react-glide-table 1.7.0 → 2.0.1
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 +54 -2
- package/dist/compound.cjs +453 -97
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +438 -82
- package/dist/core.cjs +399 -12
- package/dist/core.d.cts +40 -4
- package/dist/core.d.ts +40 -4
- package/dist/core.js +391 -12
- package/dist/index.cjs +550 -164
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +522 -144
- package/dist/{types-Cs9MiZs1.d.cts → types-DJOlsDL8.d.cts} +73 -4
- package/dist/{types-Cs9MiZs1.d.ts → types-DJOlsDL8.d.ts} +73 -4
- package/package.json +1 -1
package/dist/compound.cjs
CHANGED
|
@@ -99,20 +99,6 @@ function getCellEditDraftValue(value) {
|
|
|
99
99
|
if (value === null || value === void 0) return "";
|
|
100
100
|
return String(value);
|
|
101
101
|
}
|
|
102
|
-
function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
|
|
103
|
-
const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
|
|
104
|
-
if (!cell) return null;
|
|
105
|
-
const columnDef = cell.column.columnDef;
|
|
106
|
-
if (!isColumnEditable(columnDef)) return null;
|
|
107
|
-
const accessorKey = getColumnAccessorKey(columnDef);
|
|
108
|
-
if (!accessorKey) return null;
|
|
109
|
-
const parsed = parseCellEditValue(raw, getColumnEditType(columnDef));
|
|
110
|
-
if (!parsed.ok) return null;
|
|
111
|
-
const newData = data.map((row) => ({ ...row }));
|
|
112
|
-
if (!newData[rowIndex]) return null;
|
|
113
|
-
newData[rowIndex][accessorKey] = parsed.value;
|
|
114
|
-
return newData;
|
|
115
|
-
}
|
|
116
102
|
|
|
117
103
|
// src/components/ui/table/features/cell-selection/cellSelection.ts
|
|
118
104
|
var INITIAL_DRAG_STATE = {
|
|
@@ -497,10 +483,40 @@ function getColumnFreezeStyle(offset, options) {
|
|
|
497
483
|
return {
|
|
498
484
|
position: "sticky",
|
|
499
485
|
...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
|
|
500
|
-
zIndex: zBase + offset.stack
|
|
501
|
-
|
|
486
|
+
zIndex: zBase + offset.stack
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function resolveHeaderFreezeOffset(column, freezeOffsets) {
|
|
490
|
+
const direct = freezeOffsets.get(column.id);
|
|
491
|
+
if (direct) return direct;
|
|
492
|
+
const leaves = typeof column.getLeafColumns === "function" ? column.getLeafColumns() : column.columns && column.columns.length > 0 ? flattenHeaderLeaves(column) : [];
|
|
493
|
+
if (leaves.length === 0) return void 0;
|
|
494
|
+
const leafOffsets = [];
|
|
495
|
+
for (const leaf of leaves) {
|
|
496
|
+
const offset2 = freezeOffsets.get(leaf.id);
|
|
497
|
+
if (!offset2) return void 0;
|
|
498
|
+
leafOffsets.push(offset2);
|
|
499
|
+
}
|
|
500
|
+
const side = leafOffsets[0]?.side;
|
|
501
|
+
if (!side || leafOffsets.some((offset2) => offset2.side !== side)) {
|
|
502
|
+
return void 0;
|
|
503
|
+
}
|
|
504
|
+
const offset = Math.min(...leafOffsets.map((item) => item.offset));
|
|
505
|
+
const leftmost = leafOffsets[0];
|
|
506
|
+
const rightmost = leafOffsets[leafOffsets.length - 1];
|
|
507
|
+
return {
|
|
508
|
+
side,
|
|
509
|
+
offset,
|
|
510
|
+
edgeLeft: leftmost.edgeLeft,
|
|
511
|
+
edgeRight: rightmost.edgeRight,
|
|
512
|
+
isEdge: leftmost.edgeLeft || rightmost.edgeRight,
|
|
513
|
+
stack: Math.max(...leafOffsets.map((item) => item.stack))
|
|
502
514
|
};
|
|
503
515
|
}
|
|
516
|
+
function flattenHeaderLeaves(column) {
|
|
517
|
+
if (!column.columns || column.columns.length === 0) return [column];
|
|
518
|
+
return column.columns.flatMap((child) => flattenHeaderLeaves(child));
|
|
519
|
+
}
|
|
504
520
|
|
|
505
521
|
// src/components/ui/table/features/column-resize/columnResize.ts
|
|
506
522
|
function getColumnSizeStyle(size, options) {
|
|
@@ -1761,6 +1777,39 @@ var import_react7 = require("react");
|
|
|
1761
1777
|
|
|
1762
1778
|
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
1763
1779
|
var import_react4 = require("react");
|
|
1780
|
+
|
|
1781
|
+
// src/components/ui/table/features/cell-render/commitCellValue.ts
|
|
1782
|
+
function commitCellValue({
|
|
1783
|
+
data,
|
|
1784
|
+
rows,
|
|
1785
|
+
rowId,
|
|
1786
|
+
columnId,
|
|
1787
|
+
value,
|
|
1788
|
+
onCellChange,
|
|
1789
|
+
onDataChange
|
|
1790
|
+
}) {
|
|
1791
|
+
if (!onCellChange && !onDataChange) return true;
|
|
1792
|
+
if (onCellChange) {
|
|
1793
|
+
onCellChange(rowId, columnId, value);
|
|
1794
|
+
return true;
|
|
1795
|
+
}
|
|
1796
|
+
const row = rows.find((item) => item.id === rowId);
|
|
1797
|
+
if (!row) return false;
|
|
1798
|
+
const cell = row.getAllCells().find((item) => item.column.id === columnId) ?? row.getVisibleCells().find((item) => item.column.id === columnId);
|
|
1799
|
+
if (!cell) return false;
|
|
1800
|
+
const accessorKey = getColumnAccessorKey(cell.column.columnDef);
|
|
1801
|
+
if (!accessorKey) return false;
|
|
1802
|
+
const dataIndex = row.index;
|
|
1803
|
+
if (dataIndex < 0 || dataIndex >= data.length) return false;
|
|
1804
|
+
const next = data.map((item) => ({ ...item }));
|
|
1805
|
+
const target = next[dataIndex];
|
|
1806
|
+
if (!target) return false;
|
|
1807
|
+
target[accessorKey] = value;
|
|
1808
|
+
onDataChange?.(next);
|
|
1809
|
+
return true;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
1764
1813
|
function useCellEdit({
|
|
1765
1814
|
data,
|
|
1766
1815
|
rows,
|
|
@@ -1795,21 +1844,23 @@ function useCellEdit({
|
|
|
1795
1844
|
cancelEdit();
|
|
1796
1845
|
return true;
|
|
1797
1846
|
}
|
|
1798
|
-
const value = raw ?? draftValueRef.current;
|
|
1799
1847
|
if (!isColumnEditable(cell.column.columnDef)) {
|
|
1800
1848
|
cancelEdit();
|
|
1801
1849
|
return true;
|
|
1802
1850
|
}
|
|
1851
|
+
const value = raw ?? draftValueRef.current;
|
|
1803
1852
|
const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
|
|
1804
1853
|
if (!parsed.ok) return false;
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1854
|
+
const committed = commitCellValue({
|
|
1855
|
+
data,
|
|
1856
|
+
rows,
|
|
1857
|
+
rowId: row.id,
|
|
1858
|
+
columnId: cell.column.id,
|
|
1859
|
+
value: parsed.value,
|
|
1860
|
+
onCellChange,
|
|
1861
|
+
onDataChange
|
|
1862
|
+
});
|
|
1863
|
+
if (!committed) return false;
|
|
1813
1864
|
cancelEdit();
|
|
1814
1865
|
return true;
|
|
1815
1866
|
},
|
|
@@ -1838,13 +1889,250 @@ function useCellEdit({
|
|
|
1838
1889
|
};
|
|
1839
1890
|
}
|
|
1840
1891
|
|
|
1892
|
+
// src/components/ui/table/features/cell-render/builtins.tsx
|
|
1893
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1894
|
+
function asString(value) {
|
|
1895
|
+
if (value == null) return "";
|
|
1896
|
+
return String(value);
|
|
1897
|
+
}
|
|
1898
|
+
function asStringList(value) {
|
|
1899
|
+
if (Array.isArray(value)) {
|
|
1900
|
+
return value.map((item) => asString(item)).filter(Boolean);
|
|
1901
|
+
}
|
|
1902
|
+
if (value == null || value === "") return [];
|
|
1903
|
+
return [asString(value)];
|
|
1904
|
+
}
|
|
1905
|
+
function asDrilldownItems(value) {
|
|
1906
|
+
if (!Array.isArray(value)) return [];
|
|
1907
|
+
return value.flatMap((item) => {
|
|
1908
|
+
if (item == null) return [];
|
|
1909
|
+
if (typeof item === "string") return [{ text: item }];
|
|
1910
|
+
if (typeof item === "object") {
|
|
1911
|
+
const record = item;
|
|
1912
|
+
const text = asString(record.text ?? record.label ?? "");
|
|
1913
|
+
if (!text) return [];
|
|
1914
|
+
const img = record.img ?? record.image;
|
|
1915
|
+
return [{ text, ...typeof img === "string" ? { img } : {} }];
|
|
1916
|
+
}
|
|
1917
|
+
return [{ text: asString(item) }];
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
function escapeHtml(text) {
|
|
1921
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1922
|
+
}
|
|
1923
|
+
function simpleMarkdownToHtml(source) {
|
|
1924
|
+
const escaped = escapeHtml(source);
|
|
1925
|
+
return escaped.replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(/\n/g, "<br />");
|
|
1926
|
+
}
|
|
1927
|
+
function TextCell({ value }) {
|
|
1928
|
+
return asString(value);
|
|
1929
|
+
}
|
|
1930
|
+
function NumberCell({ value }) {
|
|
1931
|
+
if (value == null || value === "") return null;
|
|
1932
|
+
return asString(value);
|
|
1933
|
+
}
|
|
1934
|
+
function BooleanCell({ value, update, cellProps }) {
|
|
1935
|
+
const checked = Boolean(value);
|
|
1936
|
+
const readonly = Boolean(cellProps?.readonly);
|
|
1937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1938
|
+
"input",
|
|
1939
|
+
{
|
|
1940
|
+
type: "checkbox",
|
|
1941
|
+
className: "data-table-cell-boolean",
|
|
1942
|
+
checked,
|
|
1943
|
+
disabled: readonly,
|
|
1944
|
+
"aria-checked": checked,
|
|
1945
|
+
onChange: (event) => {
|
|
1946
|
+
if (readonly) return;
|
|
1947
|
+
update(event.target.checked);
|
|
1948
|
+
},
|
|
1949
|
+
onClick: (event) => {
|
|
1950
|
+
event.stopPropagation();
|
|
1951
|
+
},
|
|
1952
|
+
onMouseDown: (event) => {
|
|
1953
|
+
event.stopPropagation();
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1958
|
+
function sanitizeUriHref(raw) {
|
|
1959
|
+
const href = raw.trim();
|
|
1960
|
+
if (!href) return null;
|
|
1961
|
+
if (href.startsWith("/") || href.startsWith("#") || href.startsWith("?") || href.startsWith("./") || href.startsWith("../")) {
|
|
1962
|
+
return href;
|
|
1963
|
+
}
|
|
1964
|
+
try {
|
|
1965
|
+
const parsed = new URL(href);
|
|
1966
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
1967
|
+
if (protocol === "http:" || protocol === "https:" || protocol === "mailto:") {
|
|
1968
|
+
return href;
|
|
1969
|
+
}
|
|
1970
|
+
return null;
|
|
1971
|
+
} catch {
|
|
1972
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return null;
|
|
1973
|
+
return href;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function UriCell({ value }) {
|
|
1977
|
+
const raw = asString(value);
|
|
1978
|
+
if (!raw) return null;
|
|
1979
|
+
const href = sanitizeUriHref(raw);
|
|
1980
|
+
if (!href) {
|
|
1981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-uri", children: raw });
|
|
1982
|
+
}
|
|
1983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1984
|
+
"a",
|
|
1985
|
+
{
|
|
1986
|
+
className: "data-table-cell-uri",
|
|
1987
|
+
href,
|
|
1988
|
+
target: "_blank",
|
|
1989
|
+
rel: "noopener noreferrer",
|
|
1990
|
+
onClick: (event) => event.stopPropagation(),
|
|
1991
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
1992
|
+
children: raw
|
|
1993
|
+
}
|
|
1994
|
+
);
|
|
1995
|
+
}
|
|
1996
|
+
function ImageCell({ value }) {
|
|
1997
|
+
const urls = asStringList(value);
|
|
1998
|
+
if (urls.length === 0) return null;
|
|
1999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-image", children: urls.map((url, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2000
|
+
"img",
|
|
2001
|
+
{
|
|
2002
|
+
src: url,
|
|
2003
|
+
alt: "",
|
|
2004
|
+
className: "data-table-cell-image-item"
|
|
2005
|
+
},
|
|
2006
|
+
`${index}:${url}`
|
|
2007
|
+
)) });
|
|
2008
|
+
}
|
|
2009
|
+
function BubbleCell({ value }) {
|
|
2010
|
+
const items = asStringList(value);
|
|
2011
|
+
if (items.length === 0) return null;
|
|
2012
|
+
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}`)) });
|
|
2013
|
+
}
|
|
2014
|
+
function MarkdownCell({ value }) {
|
|
2015
|
+
const source = asString(value);
|
|
2016
|
+
if (!source) return null;
|
|
2017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2018
|
+
"span",
|
|
2019
|
+
{
|
|
2020
|
+
className: "data-table-cell-markdown",
|
|
2021
|
+
dangerouslySetInnerHTML: { __html: simpleMarkdownToHtml(source) }
|
|
2022
|
+
}
|
|
2023
|
+
);
|
|
2024
|
+
}
|
|
2025
|
+
function DrilldownCell({ value }) {
|
|
2026
|
+
const items = asDrilldownItems(value);
|
|
2027
|
+
if (items.length === 0) return null;
|
|
2028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-drilldown", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2029
|
+
"span",
|
|
2030
|
+
{
|
|
2031
|
+
className: "data-table-cell-drilldown-item",
|
|
2032
|
+
children: [
|
|
2033
|
+
item.img ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2034
|
+
"img",
|
|
2035
|
+
{
|
|
2036
|
+
src: item.img,
|
|
2037
|
+
alt: "",
|
|
2038
|
+
className: "data-table-cell-drilldown-image"
|
|
2039
|
+
}
|
|
2040
|
+
) : null,
|
|
2041
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-drilldown-text", children: item.text })
|
|
2042
|
+
]
|
|
2043
|
+
},
|
|
2044
|
+
`${index}:${item.text}:${item.img ?? ""}`
|
|
2045
|
+
)) });
|
|
2046
|
+
}
|
|
2047
|
+
function LoadingCell() {
|
|
2048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-loading", "aria-busy": "true" });
|
|
2049
|
+
}
|
|
2050
|
+
function ProtectedCell() {
|
|
2051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-protected", "aria-label": "protected", children: "****" });
|
|
2052
|
+
}
|
|
2053
|
+
function RowIdCell({ value }) {
|
|
2054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "data-table-cell-row-id", children: asString(value) });
|
|
2055
|
+
}
|
|
2056
|
+
var BUILTIN_RENDER_MAP = {
|
|
2057
|
+
text: TextCell,
|
|
2058
|
+
number: NumberCell,
|
|
2059
|
+
boolean: BooleanCell,
|
|
2060
|
+
uri: UriCell,
|
|
2061
|
+
image: ImageCell,
|
|
2062
|
+
bubble: BubbleCell,
|
|
2063
|
+
markdown: MarkdownCell,
|
|
2064
|
+
drilldown: DrilldownCell,
|
|
2065
|
+
loading: LoadingCell,
|
|
2066
|
+
protected: ProtectedCell,
|
|
2067
|
+
"row-id": RowIdCell
|
|
2068
|
+
};
|
|
2069
|
+
var BUILTIN_CELL_RENDERERS = Object.keys(BUILTIN_RENDER_MAP).map((kind) => ({
|
|
2070
|
+
kind,
|
|
2071
|
+
render: BUILTIN_RENDER_MAP[kind]
|
|
2072
|
+
}));
|
|
2073
|
+
|
|
2074
|
+
// src/components/ui/table/features/cell-render/registry.ts
|
|
2075
|
+
function createCellRendererRegistry(customRenderers = []) {
|
|
2076
|
+
const registry = /* @__PURE__ */ new Map();
|
|
2077
|
+
for (const renderer of BUILTIN_CELL_RENDERERS) {
|
|
2078
|
+
registry.set(renderer.kind, renderer);
|
|
2079
|
+
}
|
|
2080
|
+
for (const renderer of customRenderers) {
|
|
2081
|
+
registry.set(renderer.kind, renderer);
|
|
2082
|
+
}
|
|
2083
|
+
return registry;
|
|
2084
|
+
}
|
|
2085
|
+
function resolveCellRenderer(registry, kind, ctx) {
|
|
2086
|
+
if (!kind) return void 0;
|
|
2087
|
+
const renderer = registry.get(kind);
|
|
2088
|
+
if (!renderer) return void 0;
|
|
2089
|
+
if (renderer.isMatch && !renderer.isMatch(ctx)) {
|
|
2090
|
+
return void 0;
|
|
2091
|
+
}
|
|
2092
|
+
return renderer;
|
|
2093
|
+
}
|
|
2094
|
+
function formatDefaultCellValue(value) {
|
|
2095
|
+
if (value == null) return null;
|
|
2096
|
+
if (typeof value === "string") return value;
|
|
2097
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
2098
|
+
return String(value);
|
|
2099
|
+
}
|
|
2100
|
+
if (typeof value === "bigint") return value.toString();
|
|
2101
|
+
return String(value);
|
|
2102
|
+
}
|
|
2103
|
+
|
|
1841
2104
|
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
1842
2105
|
var import_react5 = require("react");
|
|
1843
2106
|
|
|
1844
2107
|
// src/components/ui/table/features/cell-selection/copyData.ts
|
|
2108
|
+
function formatPrimitive(value) {
|
|
2109
|
+
if (value === null || value === void 0) return "";
|
|
2110
|
+
if (typeof value === "string") return value;
|
|
2111
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
2112
|
+
return String(value);
|
|
2113
|
+
}
|
|
2114
|
+
return "";
|
|
2115
|
+
}
|
|
2116
|
+
function formatObjectValue(value) {
|
|
2117
|
+
const text = value.text ?? value.label ?? value.name ?? value.title;
|
|
2118
|
+
if (text != null && text !== "") {
|
|
2119
|
+
return formatCellValue(text);
|
|
2120
|
+
}
|
|
2121
|
+
try {
|
|
2122
|
+
return JSON.stringify(value);
|
|
2123
|
+
} catch {
|
|
2124
|
+
return "";
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
1845
2127
|
function formatCellValue(value) {
|
|
1846
2128
|
if (value === null || value === void 0) return "";
|
|
1847
|
-
|
|
2129
|
+
if (Array.isArray(value)) {
|
|
2130
|
+
return value.map((item) => formatCellValue(item)).filter((item) => item.length > 0).join(", ");
|
|
2131
|
+
}
|
|
2132
|
+
if (typeof value === "object") {
|
|
2133
|
+
return formatObjectValue(value);
|
|
2134
|
+
}
|
|
2135
|
+
return formatPrimitive(value);
|
|
1848
2136
|
}
|
|
1849
2137
|
function getNestedValue(row, path) {
|
|
1850
2138
|
if (!path.includes(".")) return row[path];
|
|
@@ -2726,6 +3014,7 @@ function useGlideTable(options) {
|
|
|
2726
3014
|
onDataChange,
|
|
2727
3015
|
onCellChange,
|
|
2728
3016
|
onBatchChange,
|
|
3017
|
+
cellRenderers,
|
|
2729
3018
|
preserveRowSelection = false,
|
|
2730
3019
|
toggleField,
|
|
2731
3020
|
childField,
|
|
@@ -2951,6 +3240,22 @@ function useGlideTable(options) {
|
|
|
2951
3240
|
commitEdit,
|
|
2952
3241
|
cancelEdit
|
|
2953
3242
|
} = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
|
|
3243
|
+
const cellRendererRegistry = (0, import_react7.useMemo)(
|
|
3244
|
+
() => createCellRendererRegistry(cellRenderers),
|
|
3245
|
+
[cellRenderers]
|
|
3246
|
+
);
|
|
3247
|
+
const commitRenderedCellValue = (0, import_react7.useCallback)(
|
|
3248
|
+
(rowId, columnId, value) => commitCellValue({
|
|
3249
|
+
data: tableData,
|
|
3250
|
+
rows,
|
|
3251
|
+
rowId,
|
|
3252
|
+
columnId,
|
|
3253
|
+
value,
|
|
3254
|
+
onCellChange,
|
|
3255
|
+
onDataChange
|
|
3256
|
+
}),
|
|
3257
|
+
[onCellChange, onDataChange, rows, tableData]
|
|
3258
|
+
);
|
|
2954
3259
|
const handleCellMouseDownWithCommit = (0, import_react7.useCallback)(
|
|
2955
3260
|
(rowIndex, colIndex, options2) => {
|
|
2956
3261
|
const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
|
|
@@ -3187,6 +3492,10 @@ function useGlideTable(options) {
|
|
|
3187
3492
|
onCommitEdit: commitEdit,
|
|
3188
3493
|
onCancelEdit: cancelEdit
|
|
3189
3494
|
},
|
|
3495
|
+
cellRender: {
|
|
3496
|
+
registry: cellRendererRegistry,
|
|
3497
|
+
commitValue: commitRenderedCellValue
|
|
3498
|
+
},
|
|
3190
3499
|
expand: {
|
|
3191
3500
|
enableExpand,
|
|
3192
3501
|
toggleField,
|
|
@@ -3233,6 +3542,8 @@ function useGlideTable(options) {
|
|
|
3233
3542
|
startEdit,
|
|
3234
3543
|
commitEdit,
|
|
3235
3544
|
cancelEdit,
|
|
3545
|
+
cellRendererRegistry,
|
|
3546
|
+
commitRenderedCellValue,
|
|
3236
3547
|
enableExpand,
|
|
3237
3548
|
toggleField,
|
|
3238
3549
|
expandedRows,
|
|
@@ -3298,20 +3609,20 @@ function useGlideTable(options) {
|
|
|
3298
3609
|
}
|
|
3299
3610
|
|
|
3300
3611
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
3301
|
-
var
|
|
3612
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3302
3613
|
function DefaultScroll({
|
|
3303
3614
|
scrollRef,
|
|
3304
3615
|
children,
|
|
3305
3616
|
className
|
|
3306
3617
|
}) {
|
|
3307
|
-
return /* @__PURE__ */ (0,
|
|
3618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
|
|
3308
3619
|
}
|
|
3309
3620
|
function DefaultPending({
|
|
3310
3621
|
loadingText,
|
|
3311
3622
|
className,
|
|
3312
3623
|
classNames
|
|
3313
3624
|
}) {
|
|
3314
|
-
return /* @__PURE__ */ (0,
|
|
3625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3315
3626
|
"div",
|
|
3316
3627
|
{
|
|
3317
3628
|
className: cn(
|
|
@@ -3321,7 +3632,7 @@ function DefaultPending({
|
|
|
3321
3632
|
classNames?.pending,
|
|
3322
3633
|
className
|
|
3323
3634
|
),
|
|
3324
|
-
children: /* @__PURE__ */ (0,
|
|
3635
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
|
|
3325
3636
|
}
|
|
3326
3637
|
);
|
|
3327
3638
|
}
|
|
@@ -3330,7 +3641,7 @@ function DefaultEmpty({
|
|
|
3330
3641
|
columnCount,
|
|
3331
3642
|
classNames
|
|
3332
3643
|
}) {
|
|
3333
|
-
return /* @__PURE__ */ (0,
|
|
3644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3334
3645
|
"td",
|
|
3335
3646
|
{
|
|
3336
3647
|
colSpan: columnCount,
|
|
@@ -3388,7 +3699,7 @@ function DataTable({
|
|
|
3388
3699
|
[rowContextValue, classNames]
|
|
3389
3700
|
);
|
|
3390
3701
|
if (isPending) {
|
|
3391
|
-
return /* @__PURE__ */ (0,
|
|
3702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3392
3703
|
PendingSlot,
|
|
3393
3704
|
{
|
|
3394
3705
|
loadingText,
|
|
@@ -3397,7 +3708,7 @@ function DataTable({
|
|
|
3397
3708
|
}
|
|
3398
3709
|
);
|
|
3399
3710
|
}
|
|
3400
|
-
return /* @__PURE__ */ (0,
|
|
3711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3401
3712
|
"div",
|
|
3402
3713
|
{
|
|
3403
3714
|
ref: rootRef,
|
|
@@ -3411,7 +3722,7 @@ function DataTable({
|
|
|
3411
3722
|
className
|
|
3412
3723
|
),
|
|
3413
3724
|
children: [
|
|
3414
|
-
/* @__PURE__ */ (0,
|
|
3725
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3415
3726
|
ToolbarSlot,
|
|
3416
3727
|
{
|
|
3417
3728
|
filteredCount: filteredCount ?? tableData.length,
|
|
@@ -3423,7 +3734,7 @@ function DataTable({
|
|
|
3423
3734
|
classNames
|
|
3424
3735
|
}
|
|
3425
3736
|
),
|
|
3426
|
-
enableInlineSearch ? /* @__PURE__ */ (0,
|
|
3737
|
+
enableInlineSearch ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3427
3738
|
DataTableSearch,
|
|
3428
3739
|
{
|
|
3429
3740
|
showSearch: inlineSearch.showSearch,
|
|
@@ -3445,14 +3756,14 @@ function DataTable({
|
|
|
3445
3756
|
onPrevious: inlineSearch.goToPrevious
|
|
3446
3757
|
}
|
|
3447
3758
|
) : null,
|
|
3448
|
-
/* @__PURE__ */ (0,
|
|
3759
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3449
3760
|
"table",
|
|
3450
3761
|
{
|
|
3451
3762
|
className: cn("data-table", classNames?.table),
|
|
3452
3763
|
style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
|
|
3453
3764
|
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
3454
3765
|
children: [
|
|
3455
|
-
/* @__PURE__ */ (0,
|
|
3766
|
+
/* @__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
3767
|
"tr",
|
|
3457
3768
|
{
|
|
3458
3769
|
className: cn("data-table-head-row", classNames?.headRow),
|
|
@@ -3464,7 +3775,7 @@ function DataTable({
|
|
|
3464
3775
|
force: enableColumnResize,
|
|
3465
3776
|
lockMax: enableColumnResize
|
|
3466
3777
|
});
|
|
3467
|
-
const freezeOffset = enableColumnFreeze ?
|
|
3778
|
+
const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
|
|
3468
3779
|
const freezeStyle = getColumnFreezeStyle(freezeOffset, {
|
|
3469
3780
|
isHeader: true,
|
|
3470
3781
|
headerTop: header.depth * DATA_TABLE_HEADER_ROW_HEIGHT
|
|
@@ -3473,7 +3784,7 @@ function DataTable({
|
|
|
3473
3784
|
...sizeStyle,
|
|
3474
3785
|
...freezeStyle
|
|
3475
3786
|
};
|
|
3476
|
-
return /* @__PURE__ */ (0,
|
|
3787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3477
3788
|
"th",
|
|
3478
3789
|
{
|
|
3479
3790
|
colSpan: header.colSpan,
|
|
@@ -3490,8 +3801,11 @@ function DataTable({
|
|
|
3490
3801
|
headerClassName
|
|
3491
3802
|
),
|
|
3492
3803
|
children: [
|
|
3493
|
-
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3494
|
-
|
|
3804
|
+
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3805
|
+
header.column.columnDef.header,
|
|
3806
|
+
header.getContext()
|
|
3807
|
+
),
|
|
3808
|
+
canResize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3495
3809
|
"div",
|
|
3496
3810
|
{
|
|
3497
3811
|
role: "separator",
|
|
@@ -3517,20 +3831,20 @@ function DataTable({
|
|
|
3517
3831
|
},
|
|
3518
3832
|
headerGroup.id
|
|
3519
3833
|
)) }),
|
|
3520
|
-
/* @__PURE__ */ (0,
|
|
3834
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3521
3835
|
"tbody",
|
|
3522
3836
|
{
|
|
3523
3837
|
onMouseLeave: clearHover,
|
|
3524
3838
|
className: cn("data-table-body", classNames?.body),
|
|
3525
|
-
children: rows.length === 0 ? /* @__PURE__ */ (0,
|
|
3839
|
+
children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3526
3840
|
EmptySlot,
|
|
3527
3841
|
{
|
|
3528
3842
|
emptyText,
|
|
3529
3843
|
columnCount,
|
|
3530
3844
|
classNames
|
|
3531
3845
|
}
|
|
3532
|
-
) : shouldVirtualize ? /* @__PURE__ */ (0,
|
|
3533
|
-
paddingTop > 0 && /* @__PURE__ */ (0,
|
|
3846
|
+
) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3847
|
+
paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3534
3848
|
"tr",
|
|
3535
3849
|
{
|
|
3536
3850
|
"aria-hidden": true,
|
|
@@ -3538,7 +3852,7 @@ function DataTable({
|
|
|
3538
3852
|
"data-table-virtual-spacer",
|
|
3539
3853
|
classNames?.virtualSpacer
|
|
3540
3854
|
),
|
|
3541
|
-
children: /* @__PURE__ */ (0,
|
|
3855
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3542
3856
|
"td",
|
|
3543
3857
|
{
|
|
3544
3858
|
colSpan: columnCount,
|
|
@@ -3554,7 +3868,7 @@ function DataTable({
|
|
|
3554
3868
|
virtualRows.map((virtualRow) => {
|
|
3555
3869
|
const row = rows[virtualRow.index];
|
|
3556
3870
|
if (!row) return null;
|
|
3557
|
-
return /* @__PURE__ */ (0,
|
|
3871
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3558
3872
|
RowSlot,
|
|
3559
3873
|
{
|
|
3560
3874
|
row,
|
|
@@ -3565,7 +3879,7 @@ function DataTable({
|
|
|
3565
3879
|
row.id
|
|
3566
3880
|
);
|
|
3567
3881
|
}),
|
|
3568
|
-
paddingBottom > 0 && /* @__PURE__ */ (0,
|
|
3882
|
+
paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3569
3883
|
"tr",
|
|
3570
3884
|
{
|
|
3571
3885
|
"aria-hidden": true,
|
|
@@ -3573,7 +3887,7 @@ function DataTable({
|
|
|
3573
3887
|
"data-table-virtual-spacer",
|
|
3574
3888
|
classNames?.virtualSpacer
|
|
3575
3889
|
),
|
|
3576
|
-
children: /* @__PURE__ */ (0,
|
|
3890
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3577
3891
|
"td",
|
|
3578
3892
|
{
|
|
3579
3893
|
colSpan: columnCount,
|
|
@@ -3586,7 +3900,7 @@ function DataTable({
|
|
|
3586
3900
|
)
|
|
3587
3901
|
}
|
|
3588
3902
|
)
|
|
3589
|
-
] }) : rows.map((row) => /* @__PURE__ */ (0,
|
|
3903
|
+
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3590
3904
|
RowSlot,
|
|
3591
3905
|
{
|
|
3592
3906
|
row,
|
|
@@ -3605,10 +3919,44 @@ function DataTable({
|
|
|
3605
3919
|
}
|
|
3606
3920
|
|
|
3607
3921
|
// src/components/ui/table/components/Table/Table.tsx
|
|
3608
|
-
var
|
|
3922
|
+
var import_react12 = require("react");
|
|
3923
|
+
|
|
3924
|
+
// src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
|
|
3925
|
+
var import_react9 = require("react");
|
|
3926
|
+
function ResolvedTableCell({
|
|
3927
|
+
info
|
|
3928
|
+
}) {
|
|
3929
|
+
const { cellRender } = useDataTableRowContext();
|
|
3930
|
+
const { row, column, getValue } = info;
|
|
3931
|
+
const meta = column.columnDef.meta;
|
|
3932
|
+
const value = getValue();
|
|
3933
|
+
const columnId = column.id;
|
|
3934
|
+
const update = (0, import_react9.useCallback)(
|
|
3935
|
+
(next) => {
|
|
3936
|
+
cellRender.commitValue(row.id, columnId, next);
|
|
3937
|
+
},
|
|
3938
|
+
[cellRender, columnId, row.id]
|
|
3939
|
+
);
|
|
3940
|
+
const ctx = {
|
|
3941
|
+
value,
|
|
3942
|
+
row,
|
|
3943
|
+
index: row.index,
|
|
3944
|
+
columnId,
|
|
3945
|
+
cellProps: meta?.cellProps,
|
|
3946
|
+
update
|
|
3947
|
+
};
|
|
3948
|
+
if (meta?.cellRender) {
|
|
3949
|
+
return meta.cellRender(ctx);
|
|
3950
|
+
}
|
|
3951
|
+
const renderer = resolveCellRenderer(cellRender.registry, meta?.kind, ctx);
|
|
3952
|
+
if (renderer) {
|
|
3953
|
+
return renderer.render(ctx);
|
|
3954
|
+
}
|
|
3955
|
+
return formatDefaultCellValue(value);
|
|
3956
|
+
}
|
|
3609
3957
|
|
|
3610
3958
|
// src/components/ui/table/components/Table/buildColumnDef.tsx
|
|
3611
|
-
var
|
|
3959
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3612
3960
|
function SortableHeader({
|
|
3613
3961
|
label,
|
|
3614
3962
|
field,
|
|
@@ -3617,15 +3965,18 @@ function SortableHeader({
|
|
|
3617
3965
|
}) {
|
|
3618
3966
|
const isActive = sort?.field === field;
|
|
3619
3967
|
const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
|
|
3620
|
-
return /* @__PURE__ */ (0,
|
|
3968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3621
3969
|
"button",
|
|
3622
3970
|
{
|
|
3623
3971
|
type: "button",
|
|
3624
|
-
className: cn(
|
|
3972
|
+
className: cn(
|
|
3973
|
+
"SortableHeaderJSX",
|
|
3974
|
+
isActive ? "is-active" : "is-inactive"
|
|
3975
|
+
),
|
|
3625
3976
|
onClick: () => onSort(field),
|
|
3626
3977
|
children: [
|
|
3627
|
-
/* @__PURE__ */ (0,
|
|
3628
|
-
/* @__PURE__ */ (0,
|
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: label }),
|
|
3979
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { className: "sortable-header-icon" })
|
|
3629
3980
|
]
|
|
3630
3981
|
}
|
|
3631
3982
|
);
|
|
@@ -3647,6 +3998,8 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3647
3998
|
editable,
|
|
3648
3999
|
editType,
|
|
3649
4000
|
editInputProps,
|
|
4001
|
+
kind,
|
|
4002
|
+
cellProps,
|
|
3650
4003
|
className,
|
|
3651
4004
|
headerClassName,
|
|
3652
4005
|
render
|
|
@@ -3658,18 +4011,20 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3658
4011
|
...minWidth != null ? { minSize: minWidth } : {},
|
|
3659
4012
|
...maxWidth != null ? { maxSize: maxWidth } : {},
|
|
3660
4013
|
...resizable === false ? { enableResizing: false } : {},
|
|
3661
|
-
header: sortable ? () => /* @__PURE__ */ (0,
|
|
4014
|
+
header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4015
|
+
SortableHeader,
|
|
4016
|
+
{
|
|
4017
|
+
label: children,
|
|
4018
|
+
field,
|
|
4019
|
+
sort,
|
|
4020
|
+
onSort
|
|
4021
|
+
}
|
|
4022
|
+
) : (
|
|
3662
4023
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
3663
4024
|
() => children
|
|
3664
4025
|
),
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
cell: ({ row, getValue }) => render(
|
|
3668
|
-
getValue(),
|
|
3669
|
-
row,
|
|
3670
|
-
row.index
|
|
3671
|
-
)
|
|
3672
|
-
} : {},
|
|
4026
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4027
|
+
cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResolvedTableCell, { info }),
|
|
3673
4028
|
meta: {
|
|
3674
4029
|
align,
|
|
3675
4030
|
rowSpan,
|
|
@@ -3677,6 +4032,9 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3677
4032
|
editable,
|
|
3678
4033
|
editType,
|
|
3679
4034
|
editInputProps,
|
|
4035
|
+
kind,
|
|
4036
|
+
cellProps,
|
|
4037
|
+
cellRender: render,
|
|
3680
4038
|
frozen,
|
|
3681
4039
|
className,
|
|
3682
4040
|
headerClassName
|
|
@@ -3699,10 +4057,8 @@ function buildColumnDefsFromTree(nodes, sort, onSort) {
|
|
|
3699
4057
|
const { header, align, headerClassName } = node.props;
|
|
3700
4058
|
return {
|
|
3701
4059
|
id: resolveGroupId(node.props, index),
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
() => header
|
|
3705
|
-
),
|
|
4060
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4061
|
+
header: () => header,
|
|
3706
4062
|
columns: childDefs,
|
|
3707
4063
|
enableResizing: false,
|
|
3708
4064
|
meta: {
|
|
@@ -3725,10 +4081,10 @@ function countLeafColumns(nodes) {
|
|
|
3725
4081
|
}
|
|
3726
4082
|
|
|
3727
4083
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
3728
|
-
var
|
|
4084
|
+
var import_react11 = require("react");
|
|
3729
4085
|
|
|
3730
4086
|
// src/components/ui/table/components/Table/tableChildTypes.ts
|
|
3731
|
-
var
|
|
4087
|
+
var import_react10 = require("react");
|
|
3732
4088
|
var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
|
|
3733
4089
|
var TABLE_BODY_DISPLAY_NAME = "Table.Body";
|
|
3734
4090
|
var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
|
|
@@ -3741,19 +4097,19 @@ function getComponentDisplayName(type) {
|
|
|
3741
4097
|
return void 0;
|
|
3742
4098
|
}
|
|
3743
4099
|
function isTableHeaderElement(child) {
|
|
3744
|
-
return (0,
|
|
4100
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
|
|
3745
4101
|
}
|
|
3746
4102
|
function isTableBodyElement(child) {
|
|
3747
|
-
return (0,
|
|
4103
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
|
|
3748
4104
|
}
|
|
3749
4105
|
function isTableColumnElement(child) {
|
|
3750
|
-
return (0,
|
|
4106
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
|
|
3751
4107
|
}
|
|
3752
4108
|
function isTableColumnGroupElement(child) {
|
|
3753
|
-
return (0,
|
|
4109
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
3754
4110
|
}
|
|
3755
4111
|
function isTablePaginationElement(child) {
|
|
3756
|
-
return (0,
|
|
4112
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
|
|
3757
4113
|
}
|
|
3758
4114
|
|
|
3759
4115
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
@@ -3763,7 +4119,7 @@ function parseTableChildren(children) {
|
|
|
3763
4119
|
body: null,
|
|
3764
4120
|
pagination: null
|
|
3765
4121
|
};
|
|
3766
|
-
for (const child of
|
|
4122
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3767
4123
|
if (isTableHeaderElement(child)) {
|
|
3768
4124
|
slots.header = child;
|
|
3769
4125
|
continue;
|
|
@@ -3780,7 +4136,7 @@ function parseTableChildren(children) {
|
|
|
3780
4136
|
}
|
|
3781
4137
|
function walkColumnTreeNodes(children) {
|
|
3782
4138
|
const result = [];
|
|
3783
|
-
for (const child of
|
|
4139
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3784
4140
|
if (isTableColumnElement(child)) {
|
|
3785
4141
|
result.push({
|
|
3786
4142
|
type: "leaf",
|
|
@@ -3797,7 +4153,7 @@ function walkColumnTreeNodes(children) {
|
|
|
3797
4153
|
});
|
|
3798
4154
|
continue;
|
|
3799
4155
|
}
|
|
3800
|
-
if ((0,
|
|
4156
|
+
if ((0, import_react11.isValidElement)(child)) {
|
|
3801
4157
|
const nested = child.props.children;
|
|
3802
4158
|
if (nested != null) {
|
|
3803
4159
|
result.push(...walkColumnTreeNodes(nested));
|
|
@@ -3869,7 +4225,7 @@ function TableHeader(props) {
|
|
|
3869
4225
|
TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
|
|
3870
4226
|
|
|
3871
4227
|
// src/components/ui/table/components/Table/TablePagination.tsx
|
|
3872
|
-
var
|
|
4228
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3873
4229
|
function TablePagination({
|
|
3874
4230
|
page,
|
|
3875
4231
|
pageSize = 10,
|
|
@@ -3881,8 +4237,8 @@ function TablePagination({
|
|
|
3881
4237
|
const safePage = Math.min(Math.max(1, page), totalPages);
|
|
3882
4238
|
const canGoPrev = safePage > 1;
|
|
3883
4239
|
const canGoNext = safePage < totalPages;
|
|
3884
|
-
return /* @__PURE__ */ (0,
|
|
3885
|
-
/* @__PURE__ */ (0,
|
|
4240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
|
|
4241
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3886
4242
|
"button",
|
|
3887
4243
|
{
|
|
3888
4244
|
type: "button",
|
|
@@ -3890,15 +4246,15 @@ function TablePagination({
|
|
|
3890
4246
|
disabled: !canGoPrev,
|
|
3891
4247
|
onClick: () => onChange(safePage - 1),
|
|
3892
4248
|
"aria-label": "Previous page",
|
|
3893
|
-
children: /* @__PURE__ */ (0,
|
|
4249
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronLeft, { className: "pagination-button-icon" })
|
|
3894
4250
|
}
|
|
3895
4251
|
),
|
|
3896
|
-
/* @__PURE__ */ (0,
|
|
4252
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "pagination-label", children: [
|
|
3897
4253
|
safePage,
|
|
3898
4254
|
" / ",
|
|
3899
4255
|
totalPages
|
|
3900
4256
|
] }),
|
|
3901
|
-
/* @__PURE__ */ (0,
|
|
4257
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3902
4258
|
"button",
|
|
3903
4259
|
{
|
|
3904
4260
|
type: "button",
|
|
@@ -3906,7 +4262,7 @@ function TablePagination({
|
|
|
3906
4262
|
disabled: !canGoNext,
|
|
3907
4263
|
onClick: () => onChange(safePage + 1),
|
|
3908
4264
|
"aria-label": "Next page",
|
|
3909
|
-
children: /* @__PURE__ */ (0,
|
|
4265
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronRight, { className: "pagination-button-icon" })
|
|
3910
4266
|
}
|
|
3911
4267
|
)
|
|
3912
4268
|
] });
|
|
@@ -3914,7 +4270,7 @@ function TablePagination({
|
|
|
3914
4270
|
TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
|
|
3915
4271
|
|
|
3916
4272
|
// src/components/ui/table/components/Table/Table.tsx
|
|
3917
|
-
var
|
|
4273
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3918
4274
|
function TableRoot({
|
|
3919
4275
|
data,
|
|
3920
4276
|
children,
|
|
@@ -3923,12 +4279,12 @@ function TableRoot({
|
|
|
3923
4279
|
filteredCount,
|
|
3924
4280
|
...dataTableProps
|
|
3925
4281
|
}) {
|
|
3926
|
-
const { header, pagination: paginationElement } = (0,
|
|
4282
|
+
const { header, pagination: paginationElement } = (0, import_react12.useMemo)(
|
|
3927
4283
|
() => parseTableChildren(children),
|
|
3928
4284
|
[children]
|
|
3929
4285
|
);
|
|
3930
|
-
const [sort, setSort] = (0,
|
|
3931
|
-
const handleSort = (0,
|
|
4286
|
+
const [sort, setSort] = (0, import_react12.useState)(null);
|
|
4287
|
+
const handleSort = (0, import_react12.useCallback)((field) => {
|
|
3932
4288
|
setSort((previous) => {
|
|
3933
4289
|
if (previous?.field !== field) {
|
|
3934
4290
|
return { field, direction: "asc" };
|
|
@@ -3939,8 +4295,8 @@ function TableRoot({
|
|
|
3939
4295
|
return null;
|
|
3940
4296
|
});
|
|
3941
4297
|
}, []);
|
|
3942
|
-
const columnTree = (0,
|
|
3943
|
-
const columns = (0,
|
|
4298
|
+
const columnTree = (0, import_react12.useMemo)(() => extractColumnTree(header), [header]);
|
|
4299
|
+
const columns = (0, import_react12.useMemo)(
|
|
3944
4300
|
() => buildColumnDefsFromTree(columnTree, sort, handleSort),
|
|
3945
4301
|
[columnTree, sort, handleSort]
|
|
3946
4302
|
);
|
|
@@ -3948,7 +4304,7 @@ function TableRoot({
|
|
|
3948
4304
|
const pageSize = paginationProps?.pageSize ?? 10;
|
|
3949
4305
|
const page = paginationProps?.page ?? 1;
|
|
3950
4306
|
const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
|
|
3951
|
-
const tableData = (0,
|
|
4307
|
+
const tableData = (0, import_react12.useMemo)(() => {
|
|
3952
4308
|
const sortedData = sortTableData(data, sort);
|
|
3953
4309
|
if (!paginationProps) return sortedData;
|
|
3954
4310
|
return paginateTableData(sortedData, page, pageSize);
|
|
@@ -3956,8 +4312,8 @@ function TableRoot({
|
|
|
3956
4312
|
if (countLeafColumns(columnTree) === 0) {
|
|
3957
4313
|
console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
|
|
3958
4314
|
}
|
|
3959
|
-
return /* @__PURE__ */ (0,
|
|
3960
|
-
/* @__PURE__ */ (0,
|
|
4315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "TableJSX", children: [
|
|
4316
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3961
4317
|
DataTable,
|
|
3962
4318
|
{
|
|
3963
4319
|
...dataTableProps,
|
|
@@ -3968,7 +4324,7 @@ function TableRoot({
|
|
|
3968
4324
|
className: cn(className, paginationProps && "DataTableJSX--with-pagination")
|
|
3969
4325
|
}
|
|
3970
4326
|
),
|
|
3971
|
-
paginationProps && /* @__PURE__ */ (0,
|
|
4327
|
+
paginationProps && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3972
4328
|
TablePagination,
|
|
3973
4329
|
{
|
|
3974
4330
|
page,
|
|
@@ -3993,7 +4349,7 @@ function createTable() {
|
|
|
3993
4349
|
ColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
3994
4350
|
return Object.assign(
|
|
3995
4351
|
function BoundTable(props) {
|
|
3996
|
-
return /* @__PURE__ */ (0,
|
|
4352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TableRoot, { ...props });
|
|
3997
4353
|
},
|
|
3998
4354
|
{
|
|
3999
4355
|
Header: TableHeader,
|