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/dist/compound.js CHANGED
@@ -71,20 +71,6 @@ function getCellEditDraftValue(value) {
71
71
  if (value === null || value === void 0) return "";
72
72
  return String(value);
73
73
  }
74
- function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
75
- const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
76
- if (!cell) return null;
77
- const columnDef = cell.column.columnDef;
78
- if (!isColumnEditable(columnDef)) return null;
79
- const accessorKey = getColumnAccessorKey(columnDef);
80
- if (!accessorKey) return null;
81
- const parsed = parseCellEditValue(raw, getColumnEditType(columnDef));
82
- if (!parsed.ok) return null;
83
- const newData = data.map((row) => ({ ...row }));
84
- if (!newData[rowIndex]) return null;
85
- newData[rowIndex][accessorKey] = parsed.value;
86
- return newData;
87
- }
88
74
 
89
75
  // src/components/ui/table/features/cell-selection/cellSelection.ts
90
76
  var INITIAL_DRAG_STATE = {
@@ -469,10 +455,40 @@ function getColumnFreezeStyle(offset, options) {
469
455
  return {
470
456
  position: "sticky",
471
457
  ...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
472
- zIndex: zBase + offset.stack,
473
- ...options?.isHeader ? { top: options.headerTop ?? 0 } : {}
458
+ zIndex: zBase + offset.stack
459
+ };
460
+ }
461
+ function resolveHeaderFreezeOffset(column, freezeOffsets) {
462
+ const direct = freezeOffsets.get(column.id);
463
+ if (direct) return direct;
464
+ const leaves = typeof column.getLeafColumns === "function" ? column.getLeafColumns() : column.columns && column.columns.length > 0 ? flattenHeaderLeaves(column) : [];
465
+ if (leaves.length === 0) return void 0;
466
+ const leafOffsets = [];
467
+ for (const leaf of leaves) {
468
+ const offset2 = freezeOffsets.get(leaf.id);
469
+ if (!offset2) return void 0;
470
+ leafOffsets.push(offset2);
471
+ }
472
+ const side = leafOffsets[0]?.side;
473
+ if (!side || leafOffsets.some((offset2) => offset2.side !== side)) {
474
+ return void 0;
475
+ }
476
+ const offset = Math.min(...leafOffsets.map((item) => item.offset));
477
+ const leftmost = leafOffsets[0];
478
+ const rightmost = leafOffsets[leafOffsets.length - 1];
479
+ return {
480
+ side,
481
+ offset,
482
+ edgeLeft: leftmost.edgeLeft,
483
+ edgeRight: rightmost.edgeRight,
484
+ isEdge: leftmost.edgeLeft || rightmost.edgeRight,
485
+ stack: Math.max(...leafOffsets.map((item) => item.stack))
474
486
  };
475
487
  }
488
+ function flattenHeaderLeaves(column) {
489
+ if (!column.columns || column.columns.length === 0) return [column];
490
+ return column.columns.flatMap((child) => flattenHeaderLeaves(child));
491
+ }
476
492
 
477
493
  // src/components/ui/table/features/column-resize/columnResize.ts
478
494
  function getColumnSizeStyle(size, options) {
@@ -1744,6 +1760,39 @@ import {
1744
1760
 
1745
1761
  // src/components/ui/table/features/cell-edit/useCellEdit.ts
1746
1762
  import { useCallback, useEffect as useEffect3, useRef as useRef3, useState } from "react";
1763
+
1764
+ // src/components/ui/table/features/cell-render/commitCellValue.ts
1765
+ function commitCellValue({
1766
+ data,
1767
+ rows,
1768
+ rowId,
1769
+ columnId,
1770
+ value,
1771
+ onCellChange,
1772
+ onDataChange
1773
+ }) {
1774
+ if (!onCellChange && !onDataChange) return true;
1775
+ if (onCellChange) {
1776
+ onCellChange(rowId, columnId, value);
1777
+ return true;
1778
+ }
1779
+ const row = rows.find((item) => item.id === rowId);
1780
+ if (!row) return false;
1781
+ const cell = row.getAllCells().find((item) => item.column.id === columnId) ?? row.getVisibleCells().find((item) => item.column.id === columnId);
1782
+ if (!cell) return false;
1783
+ const accessorKey = getColumnAccessorKey(cell.column.columnDef);
1784
+ if (!accessorKey) return false;
1785
+ const dataIndex = row.index;
1786
+ if (dataIndex < 0 || dataIndex >= data.length) return false;
1787
+ const next = data.map((item) => ({ ...item }));
1788
+ const target = next[dataIndex];
1789
+ if (!target) return false;
1790
+ target[accessorKey] = value;
1791
+ onDataChange?.(next);
1792
+ return true;
1793
+ }
1794
+
1795
+ // src/components/ui/table/features/cell-edit/useCellEdit.ts
1747
1796
  function useCellEdit({
1748
1797
  data,
1749
1798
  rows,
@@ -1778,21 +1827,23 @@ function useCellEdit({
1778
1827
  cancelEdit();
1779
1828
  return true;
1780
1829
  }
1781
- const value = raw ?? draftValueRef.current;
1782
1830
  if (!isColumnEditable(cell.column.columnDef)) {
1783
1831
  cancelEdit();
1784
1832
  return true;
1785
1833
  }
1834
+ const value = raw ?? draftValueRef.current;
1786
1835
  const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
1787
1836
  if (!parsed.ok) return false;
1788
- if (onCellChange) {
1789
- onCellChange(row.id, cell.column.id, parsed.value);
1790
- cancelEdit();
1791
- return true;
1792
- }
1793
- const next = applyCellEdit(data, rows, current.rowIndex, current.colIndex, value);
1794
- if (!next) return false;
1795
- onDataChange?.(next);
1837
+ const committed = commitCellValue({
1838
+ data,
1839
+ rows,
1840
+ rowId: row.id,
1841
+ columnId: cell.column.id,
1842
+ value: parsed.value,
1843
+ onCellChange,
1844
+ onDataChange
1845
+ });
1846
+ if (!committed) return false;
1796
1847
  cancelEdit();
1797
1848
  return true;
1798
1849
  },
@@ -1821,13 +1872,250 @@ function useCellEdit({
1821
1872
  };
1822
1873
  }
1823
1874
 
1875
+ // src/components/ui/table/features/cell-render/builtins.tsx
1876
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1877
+ function asString(value) {
1878
+ if (value == null) return "";
1879
+ return String(value);
1880
+ }
1881
+ function asStringList(value) {
1882
+ if (Array.isArray(value)) {
1883
+ return value.map((item) => asString(item)).filter(Boolean);
1884
+ }
1885
+ if (value == null || value === "") return [];
1886
+ return [asString(value)];
1887
+ }
1888
+ function asDrilldownItems(value) {
1889
+ if (!Array.isArray(value)) return [];
1890
+ return value.flatMap((item) => {
1891
+ if (item == null) return [];
1892
+ if (typeof item === "string") return [{ text: item }];
1893
+ if (typeof item === "object") {
1894
+ const record = item;
1895
+ const text = asString(record.text ?? record.label ?? "");
1896
+ if (!text) return [];
1897
+ const img = record.img ?? record.image;
1898
+ return [{ text, ...typeof img === "string" ? { img } : {} }];
1899
+ }
1900
+ return [{ text: asString(item) }];
1901
+ });
1902
+ }
1903
+ function escapeHtml(text) {
1904
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1905
+ }
1906
+ function simpleMarkdownToHtml(source) {
1907
+ const escaped = escapeHtml(source);
1908
+ return escaped.replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(/\n/g, "<br />");
1909
+ }
1910
+ function TextCell({ value }) {
1911
+ return asString(value);
1912
+ }
1913
+ function NumberCell({ value }) {
1914
+ if (value == null || value === "") return null;
1915
+ return asString(value);
1916
+ }
1917
+ function BooleanCell({ value, update, cellProps }) {
1918
+ const checked = Boolean(value);
1919
+ const readonly = Boolean(cellProps?.readonly);
1920
+ return /* @__PURE__ */ jsx6(
1921
+ "input",
1922
+ {
1923
+ type: "checkbox",
1924
+ className: "data-table-cell-boolean",
1925
+ checked,
1926
+ disabled: readonly,
1927
+ "aria-checked": checked,
1928
+ onChange: (event) => {
1929
+ if (readonly) return;
1930
+ update(event.target.checked);
1931
+ },
1932
+ onClick: (event) => {
1933
+ event.stopPropagation();
1934
+ },
1935
+ onMouseDown: (event) => {
1936
+ event.stopPropagation();
1937
+ }
1938
+ }
1939
+ );
1940
+ }
1941
+ function sanitizeUriHref(raw) {
1942
+ const href = raw.trim();
1943
+ if (!href) return null;
1944
+ if (href.startsWith("/") || href.startsWith("#") || href.startsWith("?") || href.startsWith("./") || href.startsWith("../")) {
1945
+ return href;
1946
+ }
1947
+ try {
1948
+ const parsed = new URL(href);
1949
+ const protocol = parsed.protocol.toLowerCase();
1950
+ if (protocol === "http:" || protocol === "https:" || protocol === "mailto:") {
1951
+ return href;
1952
+ }
1953
+ return null;
1954
+ } catch {
1955
+ if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return null;
1956
+ return href;
1957
+ }
1958
+ }
1959
+ function UriCell({ value }) {
1960
+ const raw = asString(value);
1961
+ if (!raw) return null;
1962
+ const href = sanitizeUriHref(raw);
1963
+ if (!href) {
1964
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-uri", children: raw });
1965
+ }
1966
+ return /* @__PURE__ */ jsx6(
1967
+ "a",
1968
+ {
1969
+ className: "data-table-cell-uri",
1970
+ href,
1971
+ target: "_blank",
1972
+ rel: "noopener noreferrer",
1973
+ onClick: (event) => event.stopPropagation(),
1974
+ onMouseDown: (event) => event.stopPropagation(),
1975
+ children: raw
1976
+ }
1977
+ );
1978
+ }
1979
+ function ImageCell({ value }) {
1980
+ const urls = asStringList(value);
1981
+ if (urls.length === 0) return null;
1982
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-image", children: urls.map((url, index) => /* @__PURE__ */ jsx6(
1983
+ "img",
1984
+ {
1985
+ src: url,
1986
+ alt: "",
1987
+ className: "data-table-cell-image-item"
1988
+ },
1989
+ `${index}:${url}`
1990
+ )) });
1991
+ }
1992
+ function BubbleCell({ value }) {
1993
+ const items = asStringList(value);
1994
+ if (items.length === 0) return null;
1995
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-bubble", children: items.map((item, index) => /* @__PURE__ */ jsx6("span", { className: "data-table-cell-bubble-item", children: item }, `${index}:${item}`)) });
1996
+ }
1997
+ function MarkdownCell({ value }) {
1998
+ const source = asString(value);
1999
+ if (!source) return null;
2000
+ return /* @__PURE__ */ jsx6(
2001
+ "span",
2002
+ {
2003
+ className: "data-table-cell-markdown",
2004
+ dangerouslySetInnerHTML: { __html: simpleMarkdownToHtml(source) }
2005
+ }
2006
+ );
2007
+ }
2008
+ function DrilldownCell({ value }) {
2009
+ const items = asDrilldownItems(value);
2010
+ if (items.length === 0) return null;
2011
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-drilldown", children: items.map((item, index) => /* @__PURE__ */ jsxs5(
2012
+ "span",
2013
+ {
2014
+ className: "data-table-cell-drilldown-item",
2015
+ children: [
2016
+ item.img ? /* @__PURE__ */ jsx6(
2017
+ "img",
2018
+ {
2019
+ src: item.img,
2020
+ alt: "",
2021
+ className: "data-table-cell-drilldown-image"
2022
+ }
2023
+ ) : null,
2024
+ /* @__PURE__ */ jsx6("span", { className: "data-table-cell-drilldown-text", children: item.text })
2025
+ ]
2026
+ },
2027
+ `${index}:${item.text}:${item.img ?? ""}`
2028
+ )) });
2029
+ }
2030
+ function LoadingCell() {
2031
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-loading", "aria-busy": "true" });
2032
+ }
2033
+ function ProtectedCell() {
2034
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-protected", "aria-label": "protected", children: "****" });
2035
+ }
2036
+ function RowIdCell({ value }) {
2037
+ return /* @__PURE__ */ jsx6("span", { className: "data-table-cell-row-id", children: asString(value) });
2038
+ }
2039
+ var BUILTIN_RENDER_MAP = {
2040
+ text: TextCell,
2041
+ number: NumberCell,
2042
+ boolean: BooleanCell,
2043
+ uri: UriCell,
2044
+ image: ImageCell,
2045
+ bubble: BubbleCell,
2046
+ markdown: MarkdownCell,
2047
+ drilldown: DrilldownCell,
2048
+ loading: LoadingCell,
2049
+ protected: ProtectedCell,
2050
+ "row-id": RowIdCell
2051
+ };
2052
+ var BUILTIN_CELL_RENDERERS = Object.keys(BUILTIN_RENDER_MAP).map((kind) => ({
2053
+ kind,
2054
+ render: BUILTIN_RENDER_MAP[kind]
2055
+ }));
2056
+
2057
+ // src/components/ui/table/features/cell-render/registry.ts
2058
+ function createCellRendererRegistry(customRenderers = []) {
2059
+ const registry = /* @__PURE__ */ new Map();
2060
+ for (const renderer of BUILTIN_CELL_RENDERERS) {
2061
+ registry.set(renderer.kind, renderer);
2062
+ }
2063
+ for (const renderer of customRenderers) {
2064
+ registry.set(renderer.kind, renderer);
2065
+ }
2066
+ return registry;
2067
+ }
2068
+ function resolveCellRenderer(registry, kind, ctx) {
2069
+ if (!kind) return void 0;
2070
+ const renderer = registry.get(kind);
2071
+ if (!renderer) return void 0;
2072
+ if (renderer.isMatch && !renderer.isMatch(ctx)) {
2073
+ return void 0;
2074
+ }
2075
+ return renderer;
2076
+ }
2077
+ function formatDefaultCellValue(value) {
2078
+ if (value == null) return null;
2079
+ if (typeof value === "string") return value;
2080
+ if (typeof value === "number" || typeof value === "boolean") {
2081
+ return String(value);
2082
+ }
2083
+ if (typeof value === "bigint") return value.toString();
2084
+ return String(value);
2085
+ }
2086
+
1824
2087
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
1825
2088
  import { useCallback as useCallback2, useEffect as useEffect4, useRef as useRef4, useState as useState2 } from "react";
1826
2089
 
1827
2090
  // src/components/ui/table/features/cell-selection/copyData.ts
2091
+ function formatPrimitive(value) {
2092
+ if (value === null || value === void 0) return "";
2093
+ if (typeof value === "string") return value;
2094
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
2095
+ return String(value);
2096
+ }
2097
+ return "";
2098
+ }
2099
+ function formatObjectValue(value) {
2100
+ const text = value.text ?? value.label ?? value.name ?? value.title;
2101
+ if (text != null && text !== "") {
2102
+ return formatCellValue(text);
2103
+ }
2104
+ try {
2105
+ return JSON.stringify(value);
2106
+ } catch {
2107
+ return "";
2108
+ }
2109
+ }
1828
2110
  function formatCellValue(value) {
1829
2111
  if (value === null || value === void 0) return "";
1830
- return String(value);
2112
+ if (Array.isArray(value)) {
2113
+ return value.map((item) => formatCellValue(item)).filter((item) => item.length > 0).join(", ");
2114
+ }
2115
+ if (typeof value === "object") {
2116
+ return formatObjectValue(value);
2117
+ }
2118
+ return formatPrimitive(value);
1831
2119
  }
1832
2120
  function getNestedValue(row, path) {
1833
2121
  if (!path.includes(".")) return row[path];
@@ -2716,6 +3004,7 @@ function useGlideTable(options) {
2716
3004
  onDataChange,
2717
3005
  onCellChange,
2718
3006
  onBatchChange,
3007
+ cellRenderers,
2719
3008
  preserveRowSelection = false,
2720
3009
  toggleField,
2721
3010
  childField,
@@ -2941,6 +3230,22 @@ function useGlideTable(options) {
2941
3230
  commitEdit,
2942
3231
  cancelEdit
2943
3232
  } = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
3233
+ const cellRendererRegistry = useMemo3(
3234
+ () => createCellRendererRegistry(cellRenderers),
3235
+ [cellRenderers]
3236
+ );
3237
+ const commitRenderedCellValue = useCallback4(
3238
+ (rowId, columnId, value) => commitCellValue({
3239
+ data: tableData,
3240
+ rows,
3241
+ rowId,
3242
+ columnId,
3243
+ value,
3244
+ onCellChange,
3245
+ onDataChange
3246
+ }),
3247
+ [onCellChange, onDataChange, rows, tableData]
3248
+ );
2944
3249
  const handleCellMouseDownWithCommit = useCallback4(
2945
3250
  (rowIndex, colIndex, options2) => {
2946
3251
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -3177,6 +3482,10 @@ function useGlideTable(options) {
3177
3482
  onCommitEdit: commitEdit,
3178
3483
  onCancelEdit: cancelEdit
3179
3484
  },
3485
+ cellRender: {
3486
+ registry: cellRendererRegistry,
3487
+ commitValue: commitRenderedCellValue
3488
+ },
3180
3489
  expand: {
3181
3490
  enableExpand,
3182
3491
  toggleField,
@@ -3223,6 +3532,8 @@ function useGlideTable(options) {
3223
3532
  startEdit,
3224
3533
  commitEdit,
3225
3534
  cancelEdit,
3535
+ cellRendererRegistry,
3536
+ commitRenderedCellValue,
3226
3537
  enableExpand,
3227
3538
  toggleField,
3228
3539
  expandedRows,
@@ -3288,20 +3599,20 @@ function useGlideTable(options) {
3288
3599
  }
3289
3600
 
3290
3601
  // src/components/ui/table/components/DataTable/DataTable.tsx
3291
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
3602
+ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
3292
3603
  function DefaultScroll({
3293
3604
  scrollRef,
3294
3605
  children,
3295
3606
  className
3296
3607
  }) {
3297
- return /* @__PURE__ */ jsx6("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
3608
+ return /* @__PURE__ */ jsx7("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
3298
3609
  }
3299
3610
  function DefaultPending({
3300
3611
  loadingText,
3301
3612
  className,
3302
3613
  classNames
3303
3614
  }) {
3304
- return /* @__PURE__ */ jsx6(
3615
+ return /* @__PURE__ */ jsx7(
3305
3616
  "div",
3306
3617
  {
3307
3618
  className: cn(
@@ -3311,7 +3622,7 @@ function DefaultPending({
3311
3622
  classNames?.pending,
3312
3623
  className
3313
3624
  ),
3314
- children: /* @__PURE__ */ jsx6("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
3625
+ children: /* @__PURE__ */ jsx7("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
3315
3626
  }
3316
3627
  );
3317
3628
  }
@@ -3320,7 +3631,7 @@ function DefaultEmpty({
3320
3631
  columnCount,
3321
3632
  classNames
3322
3633
  }) {
3323
- return /* @__PURE__ */ jsx6("tr", { children: /* @__PURE__ */ jsx6(
3634
+ return /* @__PURE__ */ jsx7("tr", { children: /* @__PURE__ */ jsx7(
3324
3635
  "td",
3325
3636
  {
3326
3637
  colSpan: columnCount,
@@ -3378,7 +3689,7 @@ function DataTable({
3378
3689
  [rowContextValue, classNames]
3379
3690
  );
3380
3691
  if (isPending) {
3381
- return /* @__PURE__ */ jsx6(
3692
+ return /* @__PURE__ */ jsx7(
3382
3693
  PendingSlot,
3383
3694
  {
3384
3695
  loadingText,
@@ -3387,7 +3698,7 @@ function DataTable({
3387
3698
  }
3388
3699
  );
3389
3700
  }
3390
- return /* @__PURE__ */ jsxs5(
3701
+ return /* @__PURE__ */ jsxs6(
3391
3702
  "div",
3392
3703
  {
3393
3704
  ref: rootRef,
@@ -3401,7 +3712,7 @@ function DataTable({
3401
3712
  className
3402
3713
  ),
3403
3714
  children: [
3404
- /* @__PURE__ */ jsx6(
3715
+ /* @__PURE__ */ jsx7(
3405
3716
  ToolbarSlot,
3406
3717
  {
3407
3718
  filteredCount: filteredCount ?? tableData.length,
@@ -3413,7 +3724,7 @@ function DataTable({
3413
3724
  classNames
3414
3725
  }
3415
3726
  ),
3416
- enableInlineSearch ? /* @__PURE__ */ jsx6(
3727
+ enableInlineSearch ? /* @__PURE__ */ jsx7(
3417
3728
  DataTableSearch,
3418
3729
  {
3419
3730
  showSearch: inlineSearch.showSearch,
@@ -3435,14 +3746,14 @@ function DataTable({
3435
3746
  onPrevious: inlineSearch.goToPrevious
3436
3747
  }
3437
3748
  ) : null,
3438
- /* @__PURE__ */ jsx6(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ jsxs5(
3749
+ /* @__PURE__ */ jsx7(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ jsxs6(
3439
3750
  "table",
3440
3751
  {
3441
3752
  className: cn("data-table", classNames?.table),
3442
3753
  style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
3443
3754
  onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
3444
3755
  children: [
3445
- /* @__PURE__ */ jsx6("thead", { className: cn("data-table-head", classNames?.head), children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsx6(
3756
+ /* @__PURE__ */ jsx7("thead", { className: cn("data-table-head", classNames?.head), children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsx7(
3446
3757
  "tr",
3447
3758
  {
3448
3759
  className: cn("data-table-head-row", classNames?.headRow),
@@ -3454,7 +3765,7 @@ function DataTable({
3454
3765
  force: enableColumnResize,
3455
3766
  lockMax: enableColumnResize
3456
3767
  });
3457
- const freezeOffset = enableColumnFreeze ? freezeOffsets.get(header.column.id) : void 0;
3768
+ const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
3458
3769
  const freezeStyle = getColumnFreezeStyle(freezeOffset, {
3459
3770
  isHeader: true,
3460
3771
  headerTop: header.depth * DATA_TABLE_HEADER_ROW_HEIGHT
@@ -3463,7 +3774,7 @@ function DataTable({
3463
3774
  ...sizeStyle,
3464
3775
  ...freezeStyle
3465
3776
  };
3466
- return /* @__PURE__ */ jsxs5(
3777
+ return /* @__PURE__ */ jsxs6(
3467
3778
  "th",
3468
3779
  {
3469
3780
  colSpan: header.colSpan,
@@ -3480,8 +3791,11 @@ function DataTable({
3480
3791
  headerClassName
3481
3792
  ),
3482
3793
  children: [
3483
- header.isPlaceholder ? null : flexRender2(header.column.columnDef.header, header.getContext()),
3484
- canResize ? /* @__PURE__ */ jsx6(
3794
+ header.isPlaceholder ? null : flexRender2(
3795
+ header.column.columnDef.header,
3796
+ header.getContext()
3797
+ ),
3798
+ canResize ? /* @__PURE__ */ jsx7(
3485
3799
  "div",
3486
3800
  {
3487
3801
  role: "separator",
@@ -3507,20 +3821,20 @@ function DataTable({
3507
3821
  },
3508
3822
  headerGroup.id
3509
3823
  )) }),
3510
- /* @__PURE__ */ jsx6(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx6(
3824
+ /* @__PURE__ */ jsx7(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx7(
3511
3825
  "tbody",
3512
3826
  {
3513
3827
  onMouseLeave: clearHover,
3514
3828
  className: cn("data-table-body", classNames?.body),
3515
- children: rows.length === 0 ? /* @__PURE__ */ jsx6(
3829
+ children: rows.length === 0 ? /* @__PURE__ */ jsx7(
3516
3830
  EmptySlot,
3517
3831
  {
3518
3832
  emptyText,
3519
3833
  columnCount,
3520
3834
  classNames
3521
3835
  }
3522
- ) : shouldVirtualize ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
3523
- paddingTop > 0 && /* @__PURE__ */ jsx6(
3836
+ ) : shouldVirtualize ? /* @__PURE__ */ jsxs6(Fragment2, { children: [
3837
+ paddingTop > 0 && /* @__PURE__ */ jsx7(
3524
3838
  "tr",
3525
3839
  {
3526
3840
  "aria-hidden": true,
@@ -3528,7 +3842,7 @@ function DataTable({
3528
3842
  "data-table-virtual-spacer",
3529
3843
  classNames?.virtualSpacer
3530
3844
  ),
3531
- children: /* @__PURE__ */ jsx6(
3845
+ children: /* @__PURE__ */ jsx7(
3532
3846
  "td",
3533
3847
  {
3534
3848
  colSpan: columnCount,
@@ -3544,7 +3858,7 @@ function DataTable({
3544
3858
  virtualRows.map((virtualRow) => {
3545
3859
  const row = rows[virtualRow.index];
3546
3860
  if (!row) return null;
3547
- return /* @__PURE__ */ jsx6(
3861
+ return /* @__PURE__ */ jsx7(
3548
3862
  RowSlot,
3549
3863
  {
3550
3864
  row,
@@ -3555,7 +3869,7 @@ function DataTable({
3555
3869
  row.id
3556
3870
  );
3557
3871
  }),
3558
- paddingBottom > 0 && /* @__PURE__ */ jsx6(
3872
+ paddingBottom > 0 && /* @__PURE__ */ jsx7(
3559
3873
  "tr",
3560
3874
  {
3561
3875
  "aria-hidden": true,
@@ -3563,7 +3877,7 @@ function DataTable({
3563
3877
  "data-table-virtual-spacer",
3564
3878
  classNames?.virtualSpacer
3565
3879
  ),
3566
- children: /* @__PURE__ */ jsx6(
3880
+ children: /* @__PURE__ */ jsx7(
3567
3881
  "td",
3568
3882
  {
3569
3883
  colSpan: columnCount,
@@ -3576,7 +3890,7 @@ function DataTable({
3576
3890
  )
3577
3891
  }
3578
3892
  )
3579
- ] }) : rows.map((row) => /* @__PURE__ */ jsx6(
3893
+ ] }) : rows.map((row) => /* @__PURE__ */ jsx7(
3580
3894
  RowSlot,
3581
3895
  {
3582
3896
  row,
@@ -3595,10 +3909,44 @@ function DataTable({
3595
3909
  }
3596
3910
 
3597
3911
  // src/components/ui/table/components/Table/Table.tsx
3598
- import { useCallback as useCallback5, useMemo as useMemo5, useState as useState5 } from "react";
3912
+ import { useCallback as useCallback6, useMemo as useMemo5, useState as useState5 } from "react";
3913
+
3914
+ // src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
3915
+ import { useCallback as useCallback5 } from "react";
3916
+ function ResolvedTableCell({
3917
+ info
3918
+ }) {
3919
+ const { cellRender } = useDataTableRowContext();
3920
+ const { row, column, getValue } = info;
3921
+ const meta = column.columnDef.meta;
3922
+ const value = getValue();
3923
+ const columnId = column.id;
3924
+ const update = useCallback5(
3925
+ (next) => {
3926
+ cellRender.commitValue(row.id, columnId, next);
3927
+ },
3928
+ [cellRender, columnId, row.id]
3929
+ );
3930
+ const ctx = {
3931
+ value,
3932
+ row,
3933
+ index: row.index,
3934
+ columnId,
3935
+ cellProps: meta?.cellProps,
3936
+ update
3937
+ };
3938
+ if (meta?.cellRender) {
3939
+ return meta.cellRender(ctx);
3940
+ }
3941
+ const renderer = resolveCellRenderer(cellRender.registry, meta?.kind, ctx);
3942
+ if (renderer) {
3943
+ return renderer.render(ctx);
3944
+ }
3945
+ return formatDefaultCellValue(value);
3946
+ }
3599
3947
 
3600
3948
  // src/components/ui/table/components/Table/buildColumnDef.tsx
3601
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
3949
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3602
3950
  function SortableHeader({
3603
3951
  label,
3604
3952
  field,
@@ -3607,15 +3955,18 @@ function SortableHeader({
3607
3955
  }) {
3608
3956
  const isActive = sort?.field === field;
3609
3957
  const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
3610
- return /* @__PURE__ */ jsxs6(
3958
+ return /* @__PURE__ */ jsxs7(
3611
3959
  "button",
3612
3960
  {
3613
3961
  type: "button",
3614
- className: cn("SortableHeaderJSX", isActive ? "is-active" : "is-inactive"),
3962
+ className: cn(
3963
+ "SortableHeaderJSX",
3964
+ isActive ? "is-active" : "is-inactive"
3965
+ ),
3615
3966
  onClick: () => onSort(field),
3616
3967
  children: [
3617
- /* @__PURE__ */ jsx7("span", { children: label }),
3618
- /* @__PURE__ */ jsx7(Icon, { className: "sortable-header-icon" })
3968
+ /* @__PURE__ */ jsx8("span", { children: label }),
3969
+ /* @__PURE__ */ jsx8(Icon, { className: "sortable-header-icon" })
3619
3970
  ]
3620
3971
  }
3621
3972
  );
@@ -3637,6 +3988,8 @@ function buildColumnDef(props, sort, onSort) {
3637
3988
  editable,
3638
3989
  editType,
3639
3990
  editInputProps,
3991
+ kind,
3992
+ cellProps,
3640
3993
  className,
3641
3994
  headerClassName,
3642
3995
  render
@@ -3648,18 +4001,20 @@ function buildColumnDef(props, sort, onSort) {
3648
4001
  ...minWidth != null ? { minSize: minWidth } : {},
3649
4002
  ...maxWidth != null ? { maxSize: maxWidth } : {},
3650
4003
  ...resizable === false ? { enableResizing: false } : {},
3651
- header: sortable ? () => /* @__PURE__ */ jsx7(SortableHeader, { label: children, field, sort, onSort }) : (
4004
+ header: sortable ? () => /* @__PURE__ */ jsx8(
4005
+ SortableHeader,
4006
+ {
4007
+ label: children,
4008
+ field,
4009
+ sort,
4010
+ onSort
4011
+ }
4012
+ ) : (
3652
4013
  // eslint-disable-next-line @typescript-eslint/promise-function-async
3653
4014
  () => children
3654
4015
  ),
3655
- ...render ? {
3656
- // eslint-disable-next-line @typescript-eslint/promise-function-async
3657
- cell: ({ row, getValue }) => render(
3658
- getValue(),
3659
- row,
3660
- row.index
3661
- )
3662
- } : {},
4016
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
4017
+ cell: (info) => /* @__PURE__ */ jsx8(ResolvedTableCell, { info }),
3663
4018
  meta: {
3664
4019
  align,
3665
4020
  rowSpan,
@@ -3667,6 +4022,9 @@ function buildColumnDef(props, sort, onSort) {
3667
4022
  editable,
3668
4023
  editType,
3669
4024
  editInputProps,
4025
+ kind,
4026
+ cellProps,
4027
+ cellRender: render,
3670
4028
  frozen,
3671
4029
  className,
3672
4030
  headerClassName
@@ -3689,10 +4047,8 @@ function buildColumnDefsFromTree(nodes, sort, onSort) {
3689
4047
  const { header, align, headerClassName } = node.props;
3690
4048
  return {
3691
4049
  id: resolveGroupId(node.props, index),
3692
- header: (
3693
- // eslint-disable-next-line @typescript-eslint/promise-function-async
3694
- () => header
3695
- ),
4050
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
4051
+ header: () => header,
3696
4052
  columns: childDefs,
3697
4053
  enableResizing: false,
3698
4054
  meta: {
@@ -3859,7 +4215,7 @@ function TableHeader(props) {
3859
4215
  TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
3860
4216
 
3861
4217
  // src/components/ui/table/components/Table/TablePagination.tsx
3862
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
4218
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3863
4219
  function TablePagination({
3864
4220
  page,
3865
4221
  pageSize = 10,
@@ -3871,8 +4227,8 @@ function TablePagination({
3871
4227
  const safePage = Math.min(Math.max(1, page), totalPages);
3872
4228
  const canGoPrev = safePage > 1;
3873
4229
  const canGoNext = safePage < totalPages;
3874
- return /* @__PURE__ */ jsxs7("div", { className: cn("TablePaginationJSX", className), children: [
3875
- /* @__PURE__ */ jsx8(
4230
+ return /* @__PURE__ */ jsxs8("div", { className: cn("TablePaginationJSX", className), children: [
4231
+ /* @__PURE__ */ jsx9(
3876
4232
  "button",
3877
4233
  {
3878
4234
  type: "button",
@@ -3880,15 +4236,15 @@ function TablePagination({
3880
4236
  disabled: !canGoPrev,
3881
4237
  onClick: () => onChange(safePage - 1),
3882
4238
  "aria-label": "Previous page",
3883
- children: /* @__PURE__ */ jsx8(ChevronLeft, { className: "pagination-button-icon" })
4239
+ children: /* @__PURE__ */ jsx9(ChevronLeft, { className: "pagination-button-icon" })
3884
4240
  }
3885
4241
  ),
3886
- /* @__PURE__ */ jsxs7("span", { className: "pagination-label", children: [
4242
+ /* @__PURE__ */ jsxs8("span", { className: "pagination-label", children: [
3887
4243
  safePage,
3888
4244
  " / ",
3889
4245
  totalPages
3890
4246
  ] }),
3891
- /* @__PURE__ */ jsx8(
4247
+ /* @__PURE__ */ jsx9(
3892
4248
  "button",
3893
4249
  {
3894
4250
  type: "button",
@@ -3896,7 +4252,7 @@ function TablePagination({
3896
4252
  disabled: !canGoNext,
3897
4253
  onClick: () => onChange(safePage + 1),
3898
4254
  "aria-label": "Next page",
3899
- children: /* @__PURE__ */ jsx8(ChevronRight, { className: "pagination-button-icon" })
4255
+ children: /* @__PURE__ */ jsx9(ChevronRight, { className: "pagination-button-icon" })
3900
4256
  }
3901
4257
  )
3902
4258
  ] });
@@ -3904,7 +4260,7 @@ function TablePagination({
3904
4260
  TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
3905
4261
 
3906
4262
  // src/components/ui/table/components/Table/Table.tsx
3907
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
4263
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
3908
4264
  function TableRoot({
3909
4265
  data,
3910
4266
  children,
@@ -3918,7 +4274,7 @@ function TableRoot({
3918
4274
  [children]
3919
4275
  );
3920
4276
  const [sort, setSort] = useState5(null);
3921
- const handleSort = useCallback5((field) => {
4277
+ const handleSort = useCallback6((field) => {
3922
4278
  setSort((previous) => {
3923
4279
  if (previous?.field !== field) {
3924
4280
  return { field, direction: "asc" };
@@ -3946,8 +4302,8 @@ function TableRoot({
3946
4302
  if (countLeafColumns(columnTree) === 0) {
3947
4303
  console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
3948
4304
  }
3949
- return /* @__PURE__ */ jsxs8("div", { className: "TableJSX", children: [
3950
- /* @__PURE__ */ jsx9(
4305
+ return /* @__PURE__ */ jsxs9("div", { className: "TableJSX", children: [
4306
+ /* @__PURE__ */ jsx10(
3951
4307
  DataTable,
3952
4308
  {
3953
4309
  ...dataTableProps,
@@ -3958,7 +4314,7 @@ function TableRoot({
3958
4314
  className: cn(className, paginationProps && "DataTableJSX--with-pagination")
3959
4315
  }
3960
4316
  ),
3961
- paginationProps && /* @__PURE__ */ jsx9(
4317
+ paginationProps && /* @__PURE__ */ jsx10(
3962
4318
  TablePagination,
3963
4319
  {
3964
4320
  page,
@@ -3983,7 +4339,7 @@ function createTable() {
3983
4339
  ColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
3984
4340
  return Object.assign(
3985
4341
  function BoundTable(props) {
3986
- return /* @__PURE__ */ jsx9(TableRoot, { ...props });
4342
+ return /* @__PURE__ */ jsx10(TableRoot, { ...props });
3987
4343
  },
3988
4344
  {
3989
4345
  Header: TableHeader,