@wallarm-org/design-system 1.15.0 → 1.17.0

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.
Files changed (46) hide show
  1. package/dist/components/FilterInput/FilterInputMenu/FilterInputMenu.js +3 -2
  2. package/dist/components/FilterInput/FilterInputMenu/FilterInputValueMenu/FilterInputValueMenu.d.ts +2 -0
  3. package/dist/components/FilterInput/FilterInputMenu/FilterInputValueMenu/FlatValueMenu.js +4 -2
  4. package/dist/components/FilterInput/FilterInputMenu/FilterInputValueMenu/NestedValueMenu.js +4 -2
  5. package/dist/components/FilterInput/FilterInputMenu/MenuEmptyState.d.ts +6 -1
  6. package/dist/components/FilterInput/FilterInputMenu/MenuEmptyState.js +2 -2
  7. package/dist/components/FilterInput/types.d.ts +9 -0
  8. package/dist/components/SplashScreen/SplashScreen.js +6 -4
  9. package/dist/components/SplashScreen/lib.js +6 -1
  10. package/dist/components/SplashScreen/useSplashPhase.js +16 -13
  11. package/dist/components/Table/EditableCell/EditableSelectCell.js +15 -9
  12. package/dist/components/Table/StickyGroupParent.d.ts +7 -0
  13. package/dist/components/Table/StickyGroupParent.js +124 -0
  14. package/dist/components/Table/TableBody/TableBody.js +16 -13
  15. package/dist/components/Table/TableBody/TableBodyCell.d.ts +4 -1
  16. package/dist/components/Table/TableBody/TableBodyCell.js +4 -2
  17. package/dist/components/Table/TableBody/TableBodyRowDndContext.d.ts +6 -0
  18. package/dist/components/Table/TableBody/TableBodyRowDndContext.js +68 -0
  19. package/dist/components/Table/TableBody/TableBodyVirtualizedCore.js +42 -39
  20. package/dist/components/Table/TableBody/TableRowOverlay.d.ts +8 -0
  21. package/dist/components/Table/TableBody/TableRowOverlay.js +36 -0
  22. package/dist/components/Table/TableColGroup.js +3 -2
  23. package/dist/components/Table/TableContext/TableProvider.js +15 -4
  24. package/dist/components/Table/TableContext/types.d.ts +4 -1
  25. package/dist/components/Table/TableInner/TableInnerContainer.js +8 -1
  26. package/dist/components/Table/TableInner/TableInnerWindow.js +8 -1
  27. package/dist/components/Table/TableRow.js +28 -9
  28. package/dist/components/Table/TableRowExpanded.d.ts +4 -1
  29. package/dist/components/Table/TableRowExpanded.js +2 -1
  30. package/dist/components/Table/TableSettingsMenu/TableSettingsMenu.js +2 -2
  31. package/dist/components/Table/hooks/index.d.ts +1 -0
  32. package/dist/components/Table/hooks/index.js +1 -0
  33. package/dist/components/Table/hooks/useStickyGroupParent.d.ts +19 -0
  34. package/dist/components/Table/hooks/useStickyGroupParent.js +147 -0
  35. package/dist/components/Table/index.d.ts +1 -1
  36. package/dist/components/Table/lib/constants.d.ts +2 -0
  37. package/dist/components/Table/lib/constants.js +3 -1
  38. package/dist/components/Table/lib/createDragHandleColumn.d.ts +8 -0
  39. package/dist/components/Table/lib/createDragHandleColumn.js +23 -0
  40. package/dist/components/Table/lib/index.d.ts +3 -1
  41. package/dist/components/Table/lib/index.js +3 -1
  42. package/dist/components/Table/lib/useRowDnd.d.ts +15 -0
  43. package/dist/components/Table/lib/useRowDnd.js +32 -0
  44. package/dist/components/Table/types.d.ts +11 -0
  45. package/dist/metadata/components.json +34 -4
  46. package/package.json +1 -1
@@ -5,6 +5,7 @@ import { TBody, Td, Tr } from "../primitives/index.js";
5
5
  import { useTableContext } from "../TableContext/index.js";
6
6
  import { TableLoadingState } from "../TableLoadingState.js";
7
7
  import { TableRow } from "../TableRow.js";
8
+ import { TableBodyRowDndContext } from "./TableBodyRowDndContext.js";
8
9
  const TableBodyVirtualizedCore = ({ tbodyRef, virtualizer })=>{
9
10
  const { table, isLoading, isLoadingPrevious } = useTableContext();
10
11
  const testId = useTestId('body');
@@ -14,45 +15,47 @@ const TableBodyVirtualizedCore = ({ tbodyRef, virtualizer })=>{
14
15
  const rows = table.getRowModel().rows;
15
16
  const colSpan = table.getVisibleLeafColumns().length;
16
17
  const scrollMargin = virtualizer.options.scrollMargin;
17
- return /*#__PURE__*/ jsxs(TBody, {
18
- ref: tbodyRef,
19
- "data-testid": testId,
20
- children: [
21
- isLoadingPrevious && /*#__PURE__*/ jsx(TableLoadingState, {
22
- position: "start",
23
- count: TABLE_PREPEND_SKELETON_ROWS
24
- }),
25
- virtualRows.length > 0 && /*#__PURE__*/ jsx(Tr, {
26
- children: /*#__PURE__*/ jsx(Td, {
27
- style: {
28
- height: `${(virtualRows[0]?.start ?? 0) - scrollMargin}px`,
29
- padding: 0,
30
- border: 'none'
31
- },
32
- colSpan: colSpan
33
- })
34
- }, "spacer-top"),
35
- virtualRows.map((virtualRow)=>{
36
- const row = rows.at(virtualRow.index);
37
- if (row) return /*#__PURE__*/ jsx(TableRow, {
38
- row: row,
39
- "data-index": virtualRow.index,
40
- ref: measureElement
41
- }, row.id);
42
- return null;
43
- }),
44
- isLoading && /*#__PURE__*/ jsx(TableLoadingState, {}),
45
- virtualRows.length > 0 && /*#__PURE__*/ jsx(Tr, {
46
- children: /*#__PURE__*/ jsx(Td, {
47
- style: {
48
- height: `${totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0)}px`,
49
- padding: 0,
50
- border: 'none'
51
- },
52
- colSpan: colSpan
53
- })
54
- }, "spacer-bottom")
55
- ]
18
+ return /*#__PURE__*/ jsx(TableBodyRowDndContext, {
19
+ children: /*#__PURE__*/ jsxs(TBody, {
20
+ ref: tbodyRef,
21
+ "data-testid": testId,
22
+ children: [
23
+ isLoadingPrevious && /*#__PURE__*/ jsx(TableLoadingState, {
24
+ position: "start",
25
+ count: TABLE_PREPEND_SKELETON_ROWS
26
+ }),
27
+ virtualRows.length > 0 && /*#__PURE__*/ jsx(Tr, {
28
+ children: /*#__PURE__*/ jsx(Td, {
29
+ style: {
30
+ height: `${(virtualRows[0]?.start ?? 0) - scrollMargin}px`,
31
+ padding: 0,
32
+ border: 'none'
33
+ },
34
+ colSpan: colSpan
35
+ })
36
+ }, "spacer-top"),
37
+ virtualRows.map((virtualRow)=>{
38
+ const row = rows.at(virtualRow.index);
39
+ if (row) return /*#__PURE__*/ jsx(TableRow, {
40
+ row: row,
41
+ "data-index": virtualRow.index,
42
+ ref: measureElement
43
+ }, row.id);
44
+ return null;
45
+ }),
46
+ isLoading && /*#__PURE__*/ jsx(TableLoadingState, {}),
47
+ virtualRows.length > 0 && /*#__PURE__*/ jsx(Tr, {
48
+ children: /*#__PURE__*/ jsx(Td, {
49
+ style: {
50
+ height: `${totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0)}px`,
51
+ padding: 0,
52
+ border: 'none'
53
+ },
54
+ colSpan: colSpan
55
+ })
56
+ }, "spacer-bottom")
57
+ ]
58
+ })
56
59
  });
57
60
  };
58
61
  TableBodyVirtualizedCore.displayName = 'TableBodyVirtualizedCore';
@@ -0,0 +1,8 @@
1
+ import type { FC } from 'react';
2
+ import { type Row, type RowData } from '@tanstack/react-table';
3
+ import { type DSTableFeatures } from '../lib';
4
+ interface TableRowOverlayProps<T extends RowData> {
5
+ row: Row<DSTableFeatures, T>;
6
+ }
7
+ export declare const TableRowOverlay: FC<TableRowOverlayProps<RowData>>;
8
+ export {};
@@ -0,0 +1,36 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { flexRender } from "@tanstack/react-table";
3
+ import { cn } from "../../../utils/cn.js";
4
+ import { getAlignClass } from "../lib/index.js";
5
+ import { Td, Tr } from "../primitives/index.js";
6
+ import { useTableContext } from "../TableContext/index.js";
7
+ const TableRowOverlayInner = ({ row })=>{
8
+ const { table } = useTableContext();
9
+ const visibleColumns = table.getVisibleLeafColumns();
10
+ return /*#__PURE__*/ jsx("table", {
11
+ className: "w-full table-fixed border-collapse",
12
+ style: {
13
+ tableLayout: 'fixed'
14
+ },
15
+ children: /*#__PURE__*/ jsx("tbody", {
16
+ children: /*#__PURE__*/ jsx(Tr, {
17
+ className: "pointer-events-none shadow-lg opacity-90 bg-bg-primary",
18
+ children: row.getVisibleCells().map((cell)=>{
19
+ const column = visibleColumns.find((c)=>c.id === cell.column.id);
20
+ const meta = cell.column.columnDef.meta;
21
+ return /*#__PURE__*/ jsx(Td, {
22
+ pinned: false,
23
+ className: cn(getAlignClass(meta), meta?.cellClassName),
24
+ style: {
25
+ width: column?.getSize()
26
+ },
27
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
28
+ }, cell.id);
29
+ })
30
+ })
31
+ })
32
+ });
33
+ };
34
+ const TableRowOverlay = TableRowOverlayInner;
35
+ TableRowOverlay.displayName = 'TableRowOverlay';
36
+ export { TableRowOverlay };
@@ -1,9 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID } from "./lib/index.js";
2
+ import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID } from "./lib/index.js";
3
3
  import { useTableContext } from "./TableContext/index.js";
4
4
  const SYSTEM_COLUMN_IDS = new Set([
5
5
  TABLE_SELECT_COLUMN_ID,
6
- TABLE_EXPAND_COLUMN_ID
6
+ TABLE_EXPAND_COLUMN_ID,
7
+ TABLE_DRAG_HANDLE_COLUMN_ID
7
8
  ]);
8
9
  const TableColGroup = ({ tableWidth })=>{
9
10
  const { table } = useTableContext();
@@ -5,7 +5,7 @@ import { SortableContext, arrayMove, horizontalListSortingStrategy, sortableKeyb
5
5
  import { useTable } from "@tanstack/react-table";
6
6
  import { useControlled } from "../../../hooks/index.js";
7
7
  import { useTableState } from "../hooks/index.js";
8
- import { TABLE_EXPAND_COLUMN_ID, TABLE_MIN_COLUMN_WIDTH, TABLE_SELECT_COLUMN_ID, TABLE_SKELETON_ROWS, TABLE_VIRTUALIZATION_OVERSCAN, createExpandColumn, createSelectionColumn, dsTableFeatures } from "../lib/index.js";
8
+ import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_MIN_COLUMN_WIDTH, TABLE_SELECT_COLUMN_ID, TABLE_SKELETON_ROWS, TABLE_VIRTUALIZATION_OVERSCAN, createDragHandleColumn, createExpandColumn, createSelectionColumn, dsTableFeatures } from "../lib/index.js";
9
9
  import { TableContext } from "./TableContext.js";
10
10
  const toTanStackPinning = (p, pinnedLeft)=>({
11
11
  start: [
@@ -15,7 +15,7 @@ const toTanStackPinning = (p, pinnedLeft)=>({
15
15
  end: p?.right ?? []
16
16
  });
17
17
  const TableProvider = (props)=>{
18
- const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, columnGroups, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
18
+ const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, columnGroups, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onRowReorder, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
19
19
  const masterCellActiveRowId = activeRowIdProp ?? null;
20
20
  const sortingEnabled = !!onSortingChange;
21
21
  const selectionEnabled = !!onRowSelectionChange;
@@ -24,6 +24,7 @@ const TableProvider = (props)=>{
24
24
  const columnDndEnabled = !!onColumnOrderChange;
25
25
  const groupingEnabled = !!groupingProp || !!onGroupingChange;
26
26
  const subRowGroupingEnabled = !!renderGroupRow && !!getSubRows;
27
+ const rowDndEnabled = !!onRowReorder && !subRowGroupingEnabled;
27
28
  const expandingEnabled = !!renderExpandedRow || !!onExpandedChange || subRowGroupingEnabled;
28
29
  const visibilityEnabled = !!onColumnVisibilityChange;
29
30
  const mergedColumns = useMemo(()=>{
@@ -31,6 +32,7 @@ const TableProvider = (props)=>{
31
32
  const prefix = [];
32
33
  if (expandingEnabled && !subRowGroupingEnabled) prefix.push(createExpandColumn());
33
34
  if (selectionEnabled) prefix.push(createSelectionColumn());
35
+ if (rowDndEnabled) prefix.push(createDragHandleColumn());
34
36
  const firstRow = data[0];
35
37
  const withAutoMeta = cols.map((col)=>{
36
38
  if (!firstRow || !('accessorKey' in col) || col.meta?.sortType) return col;
@@ -71,7 +73,8 @@ const TableProvider = (props)=>{
71
73
  data,
72
74
  selectionEnabled,
73
75
  expandingEnabled,
74
- subRowGroupingEnabled
76
+ subRowGroupingEnabled,
77
+ rowDndEnabled
75
78
  ]);
76
79
  const masterColumnId = useMemo(()=>{
77
80
  if (0 === columns.length) return null;
@@ -85,13 +88,15 @@ const TableProvider = (props)=>{
85
88
  const ids = [];
86
89
  if (expandingEnabled && !subRowGroupingEnabled) ids.push(TABLE_EXPAND_COLUMN_ID);
87
90
  if (selectionEnabled) ids.push(TABLE_SELECT_COLUMN_ID);
91
+ if (rowDndEnabled) ids.push(TABLE_DRAG_HANDLE_COLUMN_ID);
88
92
  if (masterColumnId) ids.push(masterColumnId);
89
93
  return ids;
90
94
  }, [
91
95
  masterColumnId,
92
96
  expandingEnabled,
93
97
  selectionEnabled,
94
- subRowGroupingEnabled
98
+ subRowGroupingEnabled,
99
+ rowDndEnabled
95
100
  ]);
96
101
  const [sorting, handleSortingChange] = useTableState(sortingProp, [], onSortingChange);
97
102
  const [rowSelection, handleRowSelectionChange] = useTableState(rowSelectionProp, {}, onRowSelectionChange);
@@ -191,9 +196,11 @@ const TableProvider = (props)=>{
191
196
  resizingEnabled,
192
197
  pinningEnabled,
193
198
  columnDndEnabled,
199
+ rowDndEnabled,
194
200
  groupingEnabled,
195
201
  expandingEnabled,
196
202
  visibilityEnabled,
203
+ hasSubRowGrouping: !!getSubRows,
197
204
  virtualized,
198
205
  renderExpandedRow: renderExpandedRow,
199
206
  estimateRowHeight,
@@ -214,6 +221,7 @@ const TableProvider = (props)=>{
214
221
  onStartReached,
215
222
  onStartReachedThreshold,
216
223
  initialScrollToRowId,
224
+ onRowReorder,
217
225
  onMasterCellClick,
218
226
  activeRowId: masterCellActiveRowId,
219
227
  onSettingsOpenChange
@@ -227,9 +235,11 @@ const TableProvider = (props)=>{
227
235
  resizingEnabled,
228
236
  pinningEnabled,
229
237
  columnDndEnabled,
238
+ rowDndEnabled,
230
239
  groupingEnabled,
231
240
  expandingEnabled,
232
241
  visibilityEnabled,
242
+ getSubRows,
233
243
  virtualized,
234
244
  renderExpandedRow,
235
245
  estimateRowHeight,
@@ -246,6 +256,7 @@ const TableProvider = (props)=>{
246
256
  onStartReached,
247
257
  onStartReachedThreshold,
248
258
  initialScrollToRowId,
259
+ onRowReorder,
249
260
  masterCellActiveRowId,
250
261
  onMasterCellClick,
251
262
  onSettingsOpenChange
@@ -2,7 +2,7 @@ import type { ReactNode, RefObject } from 'react';
2
2
  import type { Column, ColumnVisibilityState, ReactTable, Row, RowData } from '@tanstack/react-table';
3
3
  import type { Virtualizer } from '@tanstack/react-virtual';
4
4
  import type { DSTableFeatures } from '../lib';
5
- import type { TableColumnGroup, TableProps, TableVirtualized } from '../types';
5
+ import type { TableColumnGroup, TableProps, TableRowReorderEvent, TableVirtualized } from '../types';
6
6
  /**
7
7
  * Union covers both virtualizer flavors used by the Table (`useVirtualizer`
8
8
  * with HTMLElement scroll container and `useWindowVirtualizer` with Window).
@@ -19,9 +19,11 @@ export interface TableContextValue<T extends RowData> {
19
19
  resizingEnabled: boolean;
20
20
  pinningEnabled: boolean;
21
21
  columnDndEnabled: boolean;
22
+ rowDndEnabled: boolean;
22
23
  groupingEnabled: boolean;
23
24
  expandingEnabled: boolean;
24
25
  visibilityEnabled: boolean;
26
+ hasSubRowGrouping: boolean;
25
27
  virtualized: TableVirtualized | undefined;
26
28
  renderExpandedRow?: (row: Row<DSTableFeatures, T>) => ReactNode;
27
29
  estimateRowHeight?: (index: number) => number;
@@ -42,6 +44,7 @@ export interface TableContextValue<T extends RowData> {
42
44
  onStartReached?: () => void;
43
45
  onStartReachedThreshold?: number;
44
46
  initialScrollToRowId?: string;
47
+ onRowReorder?: (event: TableRowReorderEvent) => void;
45
48
  onMasterCellClick?: (rowId: string) => void;
46
49
  activeRowId: string | null;
47
50
  onSettingsOpenChange?: (open: boolean) => void;
@@ -6,13 +6,14 @@ import { ScrollArea, ScrollAreaCorner, ScrollAreaScrollbar, ScrollAreaViewport }
6
6
  import { tableContainerVariants } from "../classes.js";
7
7
  import { useInfiniteScroll } from "../hooks/index.js";
8
8
  import { useContainerWidth } from "../lib/index.js";
9
+ import { StickyGroupParent } from "../StickyGroupParent.js";
9
10
  import { TableBody } from "../TableBody/index.js";
10
11
  import { TableColGroup } from "../TableColGroup.js";
11
12
  import { useTableContext } from "../TableContext/index.js";
12
13
  import { TableHead } from "../TableHead.js";
13
14
  import { TableSettingsMenuSlot } from "../TableSettingsMenu/index.js";
14
15
  const TableInnerContainer = ({ isEmpty, virtualized, showSettings, hasConsumerSettingsMenu, ariaLabel, children })=>{
15
- const { containerRef, table, virtualizerRef, tbodyRef, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, isLoadingPrevious } = useTableContext();
16
+ const { containerRef, table, virtualizerRef, tbodyRef, hasSubRowGrouping, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, isLoadingPrevious } = useTableContext();
16
17
  const testId = useTestId('container');
17
18
  const scrollRootRef = useRef(null);
18
19
  const containerWidth = useContainerWidth(containerRef);
@@ -46,6 +47,8 @@ const TableInnerContainer = ({ isEmpty, virtualized, showSettings, hasConsumerSe
46
47
  ]);
47
48
  const totalSize = table.getTotalSize();
48
49
  const tableWidth = Math.max(containerWidth, totalSize);
50
+ const hasTextDescription = table.getAllLeafColumns().some((col)=>col.columnDef.meta?.description?.type === 'text');
51
+ const headerHeight = hasTextDescription ? 48 : 32;
49
52
  return /*#__PURE__*/ jsxs(Fragment, {
50
53
  children: [
51
54
  /*#__PURE__*/ jsxs(ScrollArea, {
@@ -60,6 +63,10 @@ const TableInnerContainer = ({ isEmpty, virtualized, showSettings, hasConsumerSe
60
63
  "data-table-scroll-container": true,
61
64
  tabIndex: -1,
62
65
  children: [
66
+ hasSubRowGrouping && /*#__PURE__*/ jsx(StickyGroupParent, {
67
+ tableWidth: tableWidth,
68
+ headerHeight: headerHeight
69
+ }),
63
70
  /*#__PURE__*/ jsxs("table", {
64
71
  className: "table-fixed border-separate border-spacing-0 overflow-clip",
65
72
  style: {
@@ -4,13 +4,14 @@ import { useTestId } from "../../../utils/testId.js";
4
4
  import { ScrollArea, ScrollAreaScrollbar, ScrollAreaViewport } from "../../ScrollArea/index.js";
5
5
  import { useInfiniteScroll } from "../hooks/index.js";
6
6
  import { useContainerWidth } from "../lib/index.js";
7
+ import { StickyGroupParent } from "../StickyGroupParent.js";
7
8
  import { TableBody } from "../TableBody/index.js";
8
9
  import { TableColGroup } from "../TableColGroup.js";
9
10
  import { useTableContext } from "../TableContext/index.js";
10
11
  import { TableHead } from "../TableHead.js";
11
12
  import { TableSettingsMenuSlot } from "../TableSettingsMenu/index.js";
12
13
  const TableInnerWindow = ({ isEmpty, showSettings, hasConsumerSettingsMenu, ariaLabel, children })=>{
13
- const { table, virtualizerRef, tbodyRef, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, isLoadingPrevious } = useTableContext();
14
+ const { table, virtualizerRef, tbodyRef, hasSubRowGrouping, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, isLoadingPrevious } = useTableContext();
14
15
  const testId = useTestId('window');
15
16
  const rootRef = useRef(null);
16
17
  const scrollRef = useRef(null);
@@ -40,6 +41,8 @@ const TableInnerWindow = ({ isEmpty, showSettings, hasConsumerSettingsMenu, aria
40
41
  }, []);
41
42
  const totalSize = table.getTotalSize();
42
43
  const tableWidth = Math.max(containerWidth, totalSize);
44
+ const hasTextDescription = table.getAllLeafColumns().some((col)=>col.columnDef.meta?.description?.type === 'text');
45
+ const headerHeight = hasTextDescription ? 48 : 32;
43
46
  const tableStyles = 'table-fixed border-separate border-spacing-0';
44
47
  return /*#__PURE__*/ jsxs("div", {
45
48
  ref: rootRef,
@@ -73,6 +76,10 @@ const TableInnerWindow = ({ isEmpty, showSettings, hasConsumerSettingsMenu, aria
73
76
  ]
74
77
  })
75
78
  }),
79
+ hasSubRowGrouping && /*#__PURE__*/ jsx(StickyGroupParent, {
80
+ tableWidth: tableWidth,
81
+ headerHeight: headerHeight
82
+ }),
76
83
  /*#__PURE__*/ jsxs("table", {
77
84
  className: tableStyles,
78
85
  style: {
@@ -1,22 +1,33 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { memo } from "react";
2
+ import { memo, useCallback } from "react";
3
3
  import { cn } from "../../utils/cn.js";
4
4
  import { useTestId } from "../../utils/testId.js";
5
- import { TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID } from "./lib/index.js";
5
+ import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID, useRowDnd } from "./lib/index.js";
6
6
  import { Td, Tr } from "./primitives/index.js";
7
7
  import { TableBodyCell } from "./TableBody/TableBodyCell.js";
8
8
  import { useTableContext } from "./TableContext/index.js";
9
9
  import { TableRowExpanded } from "./TableRowExpanded.js";
10
10
  const SYSTEM_COLUMN_IDS = new Set([
11
11
  TABLE_EXPAND_COLUMN_ID,
12
- TABLE_SELECT_COLUMN_ID
12
+ TABLE_SELECT_COLUMN_ID,
13
+ TABLE_DRAG_HANDLE_COLUMN_ID
13
14
  ]);
14
15
  const TableRowInner = ({ row, ref, 'data-index': dataIndex })=>{
15
16
  const { expandingEnabled, activeRowId } = useTableContext();
16
17
  const testId = useTestId('row');
18
+ const { canDnd, isDragging, setNodeRef, style: dndStyle, attributes, listeners } = useRowDnd(row);
17
19
  const isGroupParent = row.subRows.length > 0;
18
20
  const isSelected = isGroupParent ? row.getIsAllSubRowsSelected() : row.getIsSelected();
19
21
  const isPreviewActive = activeRowId === row.id;
22
+ const composedRef = useCallback((node)=>{
23
+ if (canDnd) setNodeRef(node);
24
+ if ('function' == typeof ref) ref(node);
25
+ else if (ref) ref.current = node;
26
+ }, [
27
+ canDnd,
28
+ setNodeRef,
29
+ ref
30
+ ]);
20
31
  if (isGroupParent) {
21
32
  const cells = row.getVisibleCells();
22
33
  const systemCells = cells.filter((c)=>SYSTEM_COLUMN_IDS.has(c.column.id));
@@ -25,7 +36,7 @@ const TableRowInner = ({ row, ref, 'data-index': dataIndex })=>{
25
36
  return /*#__PURE__*/ jsxs(Fragment, {
26
37
  children: [
27
38
  /*#__PURE__*/ jsxs(Tr, {
28
- ref: ref,
39
+ ref: composedRef,
29
40
  "data-index": dataIndex,
30
41
  "data-row-id": row.id,
31
42
  "data-testid": testId,
@@ -61,21 +72,29 @@ const TableRowInner = ({ row, ref, 'data-index': dataIndex })=>{
61
72
  return /*#__PURE__*/ jsxs(Fragment, {
62
73
  children: [
63
74
  /*#__PURE__*/ jsx(Tr, {
64
- ref: ref,
75
+ ref: composedRef,
65
76
  "data-index": dataIndex,
66
77
  "data-row-id": row.id,
67
78
  "data-testid": testId,
68
79
  className: "group/row",
69
80
  "data-selected": isSelected || void 0,
70
81
  "data-preview-active": isPreviewActive || void 0,
82
+ "data-dragging": isDragging || void 0,
71
83
  "aria-selected": isSelected || void 0,
72
84
  "data-depth": row.depth > 0 ? row.depth : void 0,
73
- children: row.getVisibleCells().map((cell)=>/*#__PURE__*/ jsx(TableBodyCell, {
74
- cell: cell
75
- }, cell.id))
85
+ style: dndStyle,
86
+ children: row.getVisibleCells().map((cell)=>{
87
+ const isDragHandle = cell.column.id === TABLE_DRAG_HANDLE_COLUMN_ID;
88
+ return /*#__PURE__*/ jsx(TableBodyCell, {
89
+ cell: cell,
90
+ dragListeners: isDragHandle ? listeners : void 0,
91
+ dragAttributes: isDragHandle ? attributes : void 0
92
+ }, cell.id);
93
+ })
76
94
  }),
77
95
  expandingEnabled && /*#__PURE__*/ jsx(TableRowExpanded, {
78
- row: row
96
+ row: row,
97
+ dndStyle: dndStyle
79
98
  })
80
99
  ]
81
100
  });
@@ -1,9 +1,12 @@
1
+ import type { CSSProperties } from 'react';
1
2
  import type { Row, RowData } from '@tanstack/react-table';
2
3
  import { type DSTableFeatures } from './lib';
3
4
  interface TableRowExpandedProps<T extends RowData> {
4
5
  row: Row<DSTableFeatures, T>;
6
+ /** When row DnD is active, pass the same transform style so expanded content moves with its parent row. */
7
+ dndStyle?: CSSProperties;
5
8
  }
6
- export declare function TableRowExpanded<T extends RowData>({ row }: TableRowExpandedProps<T>): import("react").JSX.Element | null;
9
+ export declare function TableRowExpanded<T extends RowData>({ row, dndStyle, }: TableRowExpandedProps<T>): import("react").JSX.Element | null;
7
10
  export declare namespace TableRowExpanded {
8
11
  var displayName: string;
9
12
  }
@@ -3,7 +3,7 @@ import { useTestId } from "../../utils/testId.js";
3
3
  import { TABLE_EXPAND_COLUMN_ID } from "./lib/index.js";
4
4
  import { Td, Tr } from "./primitives/index.js";
5
5
  import { useTableContext } from "./TableContext/index.js";
6
- const TableRowExpanded = ({ row })=>{
6
+ const TableRowExpanded = ({ row, dndStyle })=>{
7
7
  const { table, renderExpandedRow } = useTableContext();
8
8
  const testId = useTestId('row-expanded');
9
9
  if (!row.getIsExpanded() || !renderExpandedRow) return null;
@@ -12,6 +12,7 @@ const TableRowExpanded = ({ row })=>{
12
12
  const contentColSpan = hasExpandColumn ? visibleColumns.length - 1 : visibleColumns.length;
13
13
  return /*#__PURE__*/ jsxs(Tr, {
14
14
  "data-testid": testId,
15
+ style: dndStyle,
15
16
  children: [
16
17
  hasExpandColumn && /*#__PURE__*/ jsx(Td, {
17
18
  className: "border-b-0 border-r border-border-primary-light bg-bg-surface-2 sticky left-0"
@@ -11,7 +11,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuFooter, DropdownMenuLabe
11
11
  import { Separator } from "../../Separator/index.js";
12
12
  import { VStack } from "../../Stack/index.js";
13
13
  import { Tooltip, TooltipContent, TooltipTrigger } from "../../Tooltip/index.js";
14
- import { TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID, collectDirectChildren } from "../lib/index.js";
14
+ import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID, collectDirectChildren } from "../lib/index.js";
15
15
  import { useTableContext } from "../TableContext/index.js";
16
16
  import { TableSettingsMenuContentProvider } from "./TableSettingsMenuContentContext.js";
17
17
  import { useTableSettingsMenuContext } from "./TableSettingsMenuContext.js";
@@ -47,7 +47,7 @@ const TableSettingsMenu = ({ 'data-testid': testIdProp, children, ...rest })=>{
47
47
  }, [
48
48
  menuOpen
49
49
  ]);
50
- const allColumns = table.getAllLeafColumns().filter((col)=>col.id !== TABLE_SELECT_COLUMN_ID && col.id !== TABLE_EXPAND_COLUMN_ID);
50
+ const allColumns = table.getAllLeafColumns().filter((col)=>col.id !== TABLE_SELECT_COLUMN_ID && col.id !== TABLE_EXPAND_COLUMN_ID && col.id !== TABLE_DRAG_HANDLE_COLUMN_ID);
51
51
  const filteredColumns = useMemo(()=>{
52
52
  if (!search) return allColumns;
53
53
  const lower = search.toLowerCase();
@@ -1,4 +1,5 @@
1
1
  export { useInfiniteScroll } from './infiniteScroll';
2
2
  export { useHorizontalScrollState } from './useHorizontalScrollState';
3
3
  export { useMasterCell } from './useMasterCell';
4
+ export { useStickyGroupParent } from './useStickyGroupParent';
4
5
  export { useTableState } from './useTableState';
@@ -1,4 +1,5 @@
1
1
  export { useInfiniteScroll } from "./infiniteScroll/index.js";
2
2
  export { useHorizontalScrollState } from "./useHorizontalScrollState.js";
3
3
  export { useMasterCell } from "./useMasterCell.js";
4
+ export { useStickyGroupParent } from "./useStickyGroupParent.js";
4
5
  export { useTableState } from "./useTableState.js";
@@ -0,0 +1,19 @@
1
+ import { type RefObject } from 'react';
2
+ import type { ReactTable, Row, RowData } from '@tanstack/react-table';
3
+ import type { DSTableFeatures } from '../lib';
4
+ import type { TableVirtualizerInstance } from '../TableContext/types';
5
+ export interface StickyGroupParentResult<T extends RowData> {
6
+ stickyRow: Row<DSTableFeatures, T> | null;
7
+ pushUpOffset: number;
8
+ }
9
+ interface UseStickyGroupParentOptions {
10
+ table: ReactTable<DSTableFeatures, RowData>;
11
+ scrollElementRef: RefObject<HTMLElement | null>;
12
+ useWindowScroll: boolean;
13
+ headerHeight: number;
14
+ tbodyRef: RefObject<HTMLTableSectionElement | null>;
15
+ virtualizerRef: RefObject<TableVirtualizerInstance | null>;
16
+ enabled: boolean;
17
+ }
18
+ export declare const useStickyGroupParent: <T extends RowData>(options: UseStickyGroupParentOptions) => StickyGroupParentResult<T>;
19
+ export {};