react-glide-table 1.6.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/dist/compound.cjs CHANGED
@@ -44,6 +44,7 @@ var ROW_HOVER_CLASS = "row-hoverable";
44
44
  var ROW_HOVERED_BG_CLASS = "row-hovered";
45
45
  var CELL_SELECTION_FILL_CLASS = "cell-selection-fill";
46
46
  var DATA_TABLE_ROW_HEIGHT = 44;
47
+ var DATA_TABLE_HEADER_ROW_HEIGHT = 40;
47
48
  var DATA_TABLE_VIRTUAL_OVERSCAN = 8;
48
49
  var DATA_TABLE_COLUMN_SIZE = 150;
49
50
  var DATA_TABLE_COLUMN_MIN_SIZE = 40;
@@ -98,20 +99,6 @@ function getCellEditDraftValue(value) {
98
99
  if (value === null || value === void 0) return "";
99
100
  return String(value);
100
101
  }
101
- function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
102
- const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
103
- if (!cell) return null;
104
- const columnDef = cell.column.columnDef;
105
- if (!isColumnEditable(columnDef)) return null;
106
- const accessorKey = getColumnAccessorKey(columnDef);
107
- if (!accessorKey) return null;
108
- const parsed = parseCellEditValue(raw, getColumnEditType(columnDef));
109
- if (!parsed.ok) return null;
110
- const newData = data.map((row) => ({ ...row }));
111
- if (!newData[rowIndex]) return null;
112
- newData[rowIndex][accessorKey] = parsed.value;
113
- return newData;
114
- }
115
102
 
116
103
  // src/components/ui/table/features/cell-selection/cellSelection.ts
117
104
  var INITIAL_DRAG_STATE = {
@@ -496,10 +483,40 @@ function getColumnFreezeStyle(offset, options) {
496
483
  return {
497
484
  position: "sticky",
498
485
  ...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
499
- zIndex: zBase + offset.stack,
500
- ...options?.isHeader ? { top: 0 } : {}
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))
501
514
  };
502
515
  }
516
+ function flattenHeaderLeaves(column) {
517
+ if (!column.columns || column.columns.length === 0) return [column];
518
+ return column.columns.flatMap((child) => flattenHeaderLeaves(child));
519
+ }
503
520
 
504
521
  // src/components/ui/table/features/column-resize/columnResize.ts
505
522
  function getColumnSizeStyle(size, options) {
@@ -1721,6 +1738,38 @@ function DataTableToolbar({
1721
1738
  ] });
1722
1739
  }
1723
1740
 
1741
+ // src/components/ui/table/features/column-groups/mergeHeaderGroups.ts
1742
+ function getMergedHeaderGroups(headerGroups) {
1743
+ if (headerGroups.length <= 1) {
1744
+ return headerGroups.map((group) => ({
1745
+ ...group,
1746
+ headers: group.headers.map((header) => ({
1747
+ ...header,
1748
+ mergedRowSpan: 1
1749
+ }))
1750
+ }));
1751
+ }
1752
+ const seenColumnIds = /* @__PURE__ */ new Set();
1753
+ const fullDepth = headerGroups.length;
1754
+ return headerGroups.map((group, depth) => ({
1755
+ ...group,
1756
+ headers: group.headers.filter((header) => !seenColumnIds.has(header.column.id)).map((header) => {
1757
+ seenColumnIds.add(header.column.id);
1758
+ if (header.isPlaceholder) {
1759
+ return {
1760
+ ...header,
1761
+ isPlaceholder: false,
1762
+ mergedRowSpan: fullDepth - depth
1763
+ };
1764
+ }
1765
+ return {
1766
+ ...header,
1767
+ mergedRowSpan: 1
1768
+ };
1769
+ })
1770
+ }));
1771
+ }
1772
+
1724
1773
  // src/core/useGlideTable.ts
1725
1774
  var import_react_table2 = require("@tanstack/react-table");
1726
1775
  var import_react_virtual = require("@tanstack/react-virtual");
@@ -1728,6 +1777,39 @@ var import_react7 = require("react");
1728
1777
 
1729
1778
  // src/components/ui/table/features/cell-edit/useCellEdit.ts
1730
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
1731
1813
  function useCellEdit({
1732
1814
  data,
1733
1815
  rows,
@@ -1762,21 +1844,23 @@ function useCellEdit({
1762
1844
  cancelEdit();
1763
1845
  return true;
1764
1846
  }
1765
- const value = raw ?? draftValueRef.current;
1766
1847
  if (!isColumnEditable(cell.column.columnDef)) {
1767
1848
  cancelEdit();
1768
1849
  return true;
1769
1850
  }
1851
+ const value = raw ?? draftValueRef.current;
1770
1852
  const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
1771
1853
  if (!parsed.ok) return false;
1772
- if (onCellChange) {
1773
- onCellChange(row.id, cell.column.id, parsed.value);
1774
- cancelEdit();
1775
- return true;
1776
- }
1777
- const next = applyCellEdit(data, rows, current.rowIndex, current.colIndex, value);
1778
- if (!next) return false;
1779
- onDataChange?.(next);
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;
1780
1864
  cancelEdit();
1781
1865
  return true;
1782
1866
  },
@@ -1805,13 +1889,250 @@ function useCellEdit({
1805
1889
  };
1806
1890
  }
1807
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
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
+
1808
2104
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
1809
2105
  var import_react5 = require("react");
1810
2106
 
1811
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
+ }
1812
2127
  function formatCellValue(value) {
1813
2128
  if (value === null || value === void 0) return "";
1814
- return String(value);
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);
1815
2136
  }
1816
2137
  function getNestedValue(row, path) {
1817
2138
  if (!path.includes(".")) return row[path];
@@ -2693,6 +3014,7 @@ function useGlideTable(options) {
2693
3014
  onDataChange,
2694
3015
  onCellChange,
2695
3016
  onBatchChange,
3017
+ cellRenderers,
2696
3018
  preserveRowSelection = false,
2697
3019
  toggleField,
2698
3020
  childField,
@@ -2918,6 +3240,22 @@ function useGlideTable(options) {
2918
3240
  commitEdit,
2919
3241
  cancelEdit
2920
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
+ );
2921
3259
  const handleCellMouseDownWithCommit = (0, import_react7.useCallback)(
2922
3260
  (rowIndex, colIndex, options2) => {
2923
3261
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -3154,6 +3492,10 @@ function useGlideTable(options) {
3154
3492
  onCommitEdit: commitEdit,
3155
3493
  onCancelEdit: cancelEdit
3156
3494
  },
3495
+ cellRender: {
3496
+ registry: cellRendererRegistry,
3497
+ commitValue: commitRenderedCellValue
3498
+ },
3157
3499
  expand: {
3158
3500
  enableExpand,
3159
3501
  toggleField,
@@ -3200,6 +3542,8 @@ function useGlideTable(options) {
3200
3542
  startEdit,
3201
3543
  commitEdit,
3202
3544
  cancelEdit,
3545
+ cellRendererRegistry,
3546
+ commitRenderedCellValue,
3203
3547
  enableExpand,
3204
3548
  toggleField,
3205
3549
  expandedRows,
@@ -3265,20 +3609,20 @@ function useGlideTable(options) {
3265
3609
  }
3266
3610
 
3267
3611
  // src/components/ui/table/components/DataTable/DataTable.tsx
3268
- var import_jsx_runtime6 = require("react/jsx-runtime");
3612
+ var import_jsx_runtime7 = require("react/jsx-runtime");
3269
3613
  function DefaultScroll({
3270
3614
  scrollRef,
3271
3615
  children,
3272
3616
  className
3273
3617
  }) {
3274
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
3618
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
3275
3619
  }
3276
3620
  function DefaultPending({
3277
3621
  loadingText,
3278
3622
  className,
3279
3623
  classNames
3280
3624
  }) {
3281
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3625
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3282
3626
  "div",
3283
3627
  {
3284
3628
  className: cn(
@@ -3288,7 +3632,7 @@ function DefaultPending({
3288
3632
  classNames?.pending,
3289
3633
  className
3290
3634
  ),
3291
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
3635
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
3292
3636
  }
3293
3637
  );
3294
3638
  }
@@ -3297,7 +3641,7 @@ function DefaultEmpty({
3297
3641
  columnCount,
3298
3642
  classNames
3299
3643
  }) {
3300
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3644
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3301
3645
  "td",
3302
3646
  {
3303
3647
  colSpan: columnCount,
@@ -3349,12 +3693,13 @@ function DataTable({
3349
3693
  const PendingSlot = slots?.Pending ?? DefaultPending;
3350
3694
  const EmptySlot = slots?.Empty ?? DefaultEmpty;
3351
3695
  const freezeOffsets = rowContextValue.columnFreeze.offsets;
3696
+ const headerGroups = getMergedHeaderGroups(table.getHeaderGroups());
3352
3697
  const contextValue = (0, import_react8.useMemo)(
3353
3698
  () => ({ ...rowContextValue, classNames }),
3354
3699
  [rowContextValue, classNames]
3355
3700
  );
3356
3701
  if (isPending) {
3357
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3702
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3358
3703
  PendingSlot,
3359
3704
  {
3360
3705
  loadingText,
@@ -3363,7 +3708,7 @@ function DataTable({
3363
3708
  }
3364
3709
  );
3365
3710
  }
3366
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
3711
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3367
3712
  "div",
3368
3713
  {
3369
3714
  ref: rootRef,
@@ -3377,7 +3722,7 @@ function DataTable({
3377
3722
  className
3378
3723
  ),
3379
3724
  children: [
3380
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3725
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3381
3726
  ToolbarSlot,
3382
3727
  {
3383
3728
  filteredCount: filteredCount ?? tableData.length,
@@ -3389,7 +3734,7 @@ function DataTable({
3389
3734
  classNames
3390
3735
  }
3391
3736
  ),
3392
- enableInlineSearch ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3737
+ enableInlineSearch ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3393
3738
  DataTableSearch,
3394
3739
  {
3395
3740
  showSearch: inlineSearch.showSearch,
@@ -3411,14 +3756,14 @@ function DataTable({
3411
3756
  onPrevious: inlineSearch.goToPrevious
3412
3757
  }
3413
3758
  ) : null,
3414
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
3759
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3415
3760
  "table",
3416
3761
  {
3417
3762
  className: cn("data-table", classNames?.table),
3418
3763
  style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
3419
3764
  onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
3420
3765
  children: [
3421
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("thead", { className: cn("data-table-head", classNames?.head), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
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)(
3422
3767
  "tr",
3423
3768
  {
3424
3769
  className: cn("data-table-head-row", classNames?.headRow),
@@ -3430,17 +3775,20 @@ function DataTable({
3430
3775
  force: enableColumnResize,
3431
3776
  lockMax: enableColumnResize
3432
3777
  });
3433
- const freezeOffset = enableColumnFreeze ? freezeOffsets.get(header.column.id) : void 0;
3778
+ const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
3434
3779
  const freezeStyle = getColumnFreezeStyle(freezeOffset, {
3435
- isHeader: true
3780
+ isHeader: true,
3781
+ headerTop: header.depth * DATA_TABLE_HEADER_ROW_HEIGHT
3436
3782
  });
3437
3783
  const headerStyle = {
3438
3784
  ...sizeStyle,
3439
3785
  ...freezeStyle
3440
3786
  };
3441
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
3787
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3442
3788
  "th",
3443
3789
  {
3790
+ colSpan: header.colSpan,
3791
+ rowSpan: header.mergedRowSpan,
3444
3792
  "data-resizing": header.column.getIsResizing() ? "" : void 0,
3445
3793
  "data-frozen": freezeOffset?.side,
3446
3794
  "data-freeze-edge": getColumnFreezeEdgeAttr(freezeOffset),
@@ -3453,8 +3801,11 @@ function DataTable({
3453
3801
  headerClassName
3454
3802
  ),
3455
3803
  children: [
3456
- header.isPlaceholder ? null : (0, import_react_table3.flexRender)(header.column.columnDef.header, header.getContext()),
3457
- canResize ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
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)(
3458
3809
  "div",
3459
3810
  {
3460
3811
  role: "separator",
@@ -3480,20 +3831,20 @@ function DataTable({
3480
3831
  },
3481
3832
  headerGroup.id
3482
3833
  )) }),
3483
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3834
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3484
3835
  "tbody",
3485
3836
  {
3486
3837
  onMouseLeave: clearHover,
3487
3838
  className: cn("data-table-body", classNames?.body),
3488
- children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3839
+ children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3489
3840
  EmptySlot,
3490
3841
  {
3491
3842
  emptyText,
3492
3843
  columnCount,
3493
3844
  classNames
3494
3845
  }
3495
- ) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3496
- paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3846
+ ) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3847
+ paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3497
3848
  "tr",
3498
3849
  {
3499
3850
  "aria-hidden": true,
@@ -3501,7 +3852,7 @@ function DataTable({
3501
3852
  "data-table-virtual-spacer",
3502
3853
  classNames?.virtualSpacer
3503
3854
  ),
3504
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3855
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3505
3856
  "td",
3506
3857
  {
3507
3858
  colSpan: columnCount,
@@ -3517,7 +3868,7 @@ function DataTable({
3517
3868
  virtualRows.map((virtualRow) => {
3518
3869
  const row = rows[virtualRow.index];
3519
3870
  if (!row) return null;
3520
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3871
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3521
3872
  RowSlot,
3522
3873
  {
3523
3874
  row,
@@ -3528,7 +3879,7 @@ function DataTable({
3528
3879
  row.id
3529
3880
  );
3530
3881
  }),
3531
- paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3882
+ paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3532
3883
  "tr",
3533
3884
  {
3534
3885
  "aria-hidden": true,
@@ -3536,7 +3887,7 @@ function DataTable({
3536
3887
  "data-table-virtual-spacer",
3537
3888
  classNames?.virtualSpacer
3538
3889
  ),
3539
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3890
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3540
3891
  "td",
3541
3892
  {
3542
3893
  colSpan: columnCount,
@@ -3549,7 +3900,7 @@ function DataTable({
3549
3900
  )
3550
3901
  }
3551
3902
  )
3552
- ] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3903
+ ] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3553
3904
  RowSlot,
3554
3905
  {
3555
3906
  row,
@@ -3568,10 +3919,44 @@ function DataTable({
3568
3919
  }
3569
3920
 
3570
3921
  // src/components/ui/table/components/Table/Table.tsx
3571
- var import_react11 = require("react");
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
+ }
3572
3957
 
3573
3958
  // src/components/ui/table/components/Table/buildColumnDef.tsx
3574
- var import_jsx_runtime7 = require("react/jsx-runtime");
3959
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3575
3960
  function SortableHeader({
3576
3961
  label,
3577
3962
  field,
@@ -3580,15 +3965,18 @@ function SortableHeader({
3580
3965
  }) {
3581
3966
  const isActive = sort?.field === field;
3582
3967
  const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
3583
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3968
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3584
3969
  "button",
3585
3970
  {
3586
3971
  type: "button",
3587
- className: cn("SortableHeaderJSX", isActive ? "is-active" : "is-inactive"),
3972
+ className: cn(
3973
+ "SortableHeaderJSX",
3974
+ isActive ? "is-active" : "is-inactive"
3975
+ ),
3588
3976
  onClick: () => onSort(field),
3589
3977
  children: [
3590
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: label }),
3591
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { className: "sortable-header-icon" })
3978
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: label }),
3979
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { className: "sortable-header-icon" })
3592
3980
  ]
3593
3981
  }
3594
3982
  );
@@ -3610,6 +3998,8 @@ function buildColumnDef(props, sort, onSort) {
3610
3998
  editable,
3611
3999
  editType,
3612
4000
  editInputProps,
4001
+ kind,
4002
+ cellProps,
3613
4003
  className,
3614
4004
  headerClassName,
3615
4005
  render
@@ -3621,18 +4011,20 @@ function buildColumnDef(props, sort, onSort) {
3621
4011
  ...minWidth != null ? { minSize: minWidth } : {},
3622
4012
  ...maxWidth != null ? { maxSize: maxWidth } : {},
3623
4013
  ...resizable === false ? { enableResizing: false } : {},
3624
- header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SortableHeader, { label: children, field, sort, onSort }) : (
4014
+ header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4015
+ SortableHeader,
4016
+ {
4017
+ label: children,
4018
+ field,
4019
+ sort,
4020
+ onSort
4021
+ }
4022
+ ) : (
3625
4023
  // eslint-disable-next-line @typescript-eslint/promise-function-async
3626
4024
  () => children
3627
4025
  ),
3628
- ...render ? {
3629
- // eslint-disable-next-line @typescript-eslint/promise-function-async
3630
- cell: ({ row, getValue }) => render(
3631
- getValue(),
3632
- row,
3633
- row.index
3634
- )
3635
- } : {},
4026
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
4027
+ cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResolvedTableCell, { info }),
3636
4028
  meta: {
3637
4029
  align,
3638
4030
  rowSpan,
@@ -3640,21 +4032,63 @@ function buildColumnDef(props, sort, onSort) {
3640
4032
  editable,
3641
4033
  editType,
3642
4034
  editInputProps,
4035
+ kind,
4036
+ cellProps,
4037
+ cellRender: render,
3643
4038
  frozen,
3644
4039
  className,
3645
4040
  headerClassName
3646
4041
  }
3647
4042
  };
3648
4043
  }
4044
+ function resolveGroupId(props, index) {
4045
+ if (props.id) return props.id;
4046
+ if (typeof props.header === "string" || typeof props.header === "number") {
4047
+ return `group:${props.header}:${index}`;
4048
+ }
4049
+ return `group:${index}`;
4050
+ }
4051
+ function buildColumnDefsFromTree(nodes, sort, onSort) {
4052
+ return nodes.map((node, index) => {
4053
+ if (node.type === "leaf") {
4054
+ return buildColumnDef(node.props, sort, onSort);
4055
+ }
4056
+ const childDefs = buildColumnDefsFromTree(node.columns, sort, onSort);
4057
+ const { header, align, headerClassName } = node.props;
4058
+ return {
4059
+ id: resolveGroupId(node.props, index),
4060
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
4061
+ header: () => header,
4062
+ columns: childDefs,
4063
+ enableResizing: false,
4064
+ meta: {
4065
+ align,
4066
+ headerClassName
4067
+ }
4068
+ };
4069
+ });
4070
+ }
4071
+ function countLeafColumns(nodes) {
4072
+ let count = 0;
4073
+ for (const node of nodes) {
4074
+ if (node.type === "leaf") {
4075
+ count += 1;
4076
+ } else {
4077
+ count += countLeafColumns(node.columns);
4078
+ }
4079
+ }
4080
+ return count;
4081
+ }
3649
4082
 
3650
4083
  // src/components/ui/table/components/Table/parseTableChildren.ts
3651
- var import_react10 = require("react");
4084
+ var import_react11 = require("react");
3652
4085
 
3653
4086
  // src/components/ui/table/components/Table/tableChildTypes.ts
3654
- var import_react9 = require("react");
4087
+ var import_react10 = require("react");
3655
4088
  var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
3656
4089
  var TABLE_BODY_DISPLAY_NAME = "Table.Body";
3657
4090
  var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
4091
+ var TABLE_COLUMN_GROUP_DISPLAY_NAME = "Table.ColumnGroup";
3658
4092
  var TABLE_PAGINATION_DISPLAY_NAME = "Table.Pagination";
3659
4093
  function getComponentDisplayName(type) {
3660
4094
  if (typeof type === "function" || typeof type === "object" && type !== null) {
@@ -3663,16 +4097,19 @@ function getComponentDisplayName(type) {
3663
4097
  return void 0;
3664
4098
  }
3665
4099
  function isTableHeaderElement(child) {
3666
- return (0, import_react9.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
4100
+ return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
3667
4101
  }
3668
4102
  function isTableBodyElement(child) {
3669
- return (0, import_react9.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
4103
+ return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
3670
4104
  }
3671
4105
  function isTableColumnElement(child) {
3672
- return (0, import_react9.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
4106
+ return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
4107
+ }
4108
+ function isTableColumnGroupElement(child) {
4109
+ return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
3673
4110
  }
3674
4111
  function isTablePaginationElement(child) {
3675
- return (0, import_react9.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
4112
+ return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
3676
4113
  }
3677
4114
 
3678
4115
  // src/components/ui/table/components/Table/parseTableChildren.ts
@@ -3682,7 +4119,7 @@ function parseTableChildren(children) {
3682
4119
  body: null,
3683
4120
  pagination: null
3684
4121
  };
3685
- for (const child of import_react10.Children.toArray(children)) {
4122
+ for (const child of import_react11.Children.toArray(children)) {
3686
4123
  if (isTableHeaderElement(child)) {
3687
4124
  slots.header = child;
3688
4125
  continue;
@@ -3697,26 +4134,38 @@ function parseTableChildren(children) {
3697
4134
  }
3698
4135
  return slots;
3699
4136
  }
3700
- function flattenColumnElements(children) {
4137
+ function walkColumnTreeNodes(children) {
3701
4138
  const result = [];
3702
- for (const child of import_react10.Children.toArray(children)) {
4139
+ for (const child of import_react11.Children.toArray(children)) {
3703
4140
  if (isTableColumnElement(child)) {
3704
- result.push(child);
4141
+ result.push({
4142
+ type: "leaf",
4143
+ props: child.props
4144
+ });
4145
+ continue;
4146
+ }
4147
+ if (isTableColumnGroupElement(child)) {
4148
+ const groupProps = child.props;
4149
+ result.push({
4150
+ type: "group",
4151
+ props: groupProps,
4152
+ columns: walkColumnTreeNodes(groupProps.children)
4153
+ });
3705
4154
  continue;
3706
4155
  }
3707
- if ((0, import_react10.isValidElement)(child)) {
4156
+ if ((0, import_react11.isValidElement)(child)) {
3708
4157
  const nested = child.props.children;
3709
4158
  if (nested != null) {
3710
- result.push(...flattenColumnElements(nested));
4159
+ result.push(...walkColumnTreeNodes(nested));
3711
4160
  }
3712
4161
  }
3713
4162
  }
3714
4163
  return result;
3715
4164
  }
3716
- function extractColumnElements(header) {
4165
+ function extractColumnTree(header) {
3717
4166
  if (!header) return [];
3718
4167
  const { children } = header.props;
3719
- return flattenColumnElements(children);
4168
+ return walkColumnTreeNodes(children);
3720
4169
  }
3721
4170
 
3722
4171
  // src/components/ui/table/components/Table/TableBody.tsx
@@ -3732,6 +4181,13 @@ function TableColumn(props) {
3732
4181
  }
3733
4182
  TableColumn.displayName = TABLE_COLUMN_DISPLAY_NAME;
3734
4183
 
4184
+ // src/components/ui/table/components/Table/TableColumnGroup.tsx
4185
+ function TableColumnGroup(props) {
4186
+ void props;
4187
+ return null;
4188
+ }
4189
+ TableColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
4190
+
3735
4191
  // src/components/ui/table/components/Table/tableDataPipeline.ts
3736
4192
  function sortTableData(data, sort) {
3737
4193
  if (!sort) return data;
@@ -3769,7 +4225,7 @@ function TableHeader(props) {
3769
4225
  TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
3770
4226
 
3771
4227
  // src/components/ui/table/components/Table/TablePagination.tsx
3772
- var import_jsx_runtime8 = require("react/jsx-runtime");
4228
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3773
4229
  function TablePagination({
3774
4230
  page,
3775
4231
  pageSize = 10,
@@ -3781,8 +4237,8 @@ function TablePagination({
3781
4237
  const safePage = Math.min(Math.max(1, page), totalPages);
3782
4238
  const canGoPrev = safePage > 1;
3783
4239
  const canGoNext = safePage < totalPages;
3784
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
3785
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4240
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
4241
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3786
4242
  "button",
3787
4243
  {
3788
4244
  type: "button",
@@ -3790,15 +4246,15 @@ function TablePagination({
3790
4246
  disabled: !canGoPrev,
3791
4247
  onClick: () => onChange(safePage - 1),
3792
4248
  "aria-label": "Previous page",
3793
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronLeft, { className: "pagination-button-icon" })
4249
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronLeft, { className: "pagination-button-icon" })
3794
4250
  }
3795
4251
  ),
3796
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "pagination-label", children: [
4252
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "pagination-label", children: [
3797
4253
  safePage,
3798
4254
  " / ",
3799
4255
  totalPages
3800
4256
  ] }),
3801
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4257
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3802
4258
  "button",
3803
4259
  {
3804
4260
  type: "button",
@@ -3806,7 +4262,7 @@ function TablePagination({
3806
4262
  disabled: !canGoNext,
3807
4263
  onClick: () => onChange(safePage + 1),
3808
4264
  "aria-label": "Next page",
3809
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronRight, { className: "pagination-button-icon" })
4265
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronRight, { className: "pagination-button-icon" })
3810
4266
  }
3811
4267
  )
3812
4268
  ] });
@@ -3814,7 +4270,7 @@ function TablePagination({
3814
4270
  TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
3815
4271
 
3816
4272
  // src/components/ui/table/components/Table/Table.tsx
3817
- var import_jsx_runtime9 = require("react/jsx-runtime");
4273
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3818
4274
  function TableRoot({
3819
4275
  data,
3820
4276
  children,
@@ -3823,12 +4279,12 @@ function TableRoot({
3823
4279
  filteredCount,
3824
4280
  ...dataTableProps
3825
4281
  }) {
3826
- const { header, pagination: paginationElement } = (0, import_react11.useMemo)(
4282
+ const { header, pagination: paginationElement } = (0, import_react12.useMemo)(
3827
4283
  () => parseTableChildren(children),
3828
4284
  [children]
3829
4285
  );
3830
- const [sort, setSort] = (0, import_react11.useState)(null);
3831
- const handleSort = (0, import_react11.useCallback)((field) => {
4286
+ const [sort, setSort] = (0, import_react12.useState)(null);
4287
+ const handleSort = (0, import_react12.useCallback)((field) => {
3832
4288
  setSort((previous) => {
3833
4289
  if (previous?.field !== field) {
3834
4290
  return { field, direction: "asc" };
@@ -3839,25 +4295,25 @@ function TableRoot({
3839
4295
  return null;
3840
4296
  });
3841
4297
  }, []);
3842
- const columns = (0, import_react11.useMemo)(() => {
3843
- return extractColumnElements(header).map(
3844
- (columnElement) => buildColumnDef(columnElement.props, sort, handleSort)
3845
- );
3846
- }, [header, sort, handleSort]);
4298
+ const columnTree = (0, import_react12.useMemo)(() => extractColumnTree(header), [header]);
4299
+ const columns = (0, import_react12.useMemo)(
4300
+ () => buildColumnDefsFromTree(columnTree, sort, handleSort),
4301
+ [columnTree, sort, handleSort]
4302
+ );
3847
4303
  const paginationProps = paginationElement?.props;
3848
4304
  const pageSize = paginationProps?.pageSize ?? 10;
3849
4305
  const page = paginationProps?.page ?? 1;
3850
4306
  const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
3851
- const tableData = (0, import_react11.useMemo)(() => {
4307
+ const tableData = (0, import_react12.useMemo)(() => {
3852
4308
  const sortedData = sortTableData(data, sort);
3853
4309
  if (!paginationProps) return sortedData;
3854
4310
  return paginateTableData(sortedData, page, pageSize);
3855
4311
  }, [data, sort, paginationProps, page, pageSize]);
3856
- if (columns.length === 0) {
4312
+ if (countLeafColumns(columnTree) === 0) {
3857
4313
  console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
3858
4314
  }
3859
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "TableJSX", children: [
3860
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4315
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "TableJSX", children: [
4316
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3861
4317
  DataTable,
3862
4318
  {
3863
4319
  ...dataTableProps,
@@ -3868,7 +4324,7 @@ function TableRoot({
3868
4324
  className: cn(className, paginationProps && "DataTableJSX--with-pagination")
3869
4325
  }
3870
4326
  ),
3871
- paginationProps && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4327
+ paginationProps && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3872
4328
  TablePagination,
3873
4329
  {
3874
4330
  page,
@@ -3886,13 +4342,19 @@ function createTable() {
3886
4342
  return null;
3887
4343
  }
3888
4344
  Column.displayName = TABLE_COLUMN_DISPLAY_NAME;
4345
+ function ColumnGroup(props) {
4346
+ void props;
4347
+ return null;
4348
+ }
4349
+ ColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
3889
4350
  return Object.assign(
3890
4351
  function BoundTable(props) {
3891
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TableRoot, { ...props });
4352
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TableRoot, { ...props });
3892
4353
  },
3893
4354
  {
3894
4355
  Header: TableHeader,
3895
4356
  Column,
4357
+ ColumnGroup,
3896
4358
  Body: TableBody,
3897
4359
  Pagination: TablePagination
3898
4360
  }
@@ -3901,6 +4363,7 @@ function createTable() {
3901
4363
  var Table = Object.assign(TableRoot, {
3902
4364
  Header: TableHeader,
3903
4365
  Column: TableColumn,
4366
+ ColumnGroup: TableColumnGroup,
3904
4367
  Body: TableBody,
3905
4368
  Pagination: TablePagination
3906
4369
  });