react-glide-table 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,7 +74,7 @@ export function Products({ data }: { data: Product[] }) {
74
74
  | `slots.Pending` / `slots.Empty` | Loading and empty states |
75
75
  | `className` / column `className` / `headerClassName` | Extra class hooks |
76
76
  | `labels` / `summary` / `toolbar` | Copy and slot nodes |
77
- | `Column.render` | Cell content custom render (single context object; prefer `update`) |
77
+ | `Column.render` / `ColumnDef.cell` | Cell content custom render (prefer `update` via context) |
78
78
  | `Column.kind` / `cellRenderers` | Built-in or custom cell kinds (override / add via registry) |
79
79
 
80
80
  Row/cell **state** is exposed as `data-*` attributes for Tailwind variants:
@@ -105,7 +105,25 @@ Row-level UI → `slots.Row`. Cell content → `Column.render` or `Column.kind`.
105
105
 
106
106
  `update` commits through `onCellChange` (preferred) or `onDataChange`. Prefer `update` over calling `setData` inside the render.
107
107
 
108
- Double-click inline editing (`editable` / `editType`) stays separate: use it for overlay text/number edits; use `render` + `update` for always-visible controls.
108
+ The same `update` is available on TanStack `ColumnDef.cell` when using `DataTable` directly (or `useGlideTable().getCellContext` with `flexRender`). Bare `cell.getContext()` does **not** include `update` at runtime — only the wrapped context does (`CellContextWithUpdate`).
109
+
110
+ ```tsx
111
+ const columns: ColumnDef<Product, unknown>[] = [
112
+ {
113
+ accessorKey: "status",
114
+ header: "Status",
115
+ cell: ({ getValue, update }) => (
116
+ <button type="button" onClick={() => update?.("done")}>
117
+ {String(getValue())}
118
+ </button>
119
+ ),
120
+ },
121
+ ];
122
+
123
+ <DataTable data={data} columns={columns} onCellChange={...} />
124
+ ```
125
+
126
+ Double-click inline editing (`editable` / `editType`) stays separate: use it for overlay text/number edits; use `render` / `cell` + `update` for always-visible controls.
109
127
 
110
128
  ### Cell kinds (`Column.kind` + `cellRenderers`)
111
129
 
@@ -148,15 +166,26 @@ type Product = { id: string; name: string; qty: number };
148
166
 
149
167
  const columns: ColumnDef<Product, unknown>[] = [
150
168
  { accessorKey: "name", header: "Name" },
151
- { accessorKey: "qty", header: "Qty" },
169
+ {
170
+ accessorKey: "qty",
171
+ header: "Qty",
172
+ cell: ({ getValue, update }) => (
173
+ <button type="button" onClick={() => update?.(Number(getValue()) + 1)}>
174
+ {String(getValue())}
175
+ </button>
176
+ ),
177
+ },
152
178
  ];
153
179
 
154
180
  export function ProductTable({ data }: { data: Product[] }) {
155
- const { table, rows, scrollRef } = useGlideTable({
181
+ const { table, rows, scrollRef, getCellContext } = useGlideTable({
156
182
  data,
157
183
  columns,
158
184
  getRowId: (row) => row.id,
159
185
  rowSelectionMode: "multi",
186
+ onCellChange: (rowId, columnId, value) => {
187
+ /* update your data */
188
+ },
160
189
  });
161
190
 
162
191
  return (
@@ -183,7 +212,7 @@ export function ProductTable({ data }: { data: Product[] }) {
183
212
  <tr key={row.id}>
184
213
  {row.getVisibleCells().map((cell) => (
185
214
  <td key={cell.id}>
186
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
215
+ {flexRender(cell.column.columnDef.cell, getCellContext(cell))}
187
216
  </td>
188
217
  ))}
189
218
  </tr>
@@ -195,7 +224,7 @@ export function ProductTable({ data }: { data: Product[] }) {
195
224
  }
196
225
  ```
197
226
 
198
- Wire `rowContextValue` into your own row/cell components for edit, selection, expand, and row-span behavior.
227
+ Wire `rowContextValue` into your own row/cell components for edit, selection, expand, and row-span behavior. Use `getCellContext(cell)` (not bare `cell.getContext()`) so `ColumnDef.cell` receives `update`.
199
228
 
200
229
  ## Clipboard copy & paste
201
230
 
package/dist/compound.cjs CHANGED
@@ -100,6 +100,16 @@ function getCellEditDraftValue(value) {
100
100
  return String(value);
101
101
  }
102
102
 
103
+ // src/components/ui/table/features/cell-render/withCellUpdate.ts
104
+ function withCellUpdate(context, commitValue) {
105
+ return {
106
+ ...context,
107
+ update: (next) => {
108
+ commitValue(context.row.id, context.column.id, next);
109
+ }
110
+ };
111
+ }
112
+
103
113
  // src/components/ui/table/features/cell-selection/cellSelection.ts
104
114
  var INITIAL_DRAG_STATE = {
105
115
  isSelecting: false,
@@ -1130,6 +1140,7 @@ function DataTableRow({
1130
1140
  selection,
1131
1141
  cellSelection,
1132
1142
  cellEdit,
1143
+ cellRender,
1133
1144
  expand,
1134
1145
  columnResize,
1135
1146
  columnFreeze,
@@ -1167,6 +1178,10 @@ function DataTableRow({
1167
1178
  onCommitEdit,
1168
1179
  onCancelEdit
1169
1180
  } = cellEdit;
1181
+ const renderCell = (tableCell) => (0, import_react_table.flexRender)(
1182
+ tableCell.column.columnDef.cell,
1183
+ withCellUpdate(tableCell.getContext(), cellRender.commitValue)
1184
+ );
1170
1185
  const {
1171
1186
  enableExpand,
1172
1187
  toggleField,
@@ -1479,7 +1494,7 @@ function DataTableRow({
1479
1494
  "expand-cell-value",
1480
1495
  classNames?.expandCellValue
1481
1496
  ),
1482
- children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext())
1497
+ children: renderCell(cell)
1483
1498
  }
1484
1499
  )
1485
1500
  ]
@@ -1518,7 +1533,7 @@ function DataTableRow({
1518
1533
  )
1519
1534
  }
1520
1535
  )
1521
- ] }) : (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()),
1536
+ ] }) : renderCell(cell),
1522
1537
  isBottomRightCell && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1523
1538
  "div",
1524
1539
  {
@@ -3256,6 +3271,10 @@ function useGlideTable(options) {
3256
3271
  }),
3257
3272
  [onCellChange, onDataChange, rows, tableData]
3258
3273
  );
3274
+ const getCellContext = (0, import_react7.useCallback)(
3275
+ (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
3276
+ [commitRenderedCellValue]
3277
+ );
3259
3278
  const handleCellMouseDownWithCommit = (0, import_react7.useCallback)(
3260
3279
  (rowIndex, colIndex, options2) => {
3261
3280
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -3588,6 +3607,7 @@ function useGlideTable(options) {
3588
3607
  paddingTop,
3589
3608
  paddingBottom,
3590
3609
  rowContextValue,
3610
+ getCellContext,
3591
3611
  handleToggleSelect,
3592
3612
  clearHover,
3593
3613
  copySelection: stableCopySelection,
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement } from 'react';
3
- import { l as DataTableProps, r as TableColumnProps, T as TableColumnGroupProps, s as TableProps } from './types-DJOlsDL8.cjs';
4
- export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, f as ColumnFreezeMeta, h as ColumnFreezeSide, i as DataTableClassNames, k as DataTableLabels, m as DataTableScrollSlotProps, n as DataTableSlots, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, p as SearchResultItem } from './types-DJOlsDL8.cjs';
3
+ import { l as DataTableProps, r as TableColumnProps, T as TableColumnGroupProps, s as TableProps } from './types-bgEceyRV.cjs';
4
+ export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, f as ColumnFreezeMeta, h as ColumnFreezeSide, i as DataTableClassNames, k as DataTableLabels, m as DataTableScrollSlotProps, n as DataTableSlots, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, p as SearchResultItem } from './types-bgEceyRV.cjs';
5
5
  export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement } from 'react';
3
- import { l as DataTableProps, r as TableColumnProps, T as TableColumnGroupProps, s as TableProps } from './types-DJOlsDL8.js';
4
- export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, f as ColumnFreezeMeta, h as ColumnFreezeSide, i as DataTableClassNames, k as DataTableLabels, m as DataTableScrollSlotProps, n as DataTableSlots, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, p as SearchResultItem } from './types-DJOlsDL8.js';
3
+ import { l as DataTableProps, r as TableColumnProps, T as TableColumnGroupProps, s as TableProps } from './types-bgEceyRV.js';
4
+ export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, f as ColumnFreezeMeta, h as ColumnFreezeSide, i as DataTableClassNames, k as DataTableLabels, m as DataTableScrollSlotProps, n as DataTableSlots, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, p as SearchResultItem } from './types-bgEceyRV.js';
5
5
  export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
6
6
 
7
7
  /**
package/dist/compound.js CHANGED
@@ -72,6 +72,16 @@ function getCellEditDraftValue(value) {
72
72
  return String(value);
73
73
  }
74
74
 
75
+ // src/components/ui/table/features/cell-render/withCellUpdate.ts
76
+ function withCellUpdate(context, commitValue) {
77
+ return {
78
+ ...context,
79
+ update: (next) => {
80
+ commitValue(context.row.id, context.column.id, next);
81
+ }
82
+ };
83
+ }
84
+
75
85
  // src/components/ui/table/features/cell-selection/cellSelection.ts
76
86
  var INITIAL_DRAG_STATE = {
77
87
  isSelecting: false,
@@ -1102,6 +1112,7 @@ function DataTableRow({
1102
1112
  selection,
1103
1113
  cellSelection,
1104
1114
  cellEdit,
1115
+ cellRender,
1105
1116
  expand,
1106
1117
  columnResize,
1107
1118
  columnFreeze,
@@ -1139,6 +1150,10 @@ function DataTableRow({
1139
1150
  onCommitEdit,
1140
1151
  onCancelEdit
1141
1152
  } = cellEdit;
1153
+ const renderCell = (tableCell) => flexRender(
1154
+ tableCell.column.columnDef.cell,
1155
+ withCellUpdate(tableCell.getContext(), cellRender.commitValue)
1156
+ );
1142
1157
  const {
1143
1158
  enableExpand,
1144
1159
  toggleField,
@@ -1451,7 +1466,7 @@ function DataTableRow({
1451
1466
  "expand-cell-value",
1452
1467
  classNames?.expandCellValue
1453
1468
  ),
1454
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
1469
+ children: renderCell(cell)
1455
1470
  }
1456
1471
  )
1457
1472
  ]
@@ -1490,7 +1505,7 @@ function DataTableRow({
1490
1505
  )
1491
1506
  }
1492
1507
  )
1493
- ] }) : flexRender(cell.column.columnDef.cell, cell.getContext()),
1508
+ ] }) : renderCell(cell),
1494
1509
  isBottomRightCell && /* @__PURE__ */ jsx3(
1495
1510
  "div",
1496
1511
  {
@@ -3246,6 +3261,10 @@ function useGlideTable(options) {
3246
3261
  }),
3247
3262
  [onCellChange, onDataChange, rows, tableData]
3248
3263
  );
3264
+ const getCellContext = useCallback4(
3265
+ (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
3266
+ [commitRenderedCellValue]
3267
+ );
3249
3268
  const handleCellMouseDownWithCommit = useCallback4(
3250
3269
  (rowIndex, colIndex, options2) => {
3251
3270
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -3578,6 +3597,7 @@ function useGlideTable(options) {
3578
3597
  paddingTop,
3579
3598
  paddingBottom,
3580
3599
  rowContextValue,
3600
+ getCellContext,
3581
3601
  handleToggleSelect,
3582
3602
  clearHover,
3583
3603
  copySelection: stableCopySelection,
package/dist/core.cjs CHANGED
@@ -91,6 +91,7 @@ __export(core_exports, {
91
91
  useConvertTreeData: () => useConvertTreeData,
92
92
  useGlideTable: () => useGlideTable,
93
93
  useInlineSearch: () => useInlineSearch,
94
+ withCellUpdate: () => withCellUpdate,
94
95
  writeSelectionToClipboard: () => writeSelectionToClipboard
95
96
  });
96
97
  module.exports = __toCommonJS(core_exports);
@@ -506,6 +507,16 @@ function formatDefaultCellValue(value) {
506
507
  return String(value);
507
508
  }
508
509
 
510
+ // src/components/ui/table/features/cell-render/withCellUpdate.ts
511
+ function withCellUpdate(context, commitValue) {
512
+ return {
513
+ ...context,
514
+ update: (next) => {
515
+ commitValue(context.row.id, context.column.id, next);
516
+ }
517
+ };
518
+ }
519
+
509
520
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
510
521
  var import_react2 = require("react");
511
522
 
@@ -2485,6 +2496,10 @@ function useGlideTable(options) {
2485
2496
  }),
2486
2497
  [onCellChange, onDataChange, rows, tableData]
2487
2498
  );
2499
+ const getCellContext = (0, import_react5.useCallback)(
2500
+ (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
2501
+ [commitRenderedCellValue]
2502
+ );
2488
2503
  const handleCellMouseDownWithCommit = (0, import_react5.useCallback)(
2489
2504
  (rowIndex, colIndex, options2) => {
2490
2505
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -2817,6 +2832,7 @@ function useGlideTable(options) {
2817
2832
  paddingTop,
2818
2833
  paddingBottom,
2819
2834
  rowContextValue,
2835
+ getCellContext,
2820
2836
  handleToggleSelect,
2821
2837
  clearHover,
2822
2838
  copySelection: stableCopySelection,
@@ -2970,5 +2986,6 @@ function getColumnSizeStyle(size, options) {
2970
2986
  useConvertTreeData,
2971
2987
  useGlideTable,
2972
2988
  useInlineSearch,
2989
+ withCellUpdate,
2973
2990
  writeSelectionToClipboard
2974
2991
  });
package/dist/core.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { W as CellEditType, c as CellRenderer, C as CellKind, a as CellRenderContext, i as DataTableClassNames, R as RowSelectionMode, g as ColumnFreezeOffset, p as SearchResultItem, q as SearchStatus, l as DataTableProps, k as DataTableLabels, j as DataTableCopyActions, P as PasteMode, o as RowsPastePayload } from './types-DJOlsDL8.cjs';
2
- export { B as BuiltinCellKind, b as CellRenderFn, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, I as INLINE_SEARCH_MAX_RESULTS, S as SearchCorpusRow, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-DJOlsDL8.cjs';
3
- import { Row, ColumnDef, Table, CellContext, Updater, RowSelectionState } from '@tanstack/react-table';
1
+ import { W as CellEditType, c as CellRenderer, C as CellKind, a as CellRenderContext, i as DataTableClassNames, R as RowSelectionMode, g as ColumnFreezeOffset, p as SearchResultItem, q as SearchStatus, l as DataTableProps, k as DataTableLabels, j as DataTableCopyActions, P as PasteMode, o as RowsPastePayload } from './types-bgEceyRV.cjs';
2
+ export { B as BuiltinCellKind, b as CellRenderFn, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, I as INLINE_SEARCH_MAX_RESULTS, S as SearchCorpusRow, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-bgEceyRV.cjs';
3
+ import { Row, ColumnDef, CellContext, Table, Cell, Updater, RowSelectionState } from '@tanstack/react-table';
4
4
  export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
5
5
  import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
6
6
  import * as react from 'react';
@@ -197,6 +197,19 @@ type DataTableRowContextValue = {
197
197
  };
198
198
  };
199
199
 
200
+ /**
201
+ * TanStack `CellContext` with a guaranteed `update` commit helper.
202
+ * Prefer this over bare `cell.getContext()`, which does not include `update` at runtime.
203
+ */
204
+ type CellContextWithUpdate<TData, TValue> = CellContext<TData, TValue> & {
205
+ update: (next: TValue) => void;
206
+ };
207
+ /**
208
+ * Injects `update` into a TanStack `CellContext` so `ColumnDef.cell` can commit
209
+ * through `onCellChange` / `onDataChange` the same way compound `Column.render` does.
210
+ */
211
+ declare function withCellUpdate<TData extends Record<string, unknown>, TValue>(context: CellContext<TData, TValue>, commitValue: (rowId: string, columnId: string, value: unknown) => boolean): CellContextWithUpdate<TData, TValue>;
212
+
200
213
  type UseInlineSearchOptions = {
201
214
  enabled?: boolean;
202
215
  rowCount: number;
@@ -258,6 +271,11 @@ type UseGlideTableResult<T extends Record<string, unknown>> = {
258
271
  paddingTop: number;
259
272
  paddingBottom: number;
260
273
  rowContextValue: DataTableRowContextValue;
274
+ /**
275
+ * TanStack `CellContext` with `update` injected for custom `ColumnDef.cell` renders.
276
+ * Prefer this over `cell.getContext()` when calling `flexRender` yourself.
277
+ */
278
+ getCellContext: <TValue>(cell: Cell<T, TValue>) => CellContextWithUpdate<T, TValue>;
261
279
  handleToggleSelect: (row: Row<T>) => void;
262
280
  clearHover: () => void;
263
281
  copySelection: DataTableCopyActions["copySelection"];
@@ -445,4 +463,4 @@ declare const useConvertTreeData: <T extends Record<string, unknown>>({ data, en
445
463
  declare function resolveRowSelection(mode: RowSelectionMode, controlledSelection: RowSelectionState | undefined, internalSelection: RowSelectionState): RowSelectionState;
446
464
  declare function applySelectionUpdater(mode: RowSelectionMode, updater: Updater<RowSelectionState>, previous: RowSelectionState): RowSelectionState;
447
465
 
448
- export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, CellKind, CellRenderContext, CellRenderer, type CellRendererRegistry, type CellSelectionBounds, ColumnFreezeOffset, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, ResolvedTableCell, RowSelectionMode, type RowSpanInfo, RowsPastePayload, SearchResultItem, SearchStatus, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, type UseInlineSearchOptions, type UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, writeSelectionToClipboard };
466
+ export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, type CellContextWithUpdate, CellKind, CellRenderContext, CellRenderer, type CellRendererRegistry, type CellSelectionBounds, ColumnFreezeOffset, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, ResolvedTableCell, RowSelectionMode, type RowSpanInfo, RowsPastePayload, SearchResultItem, SearchStatus, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, type UseInlineSearchOptions, type UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, withCellUpdate, writeSelectionToClipboard };
package/dist/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { W as CellEditType, c as CellRenderer, C as CellKind, a as CellRenderContext, i as DataTableClassNames, R as RowSelectionMode, g as ColumnFreezeOffset, p as SearchResultItem, q as SearchStatus, l as DataTableProps, k as DataTableLabels, j as DataTableCopyActions, P as PasteMode, o as RowsPastePayload } from './types-DJOlsDL8.js';
2
- export { B as BuiltinCellKind, b as CellRenderFn, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, I as INLINE_SEARCH_MAX_RESULTS, S as SearchCorpusRow, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-DJOlsDL8.js';
3
- import { Row, ColumnDef, Table, CellContext, Updater, RowSelectionState } from '@tanstack/react-table';
1
+ import { W as CellEditType, c as CellRenderer, C as CellKind, a as CellRenderContext, i as DataTableClassNames, R as RowSelectionMode, g as ColumnFreezeOffset, p as SearchResultItem, q as SearchStatus, l as DataTableProps, k as DataTableLabels, j as DataTableCopyActions, P as PasteMode, o as RowsPastePayload } from './types-bgEceyRV.js';
2
+ export { B as BuiltinCellKind, b as CellRenderFn, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, I as INLINE_SEARCH_MAX_RESULTS, S as SearchCorpusRow, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-bgEceyRV.js';
3
+ import { Row, ColumnDef, CellContext, Table, Cell, Updater, RowSelectionState } from '@tanstack/react-table';
4
4
  export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
5
5
  import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
6
6
  import * as react from 'react';
@@ -197,6 +197,19 @@ type DataTableRowContextValue = {
197
197
  };
198
198
  };
199
199
 
200
+ /**
201
+ * TanStack `CellContext` with a guaranteed `update` commit helper.
202
+ * Prefer this over bare `cell.getContext()`, which does not include `update` at runtime.
203
+ */
204
+ type CellContextWithUpdate<TData, TValue> = CellContext<TData, TValue> & {
205
+ update: (next: TValue) => void;
206
+ };
207
+ /**
208
+ * Injects `update` into a TanStack `CellContext` so `ColumnDef.cell` can commit
209
+ * through `onCellChange` / `onDataChange` the same way compound `Column.render` does.
210
+ */
211
+ declare function withCellUpdate<TData extends Record<string, unknown>, TValue>(context: CellContext<TData, TValue>, commitValue: (rowId: string, columnId: string, value: unknown) => boolean): CellContextWithUpdate<TData, TValue>;
212
+
200
213
  type UseInlineSearchOptions = {
201
214
  enabled?: boolean;
202
215
  rowCount: number;
@@ -258,6 +271,11 @@ type UseGlideTableResult<T extends Record<string, unknown>> = {
258
271
  paddingTop: number;
259
272
  paddingBottom: number;
260
273
  rowContextValue: DataTableRowContextValue;
274
+ /**
275
+ * TanStack `CellContext` with `update` injected for custom `ColumnDef.cell` renders.
276
+ * Prefer this over `cell.getContext()` when calling `flexRender` yourself.
277
+ */
278
+ getCellContext: <TValue>(cell: Cell<T, TValue>) => CellContextWithUpdate<T, TValue>;
261
279
  handleToggleSelect: (row: Row<T>) => void;
262
280
  clearHover: () => void;
263
281
  copySelection: DataTableCopyActions["copySelection"];
@@ -445,4 +463,4 @@ declare const useConvertTreeData: <T extends Record<string, unknown>>({ data, en
445
463
  declare function resolveRowSelection(mode: RowSelectionMode, controlledSelection: RowSelectionState | undefined, internalSelection: RowSelectionState): RowSelectionState;
446
464
  declare function applySelectionUpdater(mode: RowSelectionMode, updater: Updater<RowSelectionState>, previous: RowSelectionState): RowSelectionState;
447
465
 
448
- export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, CellKind, CellRenderContext, CellRenderer, type CellRendererRegistry, type CellSelectionBounds, ColumnFreezeOffset, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, ResolvedTableCell, RowSelectionMode, type RowSpanInfo, RowsPastePayload, SearchResultItem, SearchStatus, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, type UseInlineSearchOptions, type UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, writeSelectionToClipboard };
466
+ export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, type CellContextWithUpdate, CellKind, CellRenderContext, CellRenderer, type CellRendererRegistry, type CellSelectionBounds, ColumnFreezeOffset, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, ResolvedTableCell, RowSelectionMode, type RowSpanInfo, RowsPastePayload, SearchResultItem, SearchStatus, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, type UseInlineSearchOptions, type UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, withCellUpdate, writeSelectionToClipboard };
package/dist/core.js CHANGED
@@ -420,6 +420,16 @@ function formatDefaultCellValue(value) {
420
420
  return String(value);
421
421
  }
422
422
 
423
+ // src/components/ui/table/features/cell-render/withCellUpdate.ts
424
+ function withCellUpdate(context, commitValue) {
425
+ return {
426
+ ...context,
427
+ update: (next) => {
428
+ commitValue(context.row.id, context.column.id, next);
429
+ }
430
+ };
431
+ }
432
+
423
433
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
424
434
  import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
425
435
 
@@ -2406,6 +2416,10 @@ function useGlideTable(options) {
2406
2416
  }),
2407
2417
  [onCellChange, onDataChange, rows, tableData]
2408
2418
  );
2419
+ const getCellContext = useCallback4(
2420
+ (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
2421
+ [commitRenderedCellValue]
2422
+ );
2409
2423
  const handleCellMouseDownWithCommit = useCallback4(
2410
2424
  (rowIndex, colIndex, options2) => {
2411
2425
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -2738,6 +2752,7 @@ function useGlideTable(options) {
2738
2752
  paddingTop,
2739
2753
  paddingBottom,
2740
2754
  rowContextValue,
2755
+ getCellContext,
2741
2756
  handleToggleSelect,
2742
2757
  clearHover,
2743
2758
  copySelection: stableCopySelection,
@@ -2890,5 +2905,6 @@ export {
2890
2905
  useConvertTreeData,
2891
2906
  useGlideTable,
2892
2907
  useInlineSearch,
2908
+ withCellUpdate,
2893
2909
  writeSelectionToClipboard
2894
2910
  };
package/dist/index.cjs CHANGED
@@ -94,6 +94,7 @@ __export(src_exports, {
94
94
  useConvertTreeData: () => useConvertTreeData,
95
95
  useGlideTable: () => useGlideTable,
96
96
  useInlineSearch: () => useInlineSearch,
97
+ withCellUpdate: () => withCellUpdate,
97
98
  writeSelectionToClipboard: () => writeSelectionToClipboard
98
99
  });
99
100
  module.exports = __toCommonJS(src_exports);
@@ -518,6 +519,16 @@ function formatDefaultCellValue(value) {
518
519
  return String(value);
519
520
  }
520
521
 
522
+ // src/components/ui/table/features/cell-render/withCellUpdate.ts
523
+ function withCellUpdate(context, commitValue) {
524
+ return {
525
+ ...context,
526
+ update: (next) => {
527
+ commitValue(context.row.id, context.column.id, next);
528
+ }
529
+ };
530
+ }
531
+
521
532
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
522
533
  var import_react2 = require("react");
523
534
 
@@ -2497,6 +2508,10 @@ function useGlideTable(options) {
2497
2508
  }),
2498
2509
  [onCellChange, onDataChange, rows, tableData]
2499
2510
  );
2511
+ const getCellContext = (0, import_react5.useCallback)(
2512
+ (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
2513
+ [commitRenderedCellValue]
2514
+ );
2500
2515
  const handleCellMouseDownWithCommit = (0, import_react5.useCallback)(
2501
2516
  (rowIndex, colIndex, options2) => {
2502
2517
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -2829,6 +2844,7 @@ function useGlideTable(options) {
2829
2844
  paddingTop,
2830
2845
  paddingBottom,
2831
2846
  rowContextValue,
2847
+ getCellContext,
2832
2848
  handleToggleSelect,
2833
2849
  clearHover,
2834
2850
  copySelection: stableCopySelection,
@@ -3110,6 +3126,7 @@ function DataTableRow({
3110
3126
  selection,
3111
3127
  cellSelection,
3112
3128
  cellEdit,
3129
+ cellRender,
3113
3130
  expand,
3114
3131
  columnResize,
3115
3132
  columnFreeze,
@@ -3147,6 +3164,10 @@ function DataTableRow({
3147
3164
  onCommitEdit,
3148
3165
  onCancelEdit
3149
3166
  } = cellEdit;
3167
+ const renderCell = (tableCell) => (0, import_react_table2.flexRender)(
3168
+ tableCell.column.columnDef.cell,
3169
+ withCellUpdate(tableCell.getContext(), cellRender.commitValue)
3170
+ );
3150
3171
  const {
3151
3172
  enableExpand,
3152
3173
  toggleField,
@@ -3459,7 +3480,7 @@ function DataTableRow({
3459
3480
  "expand-cell-value",
3460
3481
  classNames?.expandCellValue
3461
3482
  ),
3462
- children: (0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext())
3483
+ children: renderCell(cell)
3463
3484
  }
3464
3485
  )
3465
3486
  ]
@@ -3498,7 +3519,7 @@ function DataTableRow({
3498
3519
  )
3499
3520
  }
3500
3521
  )
3501
- ] }) : (0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext()),
3522
+ ] }) : renderCell(cell),
3502
3523
  isBottomRightCell && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3503
3524
  "div",
3504
3525
  {
@@ -4551,5 +4572,6 @@ var Table = Object.assign(TableRoot, {
4551
4572
  useConvertTreeData,
4552
4573
  useGlideTable,
4553
4574
  useInlineSearch,
4575
+ withCellUpdate,
4554
4576
  writeSelectionToClipboard
4555
4577
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, g as ColumnFreezeOffset, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, i as DataTableClassNames, j as DataTableCopyActions, k as DataTableLabels, l as DataTableProps, m as DataTableScrollSlotProps, n as DataTableSlots, I as INLINE_SEARCH_MAX_RESULTS, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, S as SearchCorpusRow, p as SearchResultItem, q as SearchStatus, T as TableColumnGroupProps, r as TableColumnProps, s as TableProps, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-DJOlsDL8.cjs';
2
- export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, CellRendererRegistry, CellSelectionBounds, ColumnRowSpanMap, CopyRowEntry, CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DragState, EditingCell, ResolvedTableCell, RowSpanInfo, TreeRow, UseConvertTreeDataParams, UseGlideTableOptions, UseGlideTableResult, UseInlineSearchOptions, UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, writeSelectionToClipboard } from './core.cjs';
1
+ export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, g as ColumnFreezeOffset, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, i as DataTableClassNames, j as DataTableCopyActions, k as DataTableLabels, l as DataTableProps, m as DataTableScrollSlotProps, n as DataTableSlots, I as INLINE_SEARCH_MAX_RESULTS, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, S as SearchCorpusRow, p as SearchResultItem, q as SearchStatus, T as TableColumnGroupProps, r as TableColumnProps, s as TableProps, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-bgEceyRV.cjs';
2
+ export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, CellContextWithUpdate, CellRendererRegistry, CellSelectionBounds, ColumnRowSpanMap, CopyRowEntry, CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DragState, EditingCell, ResolvedTableCell, RowSpanInfo, TreeRow, UseConvertTreeDataParams, UseGlideTableOptions, UseGlideTableResult, UseInlineSearchOptions, UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, withCellUpdate, writeSelectionToClipboard } from './core.cjs';
3
3
  export { DataTable, Table, TableCompoundComponent, createTable } from './compound.cjs';
4
4
  export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
5
5
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, g as ColumnFreezeOffset, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, i as DataTableClassNames, j as DataTableCopyActions, k as DataTableLabels, l as DataTableProps, m as DataTableScrollSlotProps, n as DataTableSlots, I as INLINE_SEARCH_MAX_RESULTS, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, S as SearchCorpusRow, p as SearchResultItem, q as SearchStatus, T as TableColumnGroupProps, r as TableColumnProps, s as TableProps, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-DJOlsDL8.js';
2
- export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, CellRendererRegistry, CellSelectionBounds, ColumnRowSpanMap, CopyRowEntry, CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DragState, EditingCell, ResolvedTableCell, RowSpanInfo, TreeRow, UseConvertTreeDataParams, UseGlideTableOptions, UseGlideTableResult, UseInlineSearchOptions, UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, writeSelectionToClipboard } from './core.js';
1
+ export { B as BuiltinCellKind, C as CellKind, a as CellRenderContext, b as CellRenderFn, c as CellRenderer, d as ColumnFreezeColumnInput, e as ColumnFreezeEdgeSide, f as ColumnFreezeMeta, g as ColumnFreezeOffset, h as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, i as DataTableClassNames, j as DataTableCopyActions, k as DataTableLabels, l as DataTableProps, m as DataTableScrollSlotProps, n as DataTableSlots, I as INLINE_SEARCH_MAX_RESULTS, P as PasteMode, R as RowSelectionMode, o as RowsPastePayload, S as SearchCorpusRow, p as SearchResultItem, q as SearchStatus, T as TableColumnGroupProps, r as TableColumnProps, s as TableProps, t as buildColumnFreezeOffsets, u as buildFlatSearchCorpus, v as buildSearchMatchKey, w as buildSearchMatchKeys, x as buildTreeSearchCorpus, y as cellValueToSearchText, z as collectAncestorKeysToExpand, A as collectSearchMatchesInRange, E as createSearchRegex, F as escapeSearchRegex, G as formatSearchResultLabel, H as getColumnFreezeEdgeAttr, J as getColumnFreezeStyle, K as mapSearchResultToVisibleItem, L as mapSearchResultsToVisibleKeys, M as nextSearchIndex, N as nextSearchStride, O as previousSearchIndex, Q as resolveColumnFreezeSide, U as resolveDataTableLabels, V as resolveHeaderFreezeOffset } from './types-bgEceyRV.js';
2
+ export { BUILTIN_CELL_RENDERERS, CELL_SELECTION_EDGES_CLASS, CellContextWithUpdate, CellRendererRegistry, CellSelectionBounds, ColumnRowSpanMap, CopyRowEntry, CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DragState, EditingCell, ResolvedTableCell, RowSpanInfo, TreeRow, UseConvertTreeDataParams, UseGlideTableOptions, UseGlideTableResult, UseInlineSearchOptions, UseInlineSearchResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, commitCellValue, createCellRendererRegistry, flattenSubtreeRows, formatCellValue, formatDefaultCellValue, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolveCellRenderer, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, useInlineSearch, withCellUpdate, writeSelectionToClipboard } from './core.js';
3
3
  export { DataTable, Table, TableCompoundComponent, createTable } from './compound.js';
4
4
  export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
5
5
  import 'react';
package/dist/index.js CHANGED
@@ -429,6 +429,16 @@ function formatDefaultCellValue(value) {
429
429
  return String(value);
430
430
  }
431
431
 
432
+ // src/components/ui/table/features/cell-render/withCellUpdate.ts
433
+ function withCellUpdate(context, commitValue) {
434
+ return {
435
+ ...context,
436
+ update: (next) => {
437
+ commitValue(context.row.id, context.column.id, next);
438
+ }
439
+ };
440
+ }
441
+
432
442
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
433
443
  import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
434
444
 
@@ -2415,6 +2425,10 @@ function useGlideTable(options) {
2415
2425
  }),
2416
2426
  [onCellChange, onDataChange, rows, tableData]
2417
2427
  );
2428
+ const getCellContext = useCallback4(
2429
+ (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
2430
+ [commitRenderedCellValue]
2431
+ );
2418
2432
  const handleCellMouseDownWithCommit = useCallback4(
2419
2433
  (rowIndex, colIndex, options2) => {
2420
2434
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
@@ -2747,6 +2761,7 @@ function useGlideTable(options) {
2747
2761
  paddingTop,
2748
2762
  paddingBottom,
2749
2763
  rowContextValue,
2764
+ getCellContext,
2750
2765
  handleToggleSelect,
2751
2766
  clearHover,
2752
2767
  copySelection: stableCopySelection,
@@ -3028,6 +3043,7 @@ function DataTableRow({
3028
3043
  selection,
3029
3044
  cellSelection,
3030
3045
  cellEdit,
3046
+ cellRender,
3031
3047
  expand,
3032
3048
  columnResize,
3033
3049
  columnFreeze,
@@ -3065,6 +3081,10 @@ function DataTableRow({
3065
3081
  onCommitEdit,
3066
3082
  onCancelEdit
3067
3083
  } = cellEdit;
3084
+ const renderCell = (tableCell) => flexRender(
3085
+ tableCell.column.columnDef.cell,
3086
+ withCellUpdate(tableCell.getContext(), cellRender.commitValue)
3087
+ );
3068
3088
  const {
3069
3089
  enableExpand,
3070
3090
  toggleField,
@@ -3377,7 +3397,7 @@ function DataTableRow({
3377
3397
  "expand-cell-value",
3378
3398
  classNames?.expandCellValue
3379
3399
  ),
3380
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
3400
+ children: renderCell(cell)
3381
3401
  }
3382
3402
  )
3383
3403
  ]
@@ -3416,7 +3436,7 @@ function DataTableRow({
3416
3436
  )
3417
3437
  }
3418
3438
  )
3419
- ] }) : flexRender(cell.column.columnDef.cell, cell.getContext()),
3439
+ ] }) : renderCell(cell),
3420
3440
  isBottomRightCell && /* @__PURE__ */ jsx4(
3421
3441
  "div",
3422
3442
  {
@@ -4468,5 +4488,6 @@ export {
4468
4488
  useConvertTreeData,
4469
4489
  useGlideTable,
4470
4490
  useInlineSearch,
4491
+ withCellUpdate,
4471
4492
  writeSelectionToClipboard
4472
4493
  };
@@ -207,6 +207,15 @@ declare module "@tanstack/react-table" {
207
207
  */
208
208
  frozen?: ColumnFreezeMeta;
209
209
  }
210
+ interface CellContext<TData, TValue> {
211
+ /**
212
+ * Commit a cell value through `onCellChange` / `onDataChange`.
213
+ * Present at runtime only when the context was wrapped by `DataTable`,
214
+ * `withCellUpdate`, or `useGlideTable().getCellContext` — not on bare
215
+ * `cell.getContext()`. Prefer those helpers for a guaranteed `update`.
216
+ */
217
+ update?: (next: TValue) => void;
218
+ }
210
219
  interface Row<TData> {
211
220
  /**
212
221
  * Returns whether this row's cell is inside the active drag selection.
@@ -207,6 +207,15 @@ declare module "@tanstack/react-table" {
207
207
  */
208
208
  frozen?: ColumnFreezeMeta;
209
209
  }
210
+ interface CellContext<TData, TValue> {
211
+ /**
212
+ * Commit a cell value through `onCellChange` / `onDataChange`.
213
+ * Present at runtime only when the context was wrapped by `DataTable`,
214
+ * `withCellUpdate`, or `useGlideTable().getCellContext` — not on bare
215
+ * `cell.getContext()`. Prefer those helpers for a guaranteed `update`.
216
+ */
217
+ update?: (next: TValue) => void;
218
+ }
210
219
  interface Row<TData> {
211
220
  /**
212
221
  * Returns whether this row's cell is inside the active drag selection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"