react-glide-table 1.7.0 → 2.0.2
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 +87 -6
- package/dist/compound.cjs +474 -98
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +459 -83
- package/dist/core.cjs +416 -12
- package/dist/core.d.cts +58 -4
- package/dist/core.d.ts +58 -4
- package/dist/core.js +407 -12
- package/dist/index.cjs +574 -166
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +545 -146
- package/dist/{types-Cs9MiZs1.d.cts → types-bgEceyRV.d.cts} +82 -4
- package/dist/{types-Cs9MiZs1.d.ts → types-bgEceyRV.d.ts} +82 -4
- package/package.json +1 -1
package/dist/compound.cjs
CHANGED
|
@@ -99,19 +99,15 @@ function getCellEditDraftValue(value) {
|
|
|
99
99
|
if (value === null || value === void 0) return "";
|
|
100
100
|
return String(value);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const newData = data.map((row) => ({ ...row }));
|
|
112
|
-
if (!newData[rowIndex]) return null;
|
|
113
|
-
newData[rowIndex][accessorKey] = parsed.value;
|
|
114
|
-
return newData;
|
|
102
|
+
|
|
103
|
+
// src/components/ui/table/features/cell-render/withCellUpdate.ts
|
|
104
|
+
function withCellUpdate(context, commitValue) {
|
|
105
|
+
return {
|
|
106
|
+
...context,
|
|
107
|
+
update: (next) => {
|
|
108
|
+
commitValue(context.row.id, context.column.id, next);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
// src/components/ui/table/features/cell-selection/cellSelection.ts
|
|
@@ -497,10 +493,40 @@ function getColumnFreezeStyle(offset, options) {
|
|
|
497
493
|
return {
|
|
498
494
|
position: "sticky",
|
|
499
495
|
...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
|
|
500
|
-
zIndex: zBase + offset.stack
|
|
501
|
-
|
|
496
|
+
zIndex: zBase + offset.stack
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function resolveHeaderFreezeOffset(column, freezeOffsets) {
|
|
500
|
+
const direct = freezeOffsets.get(column.id);
|
|
501
|
+
if (direct) return direct;
|
|
502
|
+
const leaves = typeof column.getLeafColumns === "function" ? column.getLeafColumns() : column.columns && column.columns.length > 0 ? flattenHeaderLeaves(column) : [];
|
|
503
|
+
if (leaves.length === 0) return void 0;
|
|
504
|
+
const leafOffsets = [];
|
|
505
|
+
for (const leaf of leaves) {
|
|
506
|
+
const offset2 = freezeOffsets.get(leaf.id);
|
|
507
|
+
if (!offset2) return void 0;
|
|
508
|
+
leafOffsets.push(offset2);
|
|
509
|
+
}
|
|
510
|
+
const side = leafOffsets[0]?.side;
|
|
511
|
+
if (!side || leafOffsets.some((offset2) => offset2.side !== side)) {
|
|
512
|
+
return void 0;
|
|
513
|
+
}
|
|
514
|
+
const offset = Math.min(...leafOffsets.map((item) => item.offset));
|
|
515
|
+
const leftmost = leafOffsets[0];
|
|
516
|
+
const rightmost = leafOffsets[leafOffsets.length - 1];
|
|
517
|
+
return {
|
|
518
|
+
side,
|
|
519
|
+
offset,
|
|
520
|
+
edgeLeft: leftmost.edgeLeft,
|
|
521
|
+
edgeRight: rightmost.edgeRight,
|
|
522
|
+
isEdge: leftmost.edgeLeft || rightmost.edgeRight,
|
|
523
|
+
stack: Math.max(...leafOffsets.map((item) => item.stack))
|
|
502
524
|
};
|
|
503
525
|
}
|
|
526
|
+
function flattenHeaderLeaves(column) {
|
|
527
|
+
if (!column.columns || column.columns.length === 0) return [column];
|
|
528
|
+
return column.columns.flatMap((child) => flattenHeaderLeaves(child));
|
|
529
|
+
}
|
|
504
530
|
|
|
505
531
|
// src/components/ui/table/features/column-resize/columnResize.ts
|
|
506
532
|
function getColumnSizeStyle(size, options) {
|
|
@@ -1114,6 +1140,7 @@ function DataTableRow({
|
|
|
1114
1140
|
selection,
|
|
1115
1141
|
cellSelection,
|
|
1116
1142
|
cellEdit,
|
|
1143
|
+
cellRender,
|
|
1117
1144
|
expand,
|
|
1118
1145
|
columnResize,
|
|
1119
1146
|
columnFreeze,
|
|
@@ -1151,6 +1178,10 @@ function DataTableRow({
|
|
|
1151
1178
|
onCommitEdit,
|
|
1152
1179
|
onCancelEdit
|
|
1153
1180
|
} = cellEdit;
|
|
1181
|
+
const renderCell = (tableCell) => (0, import_react_table.flexRender)(
|
|
1182
|
+
tableCell.column.columnDef.cell,
|
|
1183
|
+
withCellUpdate(tableCell.getContext(), cellRender.commitValue)
|
|
1184
|
+
);
|
|
1154
1185
|
const {
|
|
1155
1186
|
enableExpand,
|
|
1156
1187
|
toggleField,
|
|
@@ -1463,7 +1494,7 @@ function DataTableRow({
|
|
|
1463
1494
|
"expand-cell-value",
|
|
1464
1495
|
classNames?.expandCellValue
|
|
1465
1496
|
),
|
|
1466
|
-
children: (
|
|
1497
|
+
children: renderCell(cell)
|
|
1467
1498
|
}
|
|
1468
1499
|
)
|
|
1469
1500
|
]
|
|
@@ -1502,7 +1533,7 @@ function DataTableRow({
|
|
|
1502
1533
|
)
|
|
1503
1534
|
}
|
|
1504
1535
|
)
|
|
1505
|
-
] }) : (
|
|
1536
|
+
] }) : renderCell(cell),
|
|
1506
1537
|
isBottomRightCell && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1507
1538
|
"div",
|
|
1508
1539
|
{
|
|
@@ -1761,6 +1792,39 @@ var import_react7 = require("react");
|
|
|
1761
1792
|
|
|
1762
1793
|
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
1763
1794
|
var import_react4 = require("react");
|
|
1795
|
+
|
|
1796
|
+
// src/components/ui/table/features/cell-render/commitCellValue.ts
|
|
1797
|
+
function commitCellValue({
|
|
1798
|
+
data,
|
|
1799
|
+
rows,
|
|
1800
|
+
rowId,
|
|
1801
|
+
columnId,
|
|
1802
|
+
value,
|
|
1803
|
+
onCellChange,
|
|
1804
|
+
onDataChange
|
|
1805
|
+
}) {
|
|
1806
|
+
if (!onCellChange && !onDataChange) return true;
|
|
1807
|
+
if (onCellChange) {
|
|
1808
|
+
onCellChange(rowId, columnId, value);
|
|
1809
|
+
return true;
|
|
1810
|
+
}
|
|
1811
|
+
const row = rows.find((item) => item.id === rowId);
|
|
1812
|
+
if (!row) return false;
|
|
1813
|
+
const cell = row.getAllCells().find((item) => item.column.id === columnId) ?? row.getVisibleCells().find((item) => item.column.id === columnId);
|
|
1814
|
+
if (!cell) return false;
|
|
1815
|
+
const accessorKey = getColumnAccessorKey(cell.column.columnDef);
|
|
1816
|
+
if (!accessorKey) return false;
|
|
1817
|
+
const dataIndex = row.index;
|
|
1818
|
+
if (dataIndex < 0 || dataIndex >= data.length) return false;
|
|
1819
|
+
const next = data.map((item) => ({ ...item }));
|
|
1820
|
+
const target = next[dataIndex];
|
|
1821
|
+
if (!target) return false;
|
|
1822
|
+
target[accessorKey] = value;
|
|
1823
|
+
onDataChange?.(next);
|
|
1824
|
+
return true;
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
1764
1828
|
function useCellEdit({
|
|
1765
1829
|
data,
|
|
1766
1830
|
rows,
|
|
@@ -1795,21 +1859,23 @@ function useCellEdit({
|
|
|
1795
1859
|
cancelEdit();
|
|
1796
1860
|
return true;
|
|
1797
1861
|
}
|
|
1798
|
-
const value = raw ?? draftValueRef.current;
|
|
1799
1862
|
if (!isColumnEditable(cell.column.columnDef)) {
|
|
1800
1863
|
cancelEdit();
|
|
1801
1864
|
return true;
|
|
1802
1865
|
}
|
|
1866
|
+
const value = raw ?? draftValueRef.current;
|
|
1803
1867
|
const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
|
|
1804
1868
|
if (!parsed.ok) return false;
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1869
|
+
const committed = commitCellValue({
|
|
1870
|
+
data,
|
|
1871
|
+
rows,
|
|
1872
|
+
rowId: row.id,
|
|
1873
|
+
columnId: cell.column.id,
|
|
1874
|
+
value: parsed.value,
|
|
1875
|
+
onCellChange,
|
|
1876
|
+
onDataChange
|
|
1877
|
+
});
|
|
1878
|
+
if (!committed) return false;
|
|
1813
1879
|
cancelEdit();
|
|
1814
1880
|
return true;
|
|
1815
1881
|
},
|
|
@@ -1838,13 +1904,250 @@ function useCellEdit({
|
|
|
1838
1904
|
};
|
|
1839
1905
|
}
|
|
1840
1906
|
|
|
1907
|
+
// src/components/ui/table/features/cell-render/builtins.tsx
|
|
1908
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1909
|
+
function asString(value) {
|
|
1910
|
+
if (value == null) return "";
|
|
1911
|
+
return String(value);
|
|
1912
|
+
}
|
|
1913
|
+
function asStringList(value) {
|
|
1914
|
+
if (Array.isArray(value)) {
|
|
1915
|
+
return value.map((item) => asString(item)).filter(Boolean);
|
|
1916
|
+
}
|
|
1917
|
+
if (value == null || value === "") return [];
|
|
1918
|
+
return [asString(value)];
|
|
1919
|
+
}
|
|
1920
|
+
function asDrilldownItems(value) {
|
|
1921
|
+
if (!Array.isArray(value)) return [];
|
|
1922
|
+
return value.flatMap((item) => {
|
|
1923
|
+
if (item == null) return [];
|
|
1924
|
+
if (typeof item === "string") return [{ text: item }];
|
|
1925
|
+
if (typeof item === "object") {
|
|
1926
|
+
const record = item;
|
|
1927
|
+
const text = asString(record.text ?? record.label ?? "");
|
|
1928
|
+
if (!text) return [];
|
|
1929
|
+
const img = record.img ?? record.image;
|
|
1930
|
+
return [{ text, ...typeof img === "string" ? { img } : {} }];
|
|
1931
|
+
}
|
|
1932
|
+
return [{ text: asString(item) }];
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
function escapeHtml(text) {
|
|
1936
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1937
|
+
}
|
|
1938
|
+
function simpleMarkdownToHtml(source) {
|
|
1939
|
+
const escaped = escapeHtml(source);
|
|
1940
|
+
return escaped.replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(/\n/g, "<br />");
|
|
1941
|
+
}
|
|
1942
|
+
function TextCell({ value }) {
|
|
1943
|
+
return asString(value);
|
|
1944
|
+
}
|
|
1945
|
+
function NumberCell({ value }) {
|
|
1946
|
+
if (value == null || value === "") return null;
|
|
1947
|
+
return asString(value);
|
|
1948
|
+
}
|
|
1949
|
+
function BooleanCell({ value, update, cellProps }) {
|
|
1950
|
+
const checked = Boolean(value);
|
|
1951
|
+
const readonly = Boolean(cellProps?.readonly);
|
|
1952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1953
|
+
"input",
|
|
1954
|
+
{
|
|
1955
|
+
type: "checkbox",
|
|
1956
|
+
className: "data-table-cell-boolean",
|
|
1957
|
+
checked,
|
|
1958
|
+
disabled: readonly,
|
|
1959
|
+
"aria-checked": checked,
|
|
1960
|
+
onChange: (event) => {
|
|
1961
|
+
if (readonly) return;
|
|
1962
|
+
update(event.target.checked);
|
|
1963
|
+
},
|
|
1964
|
+
onClick: (event) => {
|
|
1965
|
+
event.stopPropagation();
|
|
1966
|
+
},
|
|
1967
|
+
onMouseDown: (event) => {
|
|
1968
|
+
event.stopPropagation();
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
);
|
|
1972
|
+
}
|
|
1973
|
+
function sanitizeUriHref(raw) {
|
|
1974
|
+
const href = raw.trim();
|
|
1975
|
+
if (!href) return null;
|
|
1976
|
+
if (href.startsWith("/") || href.startsWith("#") || href.startsWith("?") || href.startsWith("./") || href.startsWith("../")) {
|
|
1977
|
+
return href;
|
|
1978
|
+
}
|
|
1979
|
+
try {
|
|
1980
|
+
const parsed = new URL(href);
|
|
1981
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
1982
|
+
if (protocol === "http:" || protocol === "https:" || protocol === "mailto:") {
|
|
1983
|
+
return href;
|
|
1984
|
+
}
|
|
1985
|
+
return null;
|
|
1986
|
+
} catch {
|
|
1987
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return null;
|
|
1988
|
+
return href;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
function UriCell({ value }) {
|
|
1992
|
+
const raw = asString(value);
|
|
1993
|
+
if (!raw) return null;
|
|
1994
|
+
const href = sanitizeUriHref(raw);
|
|
1995
|
+
if (!href) {
|
|
1996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-uri", children: raw });
|
|
1997
|
+
}
|
|
1998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1999
|
+
"a",
|
|
2000
|
+
{
|
|
2001
|
+
className: "data-table-cell-uri",
|
|
2002
|
+
href,
|
|
2003
|
+
target: "_blank",
|
|
2004
|
+
rel: "noopener noreferrer",
|
|
2005
|
+
onClick: (event) => event.stopPropagation(),
|
|
2006
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
2007
|
+
children: raw
|
|
2008
|
+
}
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
function ImageCell({ value }) {
|
|
2012
|
+
const urls = asStringList(value);
|
|
2013
|
+
if (urls.length === 0) return null;
|
|
2014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-image", children: urls.map((url, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2015
|
+
"img",
|
|
2016
|
+
{
|
|
2017
|
+
src: url,
|
|
2018
|
+
alt: "",
|
|
2019
|
+
className: "data-table-cell-image-item"
|
|
2020
|
+
},
|
|
2021
|
+
`${index}:${url}`
|
|
2022
|
+
)) });
|
|
2023
|
+
}
|
|
2024
|
+
function BubbleCell({ value }) {
|
|
2025
|
+
const items = asStringList(value);
|
|
2026
|
+
if (items.length === 0) return null;
|
|
2027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-bubble", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-bubble-item", children: item }, `${index}:${item}`)) });
|
|
2028
|
+
}
|
|
2029
|
+
function MarkdownCell({ value }) {
|
|
2030
|
+
const source = asString(value);
|
|
2031
|
+
if (!source) return null;
|
|
2032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2033
|
+
"span",
|
|
2034
|
+
{
|
|
2035
|
+
className: "data-table-cell-markdown",
|
|
2036
|
+
dangerouslySetInnerHTML: { __html: simpleMarkdownToHtml(source) }
|
|
2037
|
+
}
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
function DrilldownCell({ value }) {
|
|
2041
|
+
const items = asDrilldownItems(value);
|
|
2042
|
+
if (items.length === 0) return null;
|
|
2043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-drilldown", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2044
|
+
"span",
|
|
2045
|
+
{
|
|
2046
|
+
className: "data-table-cell-drilldown-item",
|
|
2047
|
+
children: [
|
|
2048
|
+
item.img ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2049
|
+
"img",
|
|
2050
|
+
{
|
|
2051
|
+
src: item.img,
|
|
2052
|
+
alt: "",
|
|
2053
|
+
className: "data-table-cell-drilldown-image"
|
|
2054
|
+
}
|
|
2055
|
+
) : null,
|
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-drilldown-text", children: item.text })
|
|
2057
|
+
]
|
|
2058
|
+
},
|
|
2059
|
+
`${index}:${item.text}:${item.img ?? ""}`
|
|
2060
|
+
)) });
|
|
2061
|
+
}
|
|
2062
|
+
function LoadingCell() {
|
|
2063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-loading", "aria-busy": "true" });
|
|
2064
|
+
}
|
|
2065
|
+
function ProtectedCell() {
|
|
2066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-protected", "aria-label": "protected", children: "****" });
|
|
2067
|
+
}
|
|
2068
|
+
function RowIdCell({ value }) {
|
|
2069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-row-id", children: asString(value) });
|
|
2070
|
+
}
|
|
2071
|
+
var BUILTIN_RENDER_MAP = {
|
|
2072
|
+
text: TextCell,
|
|
2073
|
+
number: NumberCell,
|
|
2074
|
+
boolean: BooleanCell,
|
|
2075
|
+
uri: UriCell,
|
|
2076
|
+
image: ImageCell,
|
|
2077
|
+
bubble: BubbleCell,
|
|
2078
|
+
markdown: MarkdownCell,
|
|
2079
|
+
drilldown: DrilldownCell,
|
|
2080
|
+
loading: LoadingCell,
|
|
2081
|
+
protected: ProtectedCell,
|
|
2082
|
+
"row-id": RowIdCell
|
|
2083
|
+
};
|
|
2084
|
+
var BUILTIN_CELL_RENDERERS = Object.keys(BUILTIN_RENDER_MAP).map((kind) => ({
|
|
2085
|
+
kind,
|
|
2086
|
+
render: BUILTIN_RENDER_MAP[kind]
|
|
2087
|
+
}));
|
|
2088
|
+
|
|
2089
|
+
// src/components/ui/table/features/cell-render/registry.ts
|
|
2090
|
+
function createCellRendererRegistry(customRenderers = []) {
|
|
2091
|
+
const registry = /* @__PURE__ */ new Map();
|
|
2092
|
+
for (const renderer of BUILTIN_CELL_RENDERERS) {
|
|
2093
|
+
registry.set(renderer.kind, renderer);
|
|
2094
|
+
}
|
|
2095
|
+
for (const renderer of customRenderers) {
|
|
2096
|
+
registry.set(renderer.kind, renderer);
|
|
2097
|
+
}
|
|
2098
|
+
return registry;
|
|
2099
|
+
}
|
|
2100
|
+
function resolveCellRenderer(registry, kind, ctx) {
|
|
2101
|
+
if (!kind) return void 0;
|
|
2102
|
+
const renderer = registry.get(kind);
|
|
2103
|
+
if (!renderer) return void 0;
|
|
2104
|
+
if (renderer.isMatch && !renderer.isMatch(ctx)) {
|
|
2105
|
+
return void 0;
|
|
2106
|
+
}
|
|
2107
|
+
return renderer;
|
|
2108
|
+
}
|
|
2109
|
+
function formatDefaultCellValue(value) {
|
|
2110
|
+
if (value == null) return null;
|
|
2111
|
+
if (typeof value === "string") return value;
|
|
2112
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
2113
|
+
return String(value);
|
|
2114
|
+
}
|
|
2115
|
+
if (typeof value === "bigint") return value.toString();
|
|
2116
|
+
return String(value);
|
|
2117
|
+
}
|
|
2118
|
+
|
|
1841
2119
|
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
1842
2120
|
var import_react5 = require("react");
|
|
1843
2121
|
|
|
1844
2122
|
// src/components/ui/table/features/cell-selection/copyData.ts
|
|
2123
|
+
function formatPrimitive(value) {
|
|
2124
|
+
if (value === null || value === void 0) return "";
|
|
2125
|
+
if (typeof value === "string") return value;
|
|
2126
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
2127
|
+
return String(value);
|
|
2128
|
+
}
|
|
2129
|
+
return "";
|
|
2130
|
+
}
|
|
2131
|
+
function formatObjectValue(value) {
|
|
2132
|
+
const text = value.text ?? value.label ?? value.name ?? value.title;
|
|
2133
|
+
if (text != null && text !== "") {
|
|
2134
|
+
return formatCellValue(text);
|
|
2135
|
+
}
|
|
2136
|
+
try {
|
|
2137
|
+
return JSON.stringify(value);
|
|
2138
|
+
} catch {
|
|
2139
|
+
return "";
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
1845
2142
|
function formatCellValue(value) {
|
|
1846
2143
|
if (value === null || value === void 0) return "";
|
|
1847
|
-
|
|
2144
|
+
if (Array.isArray(value)) {
|
|
2145
|
+
return value.map((item) => formatCellValue(item)).filter((item) => item.length > 0).join(", ");
|
|
2146
|
+
}
|
|
2147
|
+
if (typeof value === "object") {
|
|
2148
|
+
return formatObjectValue(value);
|
|
2149
|
+
}
|
|
2150
|
+
return formatPrimitive(value);
|
|
1848
2151
|
}
|
|
1849
2152
|
function getNestedValue(row, path) {
|
|
1850
2153
|
if (!path.includes(".")) return row[path];
|
|
@@ -2726,6 +3029,7 @@ function useGlideTable(options) {
|
|
|
2726
3029
|
onDataChange,
|
|
2727
3030
|
onCellChange,
|
|
2728
3031
|
onBatchChange,
|
|
3032
|
+
cellRenderers,
|
|
2729
3033
|
preserveRowSelection = false,
|
|
2730
3034
|
toggleField,
|
|
2731
3035
|
childField,
|
|
@@ -2951,6 +3255,26 @@ function useGlideTable(options) {
|
|
|
2951
3255
|
commitEdit,
|
|
2952
3256
|
cancelEdit
|
|
2953
3257
|
} = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
|
|
3258
|
+
const cellRendererRegistry = (0, import_react7.useMemo)(
|
|
3259
|
+
() => createCellRendererRegistry(cellRenderers),
|
|
3260
|
+
[cellRenderers]
|
|
3261
|
+
);
|
|
3262
|
+
const commitRenderedCellValue = (0, import_react7.useCallback)(
|
|
3263
|
+
(rowId, columnId, value) => commitCellValue({
|
|
3264
|
+
data: tableData,
|
|
3265
|
+
rows,
|
|
3266
|
+
rowId,
|
|
3267
|
+
columnId,
|
|
3268
|
+
value,
|
|
3269
|
+
onCellChange,
|
|
3270
|
+
onDataChange
|
|
3271
|
+
}),
|
|
3272
|
+
[onCellChange, onDataChange, rows, tableData]
|
|
3273
|
+
);
|
|
3274
|
+
const getCellContext = (0, import_react7.useCallback)(
|
|
3275
|
+
(cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
|
|
3276
|
+
[commitRenderedCellValue]
|
|
3277
|
+
);
|
|
2954
3278
|
const handleCellMouseDownWithCommit = (0, import_react7.useCallback)(
|
|
2955
3279
|
(rowIndex, colIndex, options2) => {
|
|
2956
3280
|
const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
|
|
@@ -3187,6 +3511,10 @@ function useGlideTable(options) {
|
|
|
3187
3511
|
onCommitEdit: commitEdit,
|
|
3188
3512
|
onCancelEdit: cancelEdit
|
|
3189
3513
|
},
|
|
3514
|
+
cellRender: {
|
|
3515
|
+
registry: cellRendererRegistry,
|
|
3516
|
+
commitValue: commitRenderedCellValue
|
|
3517
|
+
},
|
|
3190
3518
|
expand: {
|
|
3191
3519
|
enableExpand,
|
|
3192
3520
|
toggleField,
|
|
@@ -3233,6 +3561,8 @@ function useGlideTable(options) {
|
|
|
3233
3561
|
startEdit,
|
|
3234
3562
|
commitEdit,
|
|
3235
3563
|
cancelEdit,
|
|
3564
|
+
cellRendererRegistry,
|
|
3565
|
+
commitRenderedCellValue,
|
|
3236
3566
|
enableExpand,
|
|
3237
3567
|
toggleField,
|
|
3238
3568
|
expandedRows,
|
|
@@ -3277,6 +3607,7 @@ function useGlideTable(options) {
|
|
|
3277
3607
|
paddingTop,
|
|
3278
3608
|
paddingBottom,
|
|
3279
3609
|
rowContextValue,
|
|
3610
|
+
getCellContext,
|
|
3280
3611
|
handleToggleSelect,
|
|
3281
3612
|
clearHover,
|
|
3282
3613
|
copySelection: stableCopySelection,
|
|
@@ -3298,20 +3629,20 @@ function useGlideTable(options) {
|
|
|
3298
3629
|
}
|
|
3299
3630
|
|
|
3300
3631
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
3301
|
-
var
|
|
3632
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3302
3633
|
function DefaultScroll({
|
|
3303
3634
|
scrollRef,
|
|
3304
3635
|
children,
|
|
3305
3636
|
className
|
|
3306
3637
|
}) {
|
|
3307
|
-
return /* @__PURE__ */ (0,
|
|
3638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
|
|
3308
3639
|
}
|
|
3309
3640
|
function DefaultPending({
|
|
3310
3641
|
loadingText,
|
|
3311
3642
|
className,
|
|
3312
3643
|
classNames
|
|
3313
3644
|
}) {
|
|
3314
|
-
return /* @__PURE__ */ (0,
|
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3315
3646
|
"div",
|
|
3316
3647
|
{
|
|
3317
3648
|
className: cn(
|
|
@@ -3321,7 +3652,7 @@ function DefaultPending({
|
|
|
3321
3652
|
classNames?.pending,
|
|
3322
3653
|
className
|
|
3323
3654
|
),
|
|
3324
|
-
children: /* @__PURE__ */ (0,
|
|
3655
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
|
|
3325
3656
|
}
|
|
3326
3657
|
);
|
|
3327
3658
|
}
|
|
@@ -3330,7 +3661,7 @@ function DefaultEmpty({
|
|
|
3330
3661
|
columnCount,
|
|
3331
3662
|
classNames
|
|
3332
3663
|
}) {
|
|
3333
|
-
return /* @__PURE__ */ (0,
|
|
3664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3334
3665
|
"td",
|
|
3335
3666
|
{
|
|
3336
3667
|
colSpan: columnCount,
|
|
@@ -3388,7 +3719,7 @@ function DataTable({
|
|
|
3388
3719
|
[rowContextValue, classNames]
|
|
3389
3720
|
);
|
|
3390
3721
|
if (isPending) {
|
|
3391
|
-
return /* @__PURE__ */ (0,
|
|
3722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3392
3723
|
PendingSlot,
|
|
3393
3724
|
{
|
|
3394
3725
|
loadingText,
|
|
@@ -3397,7 +3728,7 @@ function DataTable({
|
|
|
3397
3728
|
}
|
|
3398
3729
|
);
|
|
3399
3730
|
}
|
|
3400
|
-
return /* @__PURE__ */ (0,
|
|
3731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3401
3732
|
"div",
|
|
3402
3733
|
{
|
|
3403
3734
|
ref: rootRef,
|
|
@@ -3411,7 +3742,7 @@ function DataTable({
|
|
|
3411
3742
|
className
|
|
3412
3743
|
),
|
|
3413
3744
|
children: [
|
|
3414
|
-
/* @__PURE__ */ (0,
|
|
3745
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3415
3746
|
ToolbarSlot,
|
|
3416
3747
|
{
|
|
3417
3748
|
filteredCount: filteredCount ?? tableData.length,
|
|
@@ -3423,7 +3754,7 @@ function DataTable({
|
|
|
3423
3754
|
classNames
|
|
3424
3755
|
}
|
|
3425
3756
|
),
|
|
3426
|
-
enableInlineSearch ? /* @__PURE__ */ (0,
|
|
3757
|
+
enableInlineSearch ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3427
3758
|
DataTableSearch,
|
|
3428
3759
|
{
|
|
3429
3760
|
showSearch: inlineSearch.showSearch,
|
|
@@ -3445,14 +3776,14 @@ function DataTable({
|
|
|
3445
3776
|
onPrevious: inlineSearch.goToPrevious
|
|
3446
3777
|
}
|
|
3447
3778
|
) : null,
|
|
3448
|
-
/* @__PURE__ */ (0,
|
|
3779
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3449
3780
|
"table",
|
|
3450
3781
|
{
|
|
3451
3782
|
className: cn("data-table", classNames?.table),
|
|
3452
3783
|
style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
|
|
3453
3784
|
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
3454
3785
|
children: [
|
|
3455
|
-
/* @__PURE__ */ (0,
|
|
3786
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("thead", { className: cn("data-table-head", classNames?.head), children: headerGroups.map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3456
3787
|
"tr",
|
|
3457
3788
|
{
|
|
3458
3789
|
className: cn("data-table-head-row", classNames?.headRow),
|
|
@@ -3464,7 +3795,7 @@ function DataTable({
|
|
|
3464
3795
|
force: enableColumnResize,
|
|
3465
3796
|
lockMax: enableColumnResize
|
|
3466
3797
|
});
|
|
3467
|
-
const freezeOffset = enableColumnFreeze ?
|
|
3798
|
+
const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
|
|
3468
3799
|
const freezeStyle = getColumnFreezeStyle(freezeOffset, {
|
|
3469
3800
|
isHeader: true,
|
|
3470
3801
|
headerTop: header.depth * DATA_TABLE_HEADER_ROW_HEIGHT
|
|
@@ -3473,7 +3804,7 @@ function DataTable({
|
|
|
3473
3804
|
...sizeStyle,
|
|
3474
3805
|
...freezeStyle
|
|
3475
3806
|
};
|
|
3476
|
-
return /* @__PURE__ */ (0,
|
|
3807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3477
3808
|
"th",
|
|
3478
3809
|
{
|
|
3479
3810
|
colSpan: header.colSpan,
|
|
@@ -3490,8 +3821,11 @@ function DataTable({
|
|
|
3490
3821
|
headerClassName
|
|
3491
3822
|
),
|
|
3492
3823
|
children: [
|
|
3493
|
-
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3494
|
-
|
|
3824
|
+
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3825
|
+
header.column.columnDef.header,
|
|
3826
|
+
header.getContext()
|
|
3827
|
+
),
|
|
3828
|
+
canResize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3495
3829
|
"div",
|
|
3496
3830
|
{
|
|
3497
3831
|
role: "separator",
|
|
@@ -3517,20 +3851,20 @@ function DataTable({
|
|
|
3517
3851
|
},
|
|
3518
3852
|
headerGroup.id
|
|
3519
3853
|
)) }),
|
|
3520
|
-
/* @__PURE__ */ (0,
|
|
3854
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3521
3855
|
"tbody",
|
|
3522
3856
|
{
|
|
3523
3857
|
onMouseLeave: clearHover,
|
|
3524
3858
|
className: cn("data-table-body", classNames?.body),
|
|
3525
|
-
children: rows.length === 0 ? /* @__PURE__ */ (0,
|
|
3859
|
+
children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3526
3860
|
EmptySlot,
|
|
3527
3861
|
{
|
|
3528
3862
|
emptyText,
|
|
3529
3863
|
columnCount,
|
|
3530
3864
|
classNames
|
|
3531
3865
|
}
|
|
3532
|
-
) : shouldVirtualize ? /* @__PURE__ */ (0,
|
|
3533
|
-
paddingTop > 0 && /* @__PURE__ */ (0,
|
|
3866
|
+
) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3867
|
+
paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3534
3868
|
"tr",
|
|
3535
3869
|
{
|
|
3536
3870
|
"aria-hidden": true,
|
|
@@ -3538,7 +3872,7 @@ function DataTable({
|
|
|
3538
3872
|
"data-table-virtual-spacer",
|
|
3539
3873
|
classNames?.virtualSpacer
|
|
3540
3874
|
),
|
|
3541
|
-
children: /* @__PURE__ */ (0,
|
|
3875
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3542
3876
|
"td",
|
|
3543
3877
|
{
|
|
3544
3878
|
colSpan: columnCount,
|
|
@@ -3554,7 +3888,7 @@ function DataTable({
|
|
|
3554
3888
|
virtualRows.map((virtualRow) => {
|
|
3555
3889
|
const row = rows[virtualRow.index];
|
|
3556
3890
|
if (!row) return null;
|
|
3557
|
-
return /* @__PURE__ */ (0,
|
|
3891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3558
3892
|
RowSlot,
|
|
3559
3893
|
{
|
|
3560
3894
|
row,
|
|
@@ -3565,7 +3899,7 @@ function DataTable({
|
|
|
3565
3899
|
row.id
|
|
3566
3900
|
);
|
|
3567
3901
|
}),
|
|
3568
|
-
paddingBottom > 0 && /* @__PURE__ */ (0,
|
|
3902
|
+
paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3569
3903
|
"tr",
|
|
3570
3904
|
{
|
|
3571
3905
|
"aria-hidden": true,
|
|
@@ -3573,7 +3907,7 @@ function DataTable({
|
|
|
3573
3907
|
"data-table-virtual-spacer",
|
|
3574
3908
|
classNames?.virtualSpacer
|
|
3575
3909
|
),
|
|
3576
|
-
children: /* @__PURE__ */ (0,
|
|
3910
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3577
3911
|
"td",
|
|
3578
3912
|
{
|
|
3579
3913
|
colSpan: columnCount,
|
|
@@ -3586,7 +3920,7 @@ function DataTable({
|
|
|
3586
3920
|
)
|
|
3587
3921
|
}
|
|
3588
3922
|
)
|
|
3589
|
-
] }) : rows.map((row) => /* @__PURE__ */ (0,
|
|
3923
|
+
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3590
3924
|
RowSlot,
|
|
3591
3925
|
{
|
|
3592
3926
|
row,
|
|
@@ -3605,10 +3939,44 @@ function DataTable({
|
|
|
3605
3939
|
}
|
|
3606
3940
|
|
|
3607
3941
|
// src/components/ui/table/components/Table/Table.tsx
|
|
3608
|
-
var
|
|
3942
|
+
var import_react12 = require("react");
|
|
3943
|
+
|
|
3944
|
+
// src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
|
|
3945
|
+
var import_react9 = require("react");
|
|
3946
|
+
function ResolvedTableCell({
|
|
3947
|
+
info
|
|
3948
|
+
}) {
|
|
3949
|
+
const { cellRender } = useDataTableRowContext();
|
|
3950
|
+
const { row, column, getValue } = info;
|
|
3951
|
+
const meta = column.columnDef.meta;
|
|
3952
|
+
const value = getValue();
|
|
3953
|
+
const columnId = column.id;
|
|
3954
|
+
const update = (0, import_react9.useCallback)(
|
|
3955
|
+
(next) => {
|
|
3956
|
+
cellRender.commitValue(row.id, columnId, next);
|
|
3957
|
+
},
|
|
3958
|
+
[cellRender, columnId, row.id]
|
|
3959
|
+
);
|
|
3960
|
+
const ctx = {
|
|
3961
|
+
value,
|
|
3962
|
+
row,
|
|
3963
|
+
index: row.index,
|
|
3964
|
+
columnId,
|
|
3965
|
+
cellProps: meta?.cellProps,
|
|
3966
|
+
update
|
|
3967
|
+
};
|
|
3968
|
+
if (meta?.cellRender) {
|
|
3969
|
+
return meta.cellRender(ctx);
|
|
3970
|
+
}
|
|
3971
|
+
const renderer = resolveCellRenderer(cellRender.registry, meta?.kind, ctx);
|
|
3972
|
+
if (renderer) {
|
|
3973
|
+
return renderer.render(ctx);
|
|
3974
|
+
}
|
|
3975
|
+
return formatDefaultCellValue(value);
|
|
3976
|
+
}
|
|
3609
3977
|
|
|
3610
3978
|
// src/components/ui/table/components/Table/buildColumnDef.tsx
|
|
3611
|
-
var
|
|
3979
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3612
3980
|
function SortableHeader({
|
|
3613
3981
|
label,
|
|
3614
3982
|
field,
|
|
@@ -3617,15 +3985,18 @@ function SortableHeader({
|
|
|
3617
3985
|
}) {
|
|
3618
3986
|
const isActive = sort?.field === field;
|
|
3619
3987
|
const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
|
|
3620
|
-
return /* @__PURE__ */ (0,
|
|
3988
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3621
3989
|
"button",
|
|
3622
3990
|
{
|
|
3623
3991
|
type: "button",
|
|
3624
|
-
className: cn(
|
|
3992
|
+
className: cn(
|
|
3993
|
+
"SortableHeaderJSX",
|
|
3994
|
+
isActive ? "is-active" : "is-inactive"
|
|
3995
|
+
),
|
|
3625
3996
|
onClick: () => onSort(field),
|
|
3626
3997
|
children: [
|
|
3627
|
-
/* @__PURE__ */ (0,
|
|
3628
|
-
/* @__PURE__ */ (0,
|
|
3998
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: label }),
|
|
3999
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { className: "sortable-header-icon" })
|
|
3629
4000
|
]
|
|
3630
4001
|
}
|
|
3631
4002
|
);
|
|
@@ -3647,6 +4018,8 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3647
4018
|
editable,
|
|
3648
4019
|
editType,
|
|
3649
4020
|
editInputProps,
|
|
4021
|
+
kind,
|
|
4022
|
+
cellProps,
|
|
3650
4023
|
className,
|
|
3651
4024
|
headerClassName,
|
|
3652
4025
|
render
|
|
@@ -3658,18 +4031,20 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3658
4031
|
...minWidth != null ? { minSize: minWidth } : {},
|
|
3659
4032
|
...maxWidth != null ? { maxSize: maxWidth } : {},
|
|
3660
4033
|
...resizable === false ? { enableResizing: false } : {},
|
|
3661
|
-
header: sortable ? () => /* @__PURE__ */ (0,
|
|
4034
|
+
header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4035
|
+
SortableHeader,
|
|
4036
|
+
{
|
|
4037
|
+
label: children,
|
|
4038
|
+
field,
|
|
4039
|
+
sort,
|
|
4040
|
+
onSort
|
|
4041
|
+
}
|
|
4042
|
+
) : (
|
|
3662
4043
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
3663
4044
|
() => children
|
|
3664
4045
|
),
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
cell: ({ row, getValue }) => render(
|
|
3668
|
-
getValue(),
|
|
3669
|
-
row,
|
|
3670
|
-
row.index
|
|
3671
|
-
)
|
|
3672
|
-
} : {},
|
|
4046
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4047
|
+
cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResolvedTableCell, { info }),
|
|
3673
4048
|
meta: {
|
|
3674
4049
|
align,
|
|
3675
4050
|
rowSpan,
|
|
@@ -3677,6 +4052,9 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3677
4052
|
editable,
|
|
3678
4053
|
editType,
|
|
3679
4054
|
editInputProps,
|
|
4055
|
+
kind,
|
|
4056
|
+
cellProps,
|
|
4057
|
+
cellRender: render,
|
|
3680
4058
|
frozen,
|
|
3681
4059
|
className,
|
|
3682
4060
|
headerClassName
|
|
@@ -3699,10 +4077,8 @@ function buildColumnDefsFromTree(nodes, sort, onSort) {
|
|
|
3699
4077
|
const { header, align, headerClassName } = node.props;
|
|
3700
4078
|
return {
|
|
3701
4079
|
id: resolveGroupId(node.props, index),
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
() => header
|
|
3705
|
-
),
|
|
4080
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4081
|
+
header: () => header,
|
|
3706
4082
|
columns: childDefs,
|
|
3707
4083
|
enableResizing: false,
|
|
3708
4084
|
meta: {
|
|
@@ -3725,10 +4101,10 @@ function countLeafColumns(nodes) {
|
|
|
3725
4101
|
}
|
|
3726
4102
|
|
|
3727
4103
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
3728
|
-
var
|
|
4104
|
+
var import_react11 = require("react");
|
|
3729
4105
|
|
|
3730
4106
|
// src/components/ui/table/components/Table/tableChildTypes.ts
|
|
3731
|
-
var
|
|
4107
|
+
var import_react10 = require("react");
|
|
3732
4108
|
var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
|
|
3733
4109
|
var TABLE_BODY_DISPLAY_NAME = "Table.Body";
|
|
3734
4110
|
var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
|
|
@@ -3741,19 +4117,19 @@ function getComponentDisplayName(type) {
|
|
|
3741
4117
|
return void 0;
|
|
3742
4118
|
}
|
|
3743
4119
|
function isTableHeaderElement(child) {
|
|
3744
|
-
return (0,
|
|
4120
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
|
|
3745
4121
|
}
|
|
3746
4122
|
function isTableBodyElement(child) {
|
|
3747
|
-
return (0,
|
|
4123
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
|
|
3748
4124
|
}
|
|
3749
4125
|
function isTableColumnElement(child) {
|
|
3750
|
-
return (0,
|
|
4126
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
|
|
3751
4127
|
}
|
|
3752
4128
|
function isTableColumnGroupElement(child) {
|
|
3753
|
-
return (0,
|
|
4129
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
3754
4130
|
}
|
|
3755
4131
|
function isTablePaginationElement(child) {
|
|
3756
|
-
return (0,
|
|
4132
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
|
|
3757
4133
|
}
|
|
3758
4134
|
|
|
3759
4135
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
@@ -3763,7 +4139,7 @@ function parseTableChildren(children) {
|
|
|
3763
4139
|
body: null,
|
|
3764
4140
|
pagination: null
|
|
3765
4141
|
};
|
|
3766
|
-
for (const child of
|
|
4142
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3767
4143
|
if (isTableHeaderElement(child)) {
|
|
3768
4144
|
slots.header = child;
|
|
3769
4145
|
continue;
|
|
@@ -3780,7 +4156,7 @@ function parseTableChildren(children) {
|
|
|
3780
4156
|
}
|
|
3781
4157
|
function walkColumnTreeNodes(children) {
|
|
3782
4158
|
const result = [];
|
|
3783
|
-
for (const child of
|
|
4159
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3784
4160
|
if (isTableColumnElement(child)) {
|
|
3785
4161
|
result.push({
|
|
3786
4162
|
type: "leaf",
|
|
@@ -3797,7 +4173,7 @@ function walkColumnTreeNodes(children) {
|
|
|
3797
4173
|
});
|
|
3798
4174
|
continue;
|
|
3799
4175
|
}
|
|
3800
|
-
if ((0,
|
|
4176
|
+
if ((0, import_react11.isValidElement)(child)) {
|
|
3801
4177
|
const nested = child.props.children;
|
|
3802
4178
|
if (nested != null) {
|
|
3803
4179
|
result.push(...walkColumnTreeNodes(nested));
|
|
@@ -3869,7 +4245,7 @@ function TableHeader(props) {
|
|
|
3869
4245
|
TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
|
|
3870
4246
|
|
|
3871
4247
|
// src/components/ui/table/components/Table/TablePagination.tsx
|
|
3872
|
-
var
|
|
4248
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3873
4249
|
function TablePagination({
|
|
3874
4250
|
page,
|
|
3875
4251
|
pageSize = 10,
|
|
@@ -3881,8 +4257,8 @@ function TablePagination({
|
|
|
3881
4257
|
const safePage = Math.min(Math.max(1, page), totalPages);
|
|
3882
4258
|
const canGoPrev = safePage > 1;
|
|
3883
4259
|
const canGoNext = safePage < totalPages;
|
|
3884
|
-
return /* @__PURE__ */ (0,
|
|
3885
|
-
/* @__PURE__ */ (0,
|
|
4260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
|
|
4261
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3886
4262
|
"button",
|
|
3887
4263
|
{
|
|
3888
4264
|
type: "button",
|
|
@@ -3890,15 +4266,15 @@ function TablePagination({
|
|
|
3890
4266
|
disabled: !canGoPrev,
|
|
3891
4267
|
onClick: () => onChange(safePage - 1),
|
|
3892
4268
|
"aria-label": "Previous page",
|
|
3893
|
-
children: /* @__PURE__ */ (0,
|
|
4269
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronLeft, { className: "pagination-button-icon" })
|
|
3894
4270
|
}
|
|
3895
4271
|
),
|
|
3896
|
-
/* @__PURE__ */ (0,
|
|
4272
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "pagination-label", children: [
|
|
3897
4273
|
safePage,
|
|
3898
4274
|
" / ",
|
|
3899
4275
|
totalPages
|
|
3900
4276
|
] }),
|
|
3901
|
-
/* @__PURE__ */ (0,
|
|
4277
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3902
4278
|
"button",
|
|
3903
4279
|
{
|
|
3904
4280
|
type: "button",
|
|
@@ -3906,7 +4282,7 @@ function TablePagination({
|
|
|
3906
4282
|
disabled: !canGoNext,
|
|
3907
4283
|
onClick: () => onChange(safePage + 1),
|
|
3908
4284
|
"aria-label": "Next page",
|
|
3909
|
-
children: /* @__PURE__ */ (0,
|
|
4285
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronRight, { className: "pagination-button-icon" })
|
|
3910
4286
|
}
|
|
3911
4287
|
)
|
|
3912
4288
|
] });
|
|
@@ -3914,7 +4290,7 @@ function TablePagination({
|
|
|
3914
4290
|
TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
|
|
3915
4291
|
|
|
3916
4292
|
// src/components/ui/table/components/Table/Table.tsx
|
|
3917
|
-
var
|
|
4293
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3918
4294
|
function TableRoot({
|
|
3919
4295
|
data,
|
|
3920
4296
|
children,
|
|
@@ -3923,12 +4299,12 @@ function TableRoot({
|
|
|
3923
4299
|
filteredCount,
|
|
3924
4300
|
...dataTableProps
|
|
3925
4301
|
}) {
|
|
3926
|
-
const { header, pagination: paginationElement } = (0,
|
|
4302
|
+
const { header, pagination: paginationElement } = (0, import_react12.useMemo)(
|
|
3927
4303
|
() => parseTableChildren(children),
|
|
3928
4304
|
[children]
|
|
3929
4305
|
);
|
|
3930
|
-
const [sort, setSort] = (0,
|
|
3931
|
-
const handleSort = (0,
|
|
4306
|
+
const [sort, setSort] = (0, import_react12.useState)(null);
|
|
4307
|
+
const handleSort = (0, import_react12.useCallback)((field) => {
|
|
3932
4308
|
setSort((previous) => {
|
|
3933
4309
|
if (previous?.field !== field) {
|
|
3934
4310
|
return { field, direction: "asc" };
|
|
@@ -3939,8 +4315,8 @@ function TableRoot({
|
|
|
3939
4315
|
return null;
|
|
3940
4316
|
});
|
|
3941
4317
|
}, []);
|
|
3942
|
-
const columnTree = (0,
|
|
3943
|
-
const columns = (0,
|
|
4318
|
+
const columnTree = (0, import_react12.useMemo)(() => extractColumnTree(header), [header]);
|
|
4319
|
+
const columns = (0, import_react12.useMemo)(
|
|
3944
4320
|
() => buildColumnDefsFromTree(columnTree, sort, handleSort),
|
|
3945
4321
|
[columnTree, sort, handleSort]
|
|
3946
4322
|
);
|
|
@@ -3948,7 +4324,7 @@ function TableRoot({
|
|
|
3948
4324
|
const pageSize = paginationProps?.pageSize ?? 10;
|
|
3949
4325
|
const page = paginationProps?.page ?? 1;
|
|
3950
4326
|
const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
|
|
3951
|
-
const tableData = (0,
|
|
4327
|
+
const tableData = (0, import_react12.useMemo)(() => {
|
|
3952
4328
|
const sortedData = sortTableData(data, sort);
|
|
3953
4329
|
if (!paginationProps) return sortedData;
|
|
3954
4330
|
return paginateTableData(sortedData, page, pageSize);
|
|
@@ -3956,8 +4332,8 @@ function TableRoot({
|
|
|
3956
4332
|
if (countLeafColumns(columnTree) === 0) {
|
|
3957
4333
|
console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
|
|
3958
4334
|
}
|
|
3959
|
-
return /* @__PURE__ */ (0,
|
|
3960
|
-
/* @__PURE__ */ (0,
|
|
4335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "TableJSX", children: [
|
|
4336
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3961
4337
|
DataTable,
|
|
3962
4338
|
{
|
|
3963
4339
|
...dataTableProps,
|
|
@@ -3968,7 +4344,7 @@ function TableRoot({
|
|
|
3968
4344
|
className: cn(className, paginationProps && "DataTableJSX--with-pagination")
|
|
3969
4345
|
}
|
|
3970
4346
|
),
|
|
3971
|
-
paginationProps && /* @__PURE__ */ (0,
|
|
4347
|
+
paginationProps && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3972
4348
|
TablePagination,
|
|
3973
4349
|
{
|
|
3974
4350
|
page,
|
|
@@ -3993,7 +4369,7 @@ function createTable() {
|
|
|
3993
4369
|
ColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
3994
4370
|
return Object.assign(
|
|
3995
4371
|
function BoundTable(props) {
|
|
3996
|
-
return /* @__PURE__ */ (0,
|
|
4372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TableRoot, { ...props });
|
|
3997
4373
|
},
|
|
3998
4374
|
{
|
|
3999
4375
|
Header: TableHeader,
|