@lensui/lens-table 0.1.5 → 0.1.7

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/index.css CHANGED
@@ -15,6 +15,7 @@
15
15
  --rvg-color-primary-soft: #edf4ff;
16
16
  --rvg-color-selection-fill: #edf4ff;
17
17
  --rvg-color-axis-selection-fill: #e8f2ff;
18
+ --rvg-color-column-drop-target-fill: #eeeeee;
18
19
  --rvg-color-range-fill: #e8f1ff;
19
20
  --rvg-color-row-hover-fill: #f6f9fc;
20
21
  --rvg-color-hover: #f1f4f8;
@@ -218,9 +219,7 @@
218
219
  .rvg-cell-text {
219
220
  transition: transform 140ms ease, opacity 100ms ease;
220
221
  }
221
- .rvg-row-drop-settling .rvg-cell-text,
222
- .rvg-row-drop-settling .rvg-row-drag-icon,
223
- .rvg-row-drop-settling .rvg-row-selection-icon {
222
+ .rvg-row-drop-settling .rvg-cell-text {
224
223
  transition: none;
225
224
  }
226
225
  .rvg-cell-text > span,
@@ -240,20 +239,6 @@
240
239
  white-space: normal;
241
240
  text-overflow: clip;
242
241
  }
243
- .rvg-row-drag-icon {
244
- position: absolute;
245
- display: grid;
246
- place-items: center;
247
- pointer-events: none;
248
- transition: transform 140ms ease, opacity 100ms ease;
249
- }
250
- .rvg-row-drag-icon svg {
251
- display: block;
252
- width: 16px;
253
- height: 16px;
254
- overflow: visible;
255
- fill: var(--rvg-color-icon);
256
- }
257
242
  .rvg-cell-render {
258
243
  position: absolute;
259
244
  z-index: 1;
@@ -436,16 +421,12 @@
436
421
  background: #fce8e6;
437
422
  color: #d93025;
438
423
  }
439
- .rvg-row-selection-icon,
440
424
  .rvg-header-selection-icon {
441
425
  position: absolute;
442
426
  display: grid;
443
427
  place-items: center;
444
428
  pointer-events: none;
445
429
  }
446
- .rvg-row-selection-icon {
447
- transition: transform 140ms ease, opacity 100ms ease;
448
- }
449
430
  .rvg-selection-svg {
450
431
  display: block;
451
432
  width: 16px;
@@ -482,6 +463,7 @@
482
463
  border: 2px solid var(--rvg-color-primary);
483
464
  box-sizing: border-box;
484
465
  pointer-events: none;
466
+ transition: transform 140ms ease;
485
467
  }
486
468
  .rvg-selection-edge-target {
487
469
  position: absolute;
@@ -767,6 +749,9 @@
767
749
  .rvg-header-group.is-leaf {
768
750
  z-index: 2;
769
751
  }
752
+ .rvg-header-title.is-drop-target {
753
+ background: var(--rvg-color-column-drop-target-fill);
754
+ }
770
755
  .rvg-text-fixed-shadow {
771
756
  position: absolute;
772
757
  z-index: 4;
@@ -1479,6 +1464,38 @@
1479
1464
  color: var(--rvg-color-muted);
1480
1465
  font-weight: 600;
1481
1466
  }
1467
+ .rvg-column-drag-preview-header .rvg-preview-header-icon {
1468
+ position: absolute;
1469
+ top: 50%;
1470
+ width: 14px;
1471
+ height: 14px;
1472
+ transform: translateY(-50%);
1473
+ overflow: visible;
1474
+ color: var(--rvg-color-icon);
1475
+ }
1476
+ .rvg-column-drag-preview-header .rvg-preview-header-icon path,
1477
+ .rvg-column-drag-preview-header .rvg-preview-header-icon circle {
1478
+ fill: currentColor;
1479
+ }
1480
+ .rvg-column-drag-preview-header .rvg-preview-header-icon path.is-active,
1481
+ .rvg-column-drag-preview-header .rvg-preview-header-icon.is-active {
1482
+ color: var(--rvg-color-primary);
1483
+ }
1484
+ .rvg-column-drag-preview-header .rvg-preview-header-search-icon {
1485
+ fill: none;
1486
+ stroke: currentColor;
1487
+ stroke-width: 1.5;
1488
+ stroke-linecap: round;
1489
+ stroke-linejoin: round;
1490
+ }
1491
+ .rvg-column-drag-preview-header .rvg-preview-header-search-icon path,
1492
+ .rvg-column-drag-preview-header .rvg-preview-header-search-icon circle {
1493
+ fill: none;
1494
+ }
1495
+ .rvg-is-dragging,
1496
+ .rvg-is-dragging * {
1497
+ cursor: move !important;
1498
+ }
1482
1499
  .rvg-column-drag-preview-cell.is-axis-selected {
1483
1500
  background: var(--rvg-color-axis-selection-fill);
1484
1501
  }
@@ -1488,12 +1505,18 @@
1488
1505
  .rvg-column-drag-preview-cell.is-selected {
1489
1506
  background: var(--rvg-color-selection-fill);
1490
1507
  }
1491
- .rvg-row-drag-preview {
1508
+ .rvg-row-drag-preview-frame {
1492
1509
  position: relative;
1493
1510
  overflow: hidden;
1511
+ }
1512
+ .rvg-row-drag-preview {
1513
+ position: absolute;
1514
+ top: 2px;
1515
+ left: 2px;
1516
+ overflow: visible;
1494
1517
  border: 1px solid #a9c8f5;
1495
1518
  background: #fff;
1496
- box-shadow: var(--rvg-shadow-popover);
1519
+ box-shadow: 0 2px 6px rgba(5, 5, 5, 0.08);
1497
1520
  box-sizing: border-box;
1498
1521
  }
1499
1522
  .rvg-row-drag-preview-cell {
@@ -1520,6 +1543,11 @@
1520
1543
  height: 16px;
1521
1544
  fill: var(--rvg-color-icon);
1522
1545
  }
1546
+ .rvg-row-drag-preview-cell.is-selected {
1547
+ z-index: 1;
1548
+ background: var(--rvg-color-selection-fill);
1549
+ box-shadow: 0 0 0 2px var(--rvg-color-primary);
1550
+ }
1523
1551
  .rvg-preview-checkbox {
1524
1552
  display: grid;
1525
1553
  width: 14px;
@@ -1539,7 +1567,7 @@
1539
1567
  position: absolute;
1540
1568
  z-index: 2;
1541
1569
  margin: 0;
1542
- padding: 0 9px;
1570
+ padding: 0 10px;
1543
1571
  border: 0;
1544
1572
  border-radius: 0;
1545
1573
  outline: 0;
@@ -1576,7 +1604,7 @@
1576
1604
  position: absolute;
1577
1605
  z-index: 6;
1578
1606
  display: flex;
1579
- padding: 0 28px 0 9px;
1607
+ padding: 0 28px 0 10px;
1580
1608
  align-items: center;
1581
1609
  gap: 3px;
1582
1610
  background: var(--rvg-color-bg);
@@ -1607,7 +1635,7 @@
1607
1635
  position: absolute;
1608
1636
  z-index: 6;
1609
1637
  display: flex;
1610
- padding: 0 9px;
1638
+ padding: 0 10px;
1611
1639
  align-items: center;
1612
1640
  gap: 6px;
1613
1641
  overflow: hidden;
@@ -1872,11 +1900,11 @@
1872
1900
  text-align: left;
1873
1901
  }
1874
1902
  .rvg-choice-editor [data-part=trigger] {
1875
- padding: 0 28px 0 9px;
1903
+ padding: 0 28px 0 10px;
1876
1904
  line-height: 1;
1877
1905
  }
1878
1906
  .rvg-date-value {
1879
- padding: 0 8px 2px 9px;
1907
+ padding: 0 8px 2px 10px;
1880
1908
  }
1881
1909
  .rvg-choice-editor [data-part=value-text] {
1882
1910
  min-width: 0;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import * as react from 'react';
2
- import { ReactNode, CSSProperties } from 'react';
1
+ import { ReactNode, MouseEvent, CSSProperties, RefAttributes, ReactElement } from 'react';
3
2
 
4
3
  type GridKey = string | number;
5
4
  type SelectionMode = 'single' | 'multiple';
@@ -155,6 +154,14 @@ interface AxisSelectionConfig {
155
154
  /** single uses radio-style selection, multiple uses checkbox-style selection. */
156
155
  mode?: SelectionMode;
157
156
  }
157
+ interface RowSelectionConfig extends AxisSelectionConfig {
158
+ /** Show the selection column. Defaults to true; when false, click body cells to select rows. */
159
+ showCheckbox?: boolean;
160
+ }
161
+ interface TableRowNumberConfig {
162
+ /** Fix the row number column to the left. Defaults to true. */
163
+ fixed?: boolean;
164
+ }
158
165
  /**
159
166
  * Column definition consumed by both the canvas renderer and DOM editor layer.
160
167
  *
@@ -179,7 +186,7 @@ interface GridColumn<Row> {
179
186
  /** Text alignment for body cells and drag previews. */
180
187
  align?: 'left' | 'center' | 'right';
181
188
  /** Enables double-click / Enter editing when an editor or fallback input exists. */
182
- editable?: boolean;
189
+ editable?: boolean | ((value: unknown, row: Row, rowIndex: number) => boolean);
183
190
  /** Built-in editor configuration for text, selectable, date, time, and range cells. */
184
191
  editor?: {
185
192
  type: 'text';
@@ -219,12 +226,53 @@ interface GridSelection extends GridCellPosition {
219
226
  rowKey: GridKey;
220
227
  columnKey: string;
221
228
  }
229
+ /** Cell locator accepted by controlled and default selection props. */
230
+ type GridSelectionTarget = {
231
+ columnKey: string;
232
+ rowKey: GridKey;
233
+ rowIndex?: number;
234
+ columnIndex?: number;
235
+ } | {
236
+ columnKey: string;
237
+ rowIndex: number;
238
+ rowKey?: GridKey;
239
+ columnIndex?: number;
240
+ };
241
+ /** Fully resolved selected cell returned by onSelectedCellChange. */
242
+ interface SelectedCellChange extends GridSelection {
243
+ value: unknown;
244
+ }
222
245
  /** Fired after a cell editor commits a value. */
223
246
  interface CellChange<Row> extends GridSelection {
224
247
  value: unknown;
225
248
  previousValue: unknown;
226
249
  row: Row;
227
250
  }
251
+ /** Data cell identity and content passed to mouse callbacks. */
252
+ interface TableCellContext<Row> extends GridSelection {
253
+ row: Row;
254
+ column: GridColumn<Row>;
255
+ value: unknown;
256
+ }
257
+ /** Imperative Table API. Selection getters reflect the latest committed render. */
258
+ interface TableRef<Row extends object> {
259
+ focus: () => void;
260
+ /** Reveal a data cell without changing selection; false if the target is unavailable. */
261
+ scrollToCell: (target: GridSelectionTarget) => boolean;
262
+ getSelectedCell: () => TableCellContext<Row> | null;
263
+ setSelectedCell: (target: GridSelectionTarget | null) => boolean;
264
+ getSelectedRowKeys: () => GridKey[];
265
+ getSelectedRows: () => Row[];
266
+ setSelectedRowKeys: (keys: GridKey[]) => void;
267
+ getSelectedColumnKeys: () => string[];
268
+ setSelectedColumnKeys: (keys: string[]) => void;
269
+ /** Clear cell, range, row, and column selections. */
270
+ clearSelection: () => void;
271
+ /** Select and edit a cell, or edit the current selection. Returns false for invalid or read-only cells. */
272
+ startEdit: (target?: GridSelectionTarget) => boolean;
273
+ commitEdit: () => void;
274
+ cancelEdit: () => void;
275
+ }
228
276
  /** Fired when the consumer wants to observe or extend a cell context menu. */
229
277
  interface ContextMenuEvent<Row> extends GridSelection {
230
278
  row: Row;
@@ -271,24 +319,6 @@ interface TableContextMenuConfig<Row> {
271
319
  range?: ContextMenuSection<Row, RangeContextMenuBuiltin, RangeContextMenuContext<Row>>;
272
320
  }
273
321
  type TableContextMenu<Row> = boolean | TableContextMenuConfig<Row>;
274
- /** Payload for inserting one or more rows around a target row. */
275
- interface InsertRowsEvent<Row> {
276
- rowIndex: number;
277
- row: Row;
278
- position: 'before' | 'after';
279
- count: number;
280
- /** Rows created by the grid for the optimistic visible insert. Consumers can persist these directly. */
281
- insertedRows?: Row[];
282
- }
283
- /** Payload for deleting the selected rows. */
284
- interface DeleteRowsEvent<Row> {
285
- rows: Array<{
286
- rowIndex: number;
287
- row: Row;
288
- }>;
289
- /** Current rendered viewport, including virtual overscan. Useful for fast optimistic updates before rebuilding large datasets. */
290
- viewportRange?: ViewportRange;
291
- }
292
322
  /**
293
323
  * Public props for Table.
294
324
  *
@@ -333,23 +363,25 @@ interface TableProps<Row extends object> {
333
363
  /** Show and position the summary row for columns with summary configured. */
334
364
  summary?: TableSummaryConfig;
335
365
  /** Show an automatically generated row number column on the left. */
336
- rowNumber?: boolean;
337
- selectedCell?: GridSelection | null;
338
- defaultSelectedCell?: GridSelection | null;
339
- onSelectedCellChange?: (selection: GridSelection | null) => void;
366
+ rowNumber?: boolean | TableRowNumberConfig;
367
+ selectedCell?: GridSelectionTarget | null;
368
+ defaultSelectedCell?: GridSelectionTarget | null;
369
+ onSelectedCellChange?: (selection: SelectedCellChange | null) => void;
340
370
  /** Enable spreadsheet-style mouse drag selection across multiple body cells. Defaults to false. */
341
371
  rangeSelection?: boolean;
342
- rowSelection?: boolean | AxisSelectionConfig;
372
+ rowSelection?: boolean | RowSelectionConfig;
343
373
  selectedRowKeys?: GridKey[];
344
374
  defaultSelectedRowKeys?: GridKey[];
345
- onSelectedRowKeysChange?: (keys: GridKey[], rows: Row[], indices: number[]) => void;
375
+ onSelectedRowChange?: (keys: GridKey[], rows: Row[], indices: number[]) => void;
346
376
  columnSelection?: boolean | AxisSelectionConfig;
347
377
  selectedColumnKeys?: string[];
348
378
  defaultSelectedColumnKeys?: string[];
349
- onSelectedColumnKeysChange?: (keys: string[]) => void;
379
+ onSelectedColumnChange?: (keys: string[]) => void;
350
380
  columnDraggable?: boolean;
351
381
  columnResizable?: boolean;
352
- onColumnOrderChange?: (sourceIndex: number, targetIndex: number, detail?: {
382
+ onColumnsReorder?: (columns: GridColumn<Row>[], detail: {
383
+ sourceIndex: number;
384
+ targetIndex: number;
353
385
  type: 'column' | 'group';
354
386
  sourceKey: string;
355
387
  targetKey: string;
@@ -358,14 +390,23 @@ interface TableProps<Row extends object> {
358
390
  }) => void;
359
391
  onColumnResize?: (columnKey: string, width: number) => void;
360
392
  rowDraggable?: boolean;
361
- onRowOrderChange?: (sourceIndex: number, targetIndex: number) => void;
362
- onInsertRows?: (event: InsertRowsEvent<Row>) => void | Promise<void>;
363
- onDeleteRows?: (event: DeleteRowsEvent<Row>) => void | Promise<void>;
364
- sortState?: GridSortState | null;
365
- onSortStateChange?: (state: GridSortState | null) => void;
366
- filterValues?: Record<string, string>;
367
- onFilterValuesChange?: (values: Record<string, string>) => void;
393
+ onRowsReorder?: (rows: Row[], detail: {
394
+ sourceIndex: number;
395
+ targetIndex: number;
396
+ }) => void;
397
+ /** Receives the complete rows array and the rows added by the built-in insert operation. */
398
+ onInsertRows?: (rows: Row[], insertedRows: Row[]) => void | Promise<void>;
399
+ /** Receives the complete rows array and the rows removed by the built-in delete operation. */
400
+ onDeleteRows?: (rows: Row[], deletedRows: Row[]) => void | Promise<void>;
401
+ /** Overrides the built-in value sorting. Return rows ordered for the internally managed sort state. */
402
+ onSortChange?: (rows: Row[], state: GridSortState) => Row[];
403
+ /** Overrides the built-in text filtering. Return the rows that match the internally managed filter values. */
404
+ onFilterChange?: (rows: Row[], values: Readonly<Record<string, string>>) => Row[];
368
405
  onCellChange?: (change: CellChange<Row>) => void | Promise<void>;
406
+ /** Fires on a data cell click, before the default selection behavior. */
407
+ onCellClick?: (cell: TableCellContext<Row>, event: MouseEvent<HTMLElement>) => void;
408
+ /** Fires before double-click editing. preventDefault() cancels editing. */
409
+ onCellDoubleClick?: (cell: TableCellContext<Row>, event: MouseEvent<HTMLElement>) => void;
369
410
  onCellContextMenu?: (event: ContextMenuEvent<Row>) => void;
370
411
  /** true uses the built-in menu, false disables custom menus, object customizes menu content and order. */
371
412
  contextMenu?: TableContextMenu<Row>;
@@ -381,7 +422,7 @@ interface ViewportRange {
381
422
  columnEnd: number;
382
423
  }
383
424
 
384
- declare function Table<Row extends object>({ columns: sourceColumns, rows: sourceRows, rowKey, width, height, autoHeight, layout, rowHeight: rowHeightProp, headerHeight: headerHeightProp, fixedHeader, locale, borderless, verticalBorderless, striped, highlight, cellSpans, loading, loadingContent, virtualized, tooltip, summary, rowNumber, selectedCell, defaultSelectedCell, onSelectedCellChange, rangeSelection, rowSelection, selectedRowKeys, defaultSelectedRowKeys, onSelectedRowKeysChange, columnSelection, selectedColumnKeys, defaultSelectedColumnKeys, onSelectedColumnKeysChange, columnDraggable, columnResizable, onColumnOrderChange, onColumnResize, rowDraggable, onRowOrderChange, onInsertRows, onDeleteRows, sortState, onSortStateChange, filterValues, onFilterValuesChange, onCellChange, onCellContextMenu, contextMenu: contextMenuConfig, emptyContent, className, style, ariaLabel, }: TableProps<Row>): react.JSX.Element;
425
+ declare const Table: <Row extends object>(props: TableProps<Row> & RefAttributes<TableRef<Row>>) => ReactElement;
385
426
 
386
427
  type LayoutColumn<Row> = GridColumn<Row> & {
387
428
  rowSelection?: boolean;
@@ -428,4 +469,4 @@ declare function hitTestColumn(metrics: ColumnMetric[], contentX: number): numbe
428
469
 
429
470
  type TableFilterValues = Record<string, string>;
430
471
 
431
- export { type AxisSelectionConfig, type CellChange, type ContextMenuEvent, type DeleteRowsEvent, type GridCellPosition, type GridColumn, type GridKey, type GridSelection, type GridSortState, type InsertRowsEvent, type SelectionMode, type SortDirection, Table, type CellChange as TableCellChange, type GridCellPosition as TableCellPosition, type TableCellSpan, type TableCellSpanRule, type TableCellSpanRuleContext, type TableCellSpans, type GridColumn as TableColumn, type TableContextMenu, type TableContextMenuConfig, type ContextMenuEvent as TableContextMenuEvent, type DeleteRowsEvent as TableDeleteRowsEvent, type GridSelection as TableEditingCell, type TableFilterValues, type TableHighlightConfig, type InsertRowsEvent as TableInsertRowsEvent, type GridKey as TableKey, type TableLabels, type TableLayoutConfig, type TableLocaleCode, type TableLocaleConfig, type TableProps, type TableResolvedCellSpan, type GridSortState as TableSorter, type TableSummaryConfig, type TableTooltipConfig, type ViewportRange as TableViewportRange, type TableVirtualizedConfig, Table as VelocityGrid, type TableCellSpan as VelocityGridCellSpan, type TableCellSpanRule as VelocityGridCellSpanRule, type TableCellSpanRuleContext as VelocityGridCellSpanRuleContext, type TableCellSpans as VelocityGridCellSpans, type TableContextMenu as VelocityGridContextMenu, type TableContextMenuConfig as VelocityGridContextMenuConfig, type TableHighlightConfig as VelocityGridHighlightConfig, type TableLabels as VelocityGridLabels, type TableLayoutConfig as VelocityGridLayoutConfig, type TableLocaleCode as VelocityGridLocaleCode, type TableLocaleConfig as VelocityGridLocaleConfig, type TableProps as VelocityGridProps, type TableResolvedCellSpan as VelocityGridResolvedCellSpan, type TableSummaryConfig as VelocityGridSummaryConfig, type TableTooltipConfig as VelocityGridTooltipConfig, type TableVirtualizedConfig as VelocityGridVirtualizedConfig, type ViewportRange, buildColumnMetrics, getViewportRange, hitTestColumn };
472
+ export { type AxisSelectionConfig, type CellChange, type ContextMenuEvent, type GridCellPosition, type GridColumn, type GridKey, type GridSelection, type GridSelectionTarget, type GridSortState, type RowSelectionConfig, type SelectedCellChange, type SelectionMode, type SortDirection, Table, type CellChange as TableCellChange, type TableCellContext, type GridCellPosition as TableCellPosition, type TableCellSpan, type TableCellSpanRule, type TableCellSpanRuleContext, type TableCellSpans, type GridColumn as TableColumn, type TableContextMenu, type TableContextMenuConfig, type ContextMenuEvent as TableContextMenuEvent, type GridSelection as TableEditingCell, type TableFilterValues, type TableHighlightConfig, type GridKey as TableKey, type TableLabels, type TableLayoutConfig, type TableLocaleCode, type TableLocaleConfig, type TableProps, type TableRef, type TableResolvedCellSpan, type TableRowNumberConfig, type GridSortState as TableSorter, type TableSummaryConfig, type TableTooltipConfig, type ViewportRange as TableViewportRange, type TableVirtualizedConfig, Table as VelocityGrid, type TableCellSpan as VelocityGridCellSpan, type TableCellSpanRule as VelocityGridCellSpanRule, type TableCellSpanRuleContext as VelocityGridCellSpanRuleContext, type TableCellSpans as VelocityGridCellSpans, type TableContextMenu as VelocityGridContextMenu, type TableContextMenuConfig as VelocityGridContextMenuConfig, type TableHighlightConfig as VelocityGridHighlightConfig, type TableLabels as VelocityGridLabels, type TableLayoutConfig as VelocityGridLayoutConfig, type TableLocaleCode as VelocityGridLocaleCode, type TableLocaleConfig as VelocityGridLocaleConfig, type TableProps as VelocityGridProps, type TableRef as VelocityGridRef, type TableResolvedCellSpan as VelocityGridResolvedCellSpan, type TableSummaryConfig as VelocityGridSummaryConfig, type TableTooltipConfig as VelocityGridTooltipConfig, type TableVirtualizedConfig as VelocityGridVirtualizedConfig, type ViewportRange, buildColumnMetrics, getViewportRange, hitTestColumn };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import * as react from 'react';
2
- import { ReactNode, CSSProperties } from 'react';
1
+ import { ReactNode, MouseEvent, CSSProperties, RefAttributes, ReactElement } from 'react';
3
2
 
4
3
  type GridKey = string | number;
5
4
  type SelectionMode = 'single' | 'multiple';
@@ -155,6 +154,14 @@ interface AxisSelectionConfig {
155
154
  /** single uses radio-style selection, multiple uses checkbox-style selection. */
156
155
  mode?: SelectionMode;
157
156
  }
157
+ interface RowSelectionConfig extends AxisSelectionConfig {
158
+ /** Show the selection column. Defaults to true; when false, click body cells to select rows. */
159
+ showCheckbox?: boolean;
160
+ }
161
+ interface TableRowNumberConfig {
162
+ /** Fix the row number column to the left. Defaults to true. */
163
+ fixed?: boolean;
164
+ }
158
165
  /**
159
166
  * Column definition consumed by both the canvas renderer and DOM editor layer.
160
167
  *
@@ -179,7 +186,7 @@ interface GridColumn<Row> {
179
186
  /** Text alignment for body cells and drag previews. */
180
187
  align?: 'left' | 'center' | 'right';
181
188
  /** Enables double-click / Enter editing when an editor or fallback input exists. */
182
- editable?: boolean;
189
+ editable?: boolean | ((value: unknown, row: Row, rowIndex: number) => boolean);
183
190
  /** Built-in editor configuration for text, selectable, date, time, and range cells. */
184
191
  editor?: {
185
192
  type: 'text';
@@ -219,12 +226,53 @@ interface GridSelection extends GridCellPosition {
219
226
  rowKey: GridKey;
220
227
  columnKey: string;
221
228
  }
229
+ /** Cell locator accepted by controlled and default selection props. */
230
+ type GridSelectionTarget = {
231
+ columnKey: string;
232
+ rowKey: GridKey;
233
+ rowIndex?: number;
234
+ columnIndex?: number;
235
+ } | {
236
+ columnKey: string;
237
+ rowIndex: number;
238
+ rowKey?: GridKey;
239
+ columnIndex?: number;
240
+ };
241
+ /** Fully resolved selected cell returned by onSelectedCellChange. */
242
+ interface SelectedCellChange extends GridSelection {
243
+ value: unknown;
244
+ }
222
245
  /** Fired after a cell editor commits a value. */
223
246
  interface CellChange<Row> extends GridSelection {
224
247
  value: unknown;
225
248
  previousValue: unknown;
226
249
  row: Row;
227
250
  }
251
+ /** Data cell identity and content passed to mouse callbacks. */
252
+ interface TableCellContext<Row> extends GridSelection {
253
+ row: Row;
254
+ column: GridColumn<Row>;
255
+ value: unknown;
256
+ }
257
+ /** Imperative Table API. Selection getters reflect the latest committed render. */
258
+ interface TableRef<Row extends object> {
259
+ focus: () => void;
260
+ /** Reveal a data cell without changing selection; false if the target is unavailable. */
261
+ scrollToCell: (target: GridSelectionTarget) => boolean;
262
+ getSelectedCell: () => TableCellContext<Row> | null;
263
+ setSelectedCell: (target: GridSelectionTarget | null) => boolean;
264
+ getSelectedRowKeys: () => GridKey[];
265
+ getSelectedRows: () => Row[];
266
+ setSelectedRowKeys: (keys: GridKey[]) => void;
267
+ getSelectedColumnKeys: () => string[];
268
+ setSelectedColumnKeys: (keys: string[]) => void;
269
+ /** Clear cell, range, row, and column selections. */
270
+ clearSelection: () => void;
271
+ /** Select and edit a cell, or edit the current selection. Returns false for invalid or read-only cells. */
272
+ startEdit: (target?: GridSelectionTarget) => boolean;
273
+ commitEdit: () => void;
274
+ cancelEdit: () => void;
275
+ }
228
276
  /** Fired when the consumer wants to observe or extend a cell context menu. */
229
277
  interface ContextMenuEvent<Row> extends GridSelection {
230
278
  row: Row;
@@ -271,24 +319,6 @@ interface TableContextMenuConfig<Row> {
271
319
  range?: ContextMenuSection<Row, RangeContextMenuBuiltin, RangeContextMenuContext<Row>>;
272
320
  }
273
321
  type TableContextMenu<Row> = boolean | TableContextMenuConfig<Row>;
274
- /** Payload for inserting one or more rows around a target row. */
275
- interface InsertRowsEvent<Row> {
276
- rowIndex: number;
277
- row: Row;
278
- position: 'before' | 'after';
279
- count: number;
280
- /** Rows created by the grid for the optimistic visible insert. Consumers can persist these directly. */
281
- insertedRows?: Row[];
282
- }
283
- /** Payload for deleting the selected rows. */
284
- interface DeleteRowsEvent<Row> {
285
- rows: Array<{
286
- rowIndex: number;
287
- row: Row;
288
- }>;
289
- /** Current rendered viewport, including virtual overscan. Useful for fast optimistic updates before rebuilding large datasets. */
290
- viewportRange?: ViewportRange;
291
- }
292
322
  /**
293
323
  * Public props for Table.
294
324
  *
@@ -333,23 +363,25 @@ interface TableProps<Row extends object> {
333
363
  /** Show and position the summary row for columns with summary configured. */
334
364
  summary?: TableSummaryConfig;
335
365
  /** Show an automatically generated row number column on the left. */
336
- rowNumber?: boolean;
337
- selectedCell?: GridSelection | null;
338
- defaultSelectedCell?: GridSelection | null;
339
- onSelectedCellChange?: (selection: GridSelection | null) => void;
366
+ rowNumber?: boolean | TableRowNumberConfig;
367
+ selectedCell?: GridSelectionTarget | null;
368
+ defaultSelectedCell?: GridSelectionTarget | null;
369
+ onSelectedCellChange?: (selection: SelectedCellChange | null) => void;
340
370
  /** Enable spreadsheet-style mouse drag selection across multiple body cells. Defaults to false. */
341
371
  rangeSelection?: boolean;
342
- rowSelection?: boolean | AxisSelectionConfig;
372
+ rowSelection?: boolean | RowSelectionConfig;
343
373
  selectedRowKeys?: GridKey[];
344
374
  defaultSelectedRowKeys?: GridKey[];
345
- onSelectedRowKeysChange?: (keys: GridKey[], rows: Row[], indices: number[]) => void;
375
+ onSelectedRowChange?: (keys: GridKey[], rows: Row[], indices: number[]) => void;
346
376
  columnSelection?: boolean | AxisSelectionConfig;
347
377
  selectedColumnKeys?: string[];
348
378
  defaultSelectedColumnKeys?: string[];
349
- onSelectedColumnKeysChange?: (keys: string[]) => void;
379
+ onSelectedColumnChange?: (keys: string[]) => void;
350
380
  columnDraggable?: boolean;
351
381
  columnResizable?: boolean;
352
- onColumnOrderChange?: (sourceIndex: number, targetIndex: number, detail?: {
382
+ onColumnsReorder?: (columns: GridColumn<Row>[], detail: {
383
+ sourceIndex: number;
384
+ targetIndex: number;
353
385
  type: 'column' | 'group';
354
386
  sourceKey: string;
355
387
  targetKey: string;
@@ -358,14 +390,23 @@ interface TableProps<Row extends object> {
358
390
  }) => void;
359
391
  onColumnResize?: (columnKey: string, width: number) => void;
360
392
  rowDraggable?: boolean;
361
- onRowOrderChange?: (sourceIndex: number, targetIndex: number) => void;
362
- onInsertRows?: (event: InsertRowsEvent<Row>) => void | Promise<void>;
363
- onDeleteRows?: (event: DeleteRowsEvent<Row>) => void | Promise<void>;
364
- sortState?: GridSortState | null;
365
- onSortStateChange?: (state: GridSortState | null) => void;
366
- filterValues?: Record<string, string>;
367
- onFilterValuesChange?: (values: Record<string, string>) => void;
393
+ onRowsReorder?: (rows: Row[], detail: {
394
+ sourceIndex: number;
395
+ targetIndex: number;
396
+ }) => void;
397
+ /** Receives the complete rows array and the rows added by the built-in insert operation. */
398
+ onInsertRows?: (rows: Row[], insertedRows: Row[]) => void | Promise<void>;
399
+ /** Receives the complete rows array and the rows removed by the built-in delete operation. */
400
+ onDeleteRows?: (rows: Row[], deletedRows: Row[]) => void | Promise<void>;
401
+ /** Overrides the built-in value sorting. Return rows ordered for the internally managed sort state. */
402
+ onSortChange?: (rows: Row[], state: GridSortState) => Row[];
403
+ /** Overrides the built-in text filtering. Return the rows that match the internally managed filter values. */
404
+ onFilterChange?: (rows: Row[], values: Readonly<Record<string, string>>) => Row[];
368
405
  onCellChange?: (change: CellChange<Row>) => void | Promise<void>;
406
+ /** Fires on a data cell click, before the default selection behavior. */
407
+ onCellClick?: (cell: TableCellContext<Row>, event: MouseEvent<HTMLElement>) => void;
408
+ /** Fires before double-click editing. preventDefault() cancels editing. */
409
+ onCellDoubleClick?: (cell: TableCellContext<Row>, event: MouseEvent<HTMLElement>) => void;
369
410
  onCellContextMenu?: (event: ContextMenuEvent<Row>) => void;
370
411
  /** true uses the built-in menu, false disables custom menus, object customizes menu content and order. */
371
412
  contextMenu?: TableContextMenu<Row>;
@@ -381,7 +422,7 @@ interface ViewportRange {
381
422
  columnEnd: number;
382
423
  }
383
424
 
384
- declare function Table<Row extends object>({ columns: sourceColumns, rows: sourceRows, rowKey, width, height, autoHeight, layout, rowHeight: rowHeightProp, headerHeight: headerHeightProp, fixedHeader, locale, borderless, verticalBorderless, striped, highlight, cellSpans, loading, loadingContent, virtualized, tooltip, summary, rowNumber, selectedCell, defaultSelectedCell, onSelectedCellChange, rangeSelection, rowSelection, selectedRowKeys, defaultSelectedRowKeys, onSelectedRowKeysChange, columnSelection, selectedColumnKeys, defaultSelectedColumnKeys, onSelectedColumnKeysChange, columnDraggable, columnResizable, onColumnOrderChange, onColumnResize, rowDraggable, onRowOrderChange, onInsertRows, onDeleteRows, sortState, onSortStateChange, filterValues, onFilterValuesChange, onCellChange, onCellContextMenu, contextMenu: contextMenuConfig, emptyContent, className, style, ariaLabel, }: TableProps<Row>): react.JSX.Element;
425
+ declare const Table: <Row extends object>(props: TableProps<Row> & RefAttributes<TableRef<Row>>) => ReactElement;
385
426
 
386
427
  type LayoutColumn<Row> = GridColumn<Row> & {
387
428
  rowSelection?: boolean;
@@ -428,4 +469,4 @@ declare function hitTestColumn(metrics: ColumnMetric[], contentX: number): numbe
428
469
 
429
470
  type TableFilterValues = Record<string, string>;
430
471
 
431
- export { type AxisSelectionConfig, type CellChange, type ContextMenuEvent, type DeleteRowsEvent, type GridCellPosition, type GridColumn, type GridKey, type GridSelection, type GridSortState, type InsertRowsEvent, type SelectionMode, type SortDirection, Table, type CellChange as TableCellChange, type GridCellPosition as TableCellPosition, type TableCellSpan, type TableCellSpanRule, type TableCellSpanRuleContext, type TableCellSpans, type GridColumn as TableColumn, type TableContextMenu, type TableContextMenuConfig, type ContextMenuEvent as TableContextMenuEvent, type DeleteRowsEvent as TableDeleteRowsEvent, type GridSelection as TableEditingCell, type TableFilterValues, type TableHighlightConfig, type InsertRowsEvent as TableInsertRowsEvent, type GridKey as TableKey, type TableLabels, type TableLayoutConfig, type TableLocaleCode, type TableLocaleConfig, type TableProps, type TableResolvedCellSpan, type GridSortState as TableSorter, type TableSummaryConfig, type TableTooltipConfig, type ViewportRange as TableViewportRange, type TableVirtualizedConfig, Table as VelocityGrid, type TableCellSpan as VelocityGridCellSpan, type TableCellSpanRule as VelocityGridCellSpanRule, type TableCellSpanRuleContext as VelocityGridCellSpanRuleContext, type TableCellSpans as VelocityGridCellSpans, type TableContextMenu as VelocityGridContextMenu, type TableContextMenuConfig as VelocityGridContextMenuConfig, type TableHighlightConfig as VelocityGridHighlightConfig, type TableLabels as VelocityGridLabels, type TableLayoutConfig as VelocityGridLayoutConfig, type TableLocaleCode as VelocityGridLocaleCode, type TableLocaleConfig as VelocityGridLocaleConfig, type TableProps as VelocityGridProps, type TableResolvedCellSpan as VelocityGridResolvedCellSpan, type TableSummaryConfig as VelocityGridSummaryConfig, type TableTooltipConfig as VelocityGridTooltipConfig, type TableVirtualizedConfig as VelocityGridVirtualizedConfig, type ViewportRange, buildColumnMetrics, getViewportRange, hitTestColumn };
472
+ export { type AxisSelectionConfig, type CellChange, type ContextMenuEvent, type GridCellPosition, type GridColumn, type GridKey, type GridSelection, type GridSelectionTarget, type GridSortState, type RowSelectionConfig, type SelectedCellChange, type SelectionMode, type SortDirection, Table, type CellChange as TableCellChange, type TableCellContext, type GridCellPosition as TableCellPosition, type TableCellSpan, type TableCellSpanRule, type TableCellSpanRuleContext, type TableCellSpans, type GridColumn as TableColumn, type TableContextMenu, type TableContextMenuConfig, type ContextMenuEvent as TableContextMenuEvent, type GridSelection as TableEditingCell, type TableFilterValues, type TableHighlightConfig, type GridKey as TableKey, type TableLabels, type TableLayoutConfig, type TableLocaleCode, type TableLocaleConfig, type TableProps, type TableRef, type TableResolvedCellSpan, type TableRowNumberConfig, type GridSortState as TableSorter, type TableSummaryConfig, type TableTooltipConfig, type ViewportRange as TableViewportRange, type TableVirtualizedConfig, Table as VelocityGrid, type TableCellSpan as VelocityGridCellSpan, type TableCellSpanRule as VelocityGridCellSpanRule, type TableCellSpanRuleContext as VelocityGridCellSpanRuleContext, type TableCellSpans as VelocityGridCellSpans, type TableContextMenu as VelocityGridContextMenu, type TableContextMenuConfig as VelocityGridContextMenuConfig, type TableHighlightConfig as VelocityGridHighlightConfig, type TableLabels as VelocityGridLabels, type TableLayoutConfig as VelocityGridLayoutConfig, type TableLocaleCode as VelocityGridLocaleCode, type TableLocaleConfig as VelocityGridLocaleConfig, type TableProps as VelocityGridProps, type TableRef as VelocityGridRef, type TableResolvedCellSpan as VelocityGridResolvedCellSpan, type TableSummaryConfig as VelocityGridSummaryConfig, type TableTooltipConfig as VelocityGridTooltipConfig, type TableVirtualizedConfig as VelocityGridVirtualizedConfig, type ViewportRange, buildColumnMetrics, getViewportRange, hitTestColumn };