@cognite/aura 1.46385.0 → 1.46447.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 (28) hide show
  1. package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +0 -2
  2. package/dist/components/ui/core/data-grid/data-grid-cell.js +3 -7
  3. package/dist/components/ui/core/data-grid/data-grid-cell.js.map +1 -1
  4. package/dist/components/ui/core/data-grid/data-grid-column-resizer.d.ts +8 -0
  5. package/dist/components/ui/core/data-grid/data-grid-column-resizer.js +24 -0
  6. package/dist/components/ui/core/data-grid/data-grid-column-resizer.js.map +1 -0
  7. package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +3 -4
  8. package/dist/components/ui/core/data-grid/data-grid-header-row.js +47 -28
  9. package/dist/components/ui/core/data-grid/data-grid-header-row.js.map +1 -1
  10. package/dist/components/ui/core/data-grid/data-grid-row.d.ts +1 -4
  11. package/dist/components/ui/core/data-grid/data-grid-row.js +25 -16
  12. package/dist/components/ui/core/data-grid/data-grid-row.js.map +1 -1
  13. package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.d.ts +11 -0
  14. package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.js +128 -0
  15. package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.js.map +1 -0
  16. package/dist/components/ui/core/data-grid/data-grid-selection.types.d.ts +24 -0
  17. package/dist/components/ui/core/data-grid/data-grid-selection.types.js +3 -0
  18. package/dist/components/ui/core/data-grid/data-grid-selection.types.js.map +1 -0
  19. package/dist/components/ui/core/data-grid/data-grid.d.ts +9 -2
  20. package/dist/components/ui/core/data-grid/data-grid.js +165 -168
  21. package/dist/components/ui/core/data-grid/data-grid.js.map +1 -1
  22. package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +1 -4
  23. package/dist/components/ui/core/data-grid/data-grid.utils.js +5 -38
  24. package/dist/components/ui/core/data-grid/data-grid.utils.js.map +1 -1
  25. package/dist/components/ui/core/data-grid/index.d.ts +1 -0
  26. package/dist/components/ui/core/data-grid/index.js.map +1 -1
  27. package/dist/styles.css +1 -1
  28. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RowSelectionState } from "@tanstack/react-table";
3
+ type DataGridSelectionActionClick = (rowSelection: RowSelectionState) => void;
4
+ type DataGridSelectionAction = {
5
+ label: string;
6
+ icon?: ReactNode;
7
+ onClick: DataGridSelectionActionClick;
8
+ };
9
+ type DataGridSecondaryAction = {
10
+ onClick: DataGridSelectionActionClick;
11
+ } & ({
12
+ label: string;
13
+ icon?: ReactNode;
14
+ } | {
15
+ icon: ReactNode;
16
+ label?: undefined;
17
+ "aria-label": string;
18
+ });
19
+ type DataGridSelectionActions = {
20
+ primaryAction?: DataGridSelectionAction;
21
+ secondaryActions?: readonly DataGridSecondaryAction[];
22
+ menuActions?: readonly DataGridSelectionAction[];
23
+ };
24
+ export type { DataGridSecondaryAction, DataGridSelectionAction, DataGridSelectionActions };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=data-grid-selection.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection.types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { RowSelectionState } from '@tanstack/react-table';\n\n// The grid passes the current selection.\ntype DataGridSelectionActionClick = (rowSelection: RowSelectionState) => void;\n\ntype DataGridSelectionAction = {\n label: string;\n icon?: ReactNode;\n onClick: DataGridSelectionActionClick;\n};\n\ntype DataGridSecondaryAction = {\n onClick: DataGridSelectionActionClick;\n} & (\n | { label: string; icon?: ReactNode }\n | { icon: ReactNode; label?: undefined; 'aria-label': string }\n);\n\ntype DataGridSelectionActions = {\n primaryAction?: DataGridSelectionAction;\n secondaryActions?: readonly DataGridSecondaryAction[];\n menuActions?: readonly DataGridSelectionAction[];\n};\n\nexport type {\n DataGridSecondaryAction,\n DataGridSelectionAction,\n DataGridSelectionActions,\n};\n"],"names":[],"mappings":"AA0BA,WAIE"}
@@ -1,7 +1,8 @@
1
1
  import { type ComponentProps, type ComponentRef, type ForwardRefExoticComponent, type ReactElement, type ReactNode, type RefAttributes, type RefObject } from "react";
2
- import { type ColumnDef, type ExpandedState, type FilterFnOption, type PaginationState, type Row, type RowSelectionState, type Table, type SortingState } from "@tanstack/react-table";
2
+ import { type ColumnDef, type ColumnSizingState, type ExpandedState, type FilterFnOption, type PaginationState, type Row, type RowSelectionState, type Table, type SortingState } from "@tanstack/react-table";
3
3
  import { Button } from "../button/button";
4
4
  import { Search } from "../search/search";
5
+ import type { DataGridSelectionActions } from "./data-grid-selection.types";
5
6
  type DataGridContextValue = {
6
7
  searchValue: string;
7
8
  setSearchValue: (value: string) => void;
@@ -45,11 +46,17 @@ type DataGridBaseProps<TData> = {
45
46
  globalFilterFn?: FilterFnOption<TData>;
46
47
  enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
47
48
  enableSorting?: boolean;
49
+ enableColumnResizing?: boolean;
50
+ columnGrow?: boolean;
51
+ columnSizing?: ColumnSizingState;
52
+ defaultColumnSizing?: ColumnSizingState;
53
+ onColumnSizingChange?: (value: ColumnSizingState) => void;
48
54
  manualPagination?: boolean;
49
55
  manualSorting?: boolean;
50
56
  rowSelection?: RowSelectionState;
51
57
  defaultRowSelection?: RowSelectionState;
52
58
  onRowSelectionChange?: (value: RowSelectionState) => void;
59
+ selectionActions?: DataGridSelectionActions;
53
60
  sorting?: SortingState;
54
61
  defaultSorting?: SortingState;
55
62
  onSortingChange?: (value: SortingState) => void;
@@ -94,7 +101,7 @@ type DataGridAccessibleNameProps = {
94
101
  "aria-label"?: string;
95
102
  };
96
103
  type DataGridProps<TData> = DataGridBaseProps<TData> & DataGridAccessibleNameProps;
97
- declare function DataGrid<TData>({ data, columns, getRowId, rowCount, globalFilterFn, enableRowSelection, enableSorting, manualPagination, manualSorting, rowSelection, defaultRowSelection, onRowSelectionChange, sorting, defaultSorting, onSortingChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth, pinnedColumns, gridRef, size, children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode, loading, loadingVariant, loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: DataGridProps<TData>): ReactElement;
104
+ declare function DataGrid<TData>({ data, columns, getRowId, rowCount, globalFilterFn, enableRowSelection, enableSorting, enableColumnResizing, columnGrow, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination, manualSorting, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth, pinnedColumns, gridRef, size, children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode, loading, loadingVariant, loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: DataGridProps<TData>): ReactElement;
98
105
  declare function DataGridCheckboxHeader<TData>({ table }: {
99
106
  table: Table<TData>;
100
107
  }): ReactElement;
@@ -13,10 +13,23 @@ import { Skeleton } from "../skeleton/skeleton.js";
13
13
  import { DataGridCell } from "./data-grid-cell.js";
14
14
  import { DataGridHeaderRow } from "./data-grid-header-row.js";
15
15
  import { DataGridRow } from "./data-grid-row.js";
16
- import { getDataGridCheckboxState, selectDataGridRowTree } from "./data-grid-selection-state.js";
17
- import { collectCustomCellColumnIds, getPinnedColumnStyle } from "./data-grid.utils.js";
16
+ import { countSelectedRowIds, getDataGridCheckboxState, selectDataGridRowTree } from "./data-grid-selection-state.js";
17
+ import { DataGridSelectionToolbar } from "./data-grid-selection-toolbar.js";
18
+ import { PINNED_COLUMN_Z_INDEX, getTextValue } from "./data-grid.utils.js";
18
19
  const EMPTY_PINNED_COLUMNS = [];
19
- const DEFAULT_FLEXIBLE_COLUMN_WIDTH = 120;
20
+ function defaultDataGridCell({ renderValue }) {
21
+ const text = getTextValue(renderValue());
22
+ if (text === undefined) return null;
23
+ return /*#__PURE__*/ _jsx("span", {
24
+ className: "block min-w-0 truncate",
25
+ title: text,
26
+ children: text
27
+ });
28
+ }
29
+ const DEFAULT_COLUMN = {
30
+ cell: defaultDataGridCell,
31
+ size: undefined
32
+ };
20
33
  const DataGridContext = /*#__PURE__*/ createContext(undefined);
21
34
  const defaultDataGridLabels = {
22
35
  clearSearch: 'Clear search',
@@ -30,7 +43,7 @@ const HEADER_HEIGHT_MAP = {
30
43
  default: 36,
31
44
  compact: 32
32
45
  };
33
- function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto', enableRowSelection = false, enableSorting = false, manualPagination = false, manualSorting = false, rowSelection, defaultRowSelection, onRowSelectionChange, sorting, defaultSorting, onSortingChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth = 5, pinnedColumns = EMPTY_PINNED_COLUMNS, gridRef, size = 'default', children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode = 'client', loading = false, loadingVariant = 'skeleton', loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }) {
46
+ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto', enableRowSelection = false, enableSorting = false, enableColumnResizing = false, columnGrow = false, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination = false, manualSorting = false, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth = 5, pinnedColumns = EMPTY_PINNED_COLUMNS, gridRef, size = 'default', children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode = 'client', loading = false, loadingVariant = 'skeleton', loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }) {
34
47
  const scrollContainerRef = useRef(null);
35
48
  const labels = {
36
49
  ...defaultDataGridLabels,
@@ -66,6 +79,11 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
66
79
  defaultProp: defaultExpanded ?? {},
67
80
  onChange: onExpandedChange
68
81
  });
82
+ const [resolvedColumnSizing, setResolvedColumnSizing] = useControllableState({
83
+ prop: columnSizing,
84
+ defaultProp: defaultColumnSizing ?? {},
85
+ onChange: onColumnSizingChange
86
+ });
69
87
  const isClientSorting = enableSorting && !manualSorting;
70
88
  const isClientPagination = hasPagination && !manualPagination;
71
89
  useSearchPaginationReset(resolvedSearchValue, hasPagination, setResolvedPagination);
@@ -79,9 +97,6 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
79
97
  pinnedColumns
80
98
  ]);
81
99
  const lastPinnedColumnId = pinnedColumns[pinnedColumns.length - 1];
82
- const customCellColumnIds = useMemo(()=>collectCustomCellColumnIds(columns), [
83
- columns
84
- ]);
85
100
  // eslint-disable-next-line react-hooks/incompatible-library -- useReactTable in the DataGrid component is intentional and stable.
86
101
  const table = useReactTable({
87
102
  data,
@@ -91,6 +106,7 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
91
106
  globalFilter: resolvedSearchValue,
92
107
  sorting: resolvedSorting,
93
108
  rowSelection: resolvedRowSelection,
109
+ columnSizing: resolvedColumnSizing,
94
110
  ...hasPagination ? {
95
111
  pagination: resolvedPagination
96
112
  } : {},
@@ -100,6 +116,7 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
100
116
  },
101
117
  onSortingChange: setResolvedSorting,
102
118
  onRowSelectionChange: setResolvedRowSelection,
119
+ onColumnSizingChange: setResolvedColumnSizing,
103
120
  ...hasPagination ? {
104
121
  onPaginationChange: setResolvedPagination
105
122
  } : {},
@@ -116,6 +133,9 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
116
133
  // Selecting a parent selects every descendant, including while it is collapsed.
117
134
  enableSubRowSelection: true,
118
135
  enableSorting,
136
+ enableColumnResizing,
137
+ columnResizeMode: 'onChange',
138
+ defaultColumn: DEFAULT_COLUMN,
119
139
  manualPagination,
120
140
  manualSorting,
121
141
  manualFiltering: queryMode === 'server',
@@ -137,7 +157,6 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
137
157
  });
138
158
  const { rows } = table.getRowModel();
139
159
  const headerGroups = table.getHeaderGroups();
140
- const allColumns = table.getAllColumns();
141
160
  const visibleColumns = table.getVisibleFlatColumns();
142
161
  const resolvedRowHeight = rowHeight ?? ROW_HEIGHT_MAP[size];
143
162
  const resolvedHeaderHeight = headerHeight ?? HEADER_HEIGHT_MAP[size];
@@ -164,61 +183,28 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
164
183
  resetSelection: ()=>setResolvedRowSelection({}),
165
184
  resetSearch: ()=>setResolvedSearchValue('')
166
185
  }));
167
- useEffect(()=>{
168
- for (const pinnedId of pinnedColumns){
169
- const pinnedColumn = allColumns.find((column)=>column.id === pinnedId);
170
- if (pinnedColumn && pinnedColumn.columnDef.size === undefined) {
171
- console.warn(`[Aura DataGrid] Pinned column "${pinnedId}" has no \`size\` set. ` + 'Pinned columns must declare an explicit `size` to keep the sticky ' + 'offset aligned with the rendered column width.');
172
- }
186
+ const hasFlexibleColumn = !enableColumnResizing && !columnGrow && visibleColumns.some((column)=>column.columnDef.size === undefined && !pinnedColumnIds.has(column.id));
187
+ const gridTemplateColumns = visibleColumns.map((column, index)=>{
188
+ const columnSize = column.getSize();
189
+ if (enableColumnResizing || pinnedColumnIds.has(column.id)) {
190
+ return `${columnSize}px`;
173
191
  }
174
- }, [
175
- pinnedColumns,
176
- allColumns
177
- ]);
178
- const gridTemplateColumns = useMemo(()=>{
179
- const hasFlexibleColumn = visibleColumns.some((col)=>col.columnDef.size === undefined && !pinnedColumnIds.has(col.id));
180
- return visibleColumns.map((col, index)=>{
181
- const colSize = col.columnDef.size;
182
- const isLastColumn = index === visibleColumns.length - 1;
183
- const isPinned = pinnedColumnIds.has(col.id);
184
- // Pinned columns must render at a fixed pixel width so the cumulative
185
- // sticky `left` offset agrees with the actually-rendered column width.
186
- // `minmax(..., 1fr)` would let the column flex and break alignment.
187
- if (isPinned) {
188
- return `${colSize ?? DEFAULT_FLEXIBLE_COLUMN_WIDTH}px`;
189
- }
190
- if (colSize !== undefined) {
191
- if (!hasFlexibleColumn && isLastColumn) {
192
- return `minmax(${colSize}px, 1fr)`;
193
- }
194
- return `${colSize}px`;
192
+ if (columnGrow) {
193
+ return `minmax(${columnSize}px, ${columnSize}fr)`;
194
+ }
195
+ const isLastColumn = index === visibleColumns.length - 1;
196
+ if (column.columnDef.size !== undefined) {
197
+ if (!hasFlexibleColumn && isLastColumn) {
198
+ return `minmax(${columnSize}px, 1fr)`;
195
199
  }
196
- return `minmax(${DEFAULT_FLEXIBLE_COLUMN_WIDTH}px, 1fr)`;
197
- }).join(' ');
198
- }, [
199
- visibleColumns,
200
- pinnedColumnIds
201
- ]);
202
- const pinnedLeftByColumnId = useMemo(()=>{
203
- const leftById = new Map();
204
- let cumulativeLeft = 0;
205
- for (const pinnedId of pinnedColumns){
206
- const pinnedColumn = visibleColumns.find((column)=>column.id === pinnedId);
207
- // Skip pinned columns that are currently hidden — they don't render
208
- // and shouldn't contribute to the cumulative sticky `left` offset for
209
- // subsequent visible pinned columns.
210
- if (!pinnedColumn) continue;
211
- leftById.set(pinnedId, cumulativeLeft);
212
- // Read `columnDef.size` (not `getSize()`) so the fallback matches the
213
- // gridTemplateColumns track size; `getSize()` falls back to TanStack's
214
- // 150px default which would desync from `DEFAULT_FLEXIBLE_COLUMN_WIDTH`.
215
- cumulativeLeft += pinnedColumn.columnDef.size ?? DEFAULT_FLEXIBLE_COLUMN_WIDTH;
200
+ return `${columnSize}px`;
216
201
  }
217
- return leftById;
218
- }, [
219
- visibleColumns,
220
- pinnedColumns
221
- ]);
202
+ return `minmax(${columnSize}px, 1fr)`;
203
+ }).join(' ');
204
+ const scrollContainerStyle = {
205
+ '--data-grid-template-columns': gridTemplateColumns
206
+ };
207
+ const isResizingColumn = Boolean(table.getState().columnSizingInfo.isResizingColumn);
222
208
  const clientFilteredCount = table.getFilteredRowModel().rows.length;
223
209
  const clientTotalCount = table.getCoreRowModel().rows.length;
224
210
  const contextValue = useMemo(()=>({
@@ -235,6 +221,7 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
235
221
  clientTotalCount,
236
222
  totalResultCount
237
223
  ]);
224
+ const selectedRowCount = countSelectedRowIds(resolvedRowSelection);
238
225
  return /*#__PURE__*/ _jsx(DataGridContext.Provider, {
239
226
  value: contextValue,
240
227
  children: /*#__PURE__*/ _jsxs("div", {
@@ -245,127 +232,137 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
245
232
  className: cn('relative flex min-h-0 w-full flex-col overflow-clip rounded-xl text-sm', className),
246
233
  children: [
247
234
  children,
248
- /*#__PURE__*/ _jsx("div", {
235
+ /*#__PURE__*/ _jsxs("div", {
249
236
  ref: scrollContainerRef,
250
237
  "data-slot": "data-grid-scroll-container",
251
238
  className: "relative order-2 min-h-0 w-full flex-1 overflow-auto",
239
+ style: scrollContainerStyle,
252
240
  role: "table",
253
241
  "aria-rowcount": hideRowsForLoading ? headerGroups.length : (rowCount ?? rows.length) + headerGroups.length,
254
242
  "aria-colcount": visibleColumns.length,
255
243
  "aria-label": ariaLabel,
256
244
  "aria-labelledby": ariaLabelledBy,
257
- children: /*#__PURE__*/ _jsxs("div", {
258
- className: "min-w-fit w-full",
259
- children: [
260
- /*#__PURE__*/ _jsx("div", {
261
- role: "rowgroup",
262
- "data-slot": "data-grid-header-group",
263
- className: "contents",
264
- children: headerGroups.map((headerGroup, headerRowIndex)=>/*#__PURE__*/ _jsx(DataGridHeaderRow, {
265
- headerGroup: headerGroup,
266
- headerRowIndex: headerRowIndex,
267
- resolvedHeaderHeight: resolvedHeaderHeight,
268
- gridTemplateColumns: gridTemplateColumns,
269
- pinnedColumnIds: pinnedColumnIds,
270
- lastPinnedColumnId: lastPinnedColumnId,
271
- pinnedLeftByColumnId: pinnedLeftByColumnId
272
- }, headerGroup.id))
273
- }),
274
- /*#__PURE__*/ _jsxs("div", {
275
- role: "rowgroup",
276
- "data-slot": "data-grid-body",
277
- className: cn('relative min-h-(--data-grid-body-min-height)', !hasNoRows && !hasNoResults && 'h-(--data-grid-body-height)'),
278
- style: bodyStyle,
279
- children: [
280
- shouldRenderSkeleton && Array.from({
281
- length: resolvedLoadingRowCount
282
- }, (_, rowIndex)=>/*#__PURE__*/ _jsx("div", {
283
- "data-slot": "data-grid-row-loading",
284
- "aria-hidden": "true",
285
- className: "absolute left-0 right-0 grid border-b bg-background",
286
- style: {
287
- gridTemplateColumns,
288
- height: resolvedRowHeight,
289
- transform: `translateY(${rowIndex * resolvedRowHeight}px)`
290
- },
291
- children: visibleColumns.map((column, colIndex)=>{
292
- const isPinned = pinnedColumnIds.has(column.id);
293
- const isLastPinned = isPinned && lastPinnedColumnId === column.id;
294
- return /*#__PURE__*/ _jsx(DataGridCell, {
295
- isPinned: isPinned,
296
- isLastPinned: isLastPinned,
297
- colIndex: colIndex + 1,
298
- truncate: false,
299
- style: getPinnedColumnStyle(isPinned, column.id, pinnedLeftByColumnId),
300
- children: renderLoadingCell?.({
301
- rowIndex,
302
- columnId: column.id,
303
- columnIndex: colIndex,
304
- size
305
- }) ?? (column.id === 'select' ? /*#__PURE__*/ _jsx(Skeleton, {
306
- className: "h-4 w-4 rounded"
307
- }) : /*#__PURE__*/ _jsx(Skeleton, {
308
- className: cn('h-4 max-w-full', colIndex === 0 ? 'w-3/4' : 'w-2/3')
309
- }))
310
- }, column.id);
311
- })
312
- }, `skeleton-row-${rowIndex}`)),
313
- !hideRowsForLoading && !hasNoRows && !hasNoResults && virtualizer.getVirtualItems().map((virtualRow)=>/*#__PURE__*/ _jsx(DataGridRow, {
314
- row: rows[virtualRow.index],
315
- virtualRow: virtualRow,
316
- headerGroupCount: headerGroups.length,
317
- gridTemplateColumns: gridTemplateColumns,
245
+ children: [
246
+ /*#__PURE__*/ _jsxs("div", {
247
+ className: cn('min-w-fit w-full', enableRowSelection !== false && selectedRowCount > 0 && 'pb-24'),
248
+ children: [
249
+ /*#__PURE__*/ _jsx("div", {
250
+ role: "rowgroup",
251
+ "data-slot": "data-grid-header-group",
252
+ className: "contents",
253
+ children: headerGroups.map((headerGroup, headerRowIndex)=>/*#__PURE__*/ _jsx(DataGridHeaderRow, {
254
+ headerGroup: headerGroup,
255
+ headerRowIndex: headerRowIndex,
256
+ resolvedHeaderHeight: resolvedHeaderHeight,
318
257
  pinnedColumnIds: pinnedColumnIds,
319
258
  lastPinnedColumnId: lastPinnedColumnId,
320
- pinnedLeftByColumnId: pinnedLeftByColumnId,
321
- customCellColumnIds: customCellColumnIds,
322
- maxDepth: maxDepth,
323
- hasExpanding: hasExpanding,
324
- onRowClick: onRowClick
325
- }, rows[virtualRow.index].id)),
326
- !loading && hasNoRows && emptyState != null && /*#__PURE__*/ _jsx("div", {
327
- className: "pt-2",
328
- children: /*#__PURE__*/ _jsx("div", {
329
- className: "flex items-center justify-center rounded-lg bg-medium-background",
330
- children: renderDataGridState(emptyState, {
331
- type: 'new-object',
332
- title: 'No rows yet',
333
- description: 'Add data to populate this table.'
259
+ isResizingColumn: isResizingColumn
260
+ }, headerGroup.id))
261
+ }),
262
+ /*#__PURE__*/ _jsxs("div", {
263
+ role: "rowgroup",
264
+ "data-slot": "data-grid-body",
265
+ className: cn('relative min-h-(--data-grid-body-min-height)', !hasNoRows && !hasNoResults && 'h-(--data-grid-body-height)'),
266
+ style: bodyStyle,
267
+ children: [
268
+ shouldRenderSkeleton && Array.from({
269
+ length: resolvedLoadingRowCount
270
+ }, (_, rowIndex)=>/*#__PURE__*/ _jsx("div", {
271
+ "data-slot": "data-grid-row-loading",
272
+ "aria-hidden": "true",
273
+ className: "absolute left-0 right-0 grid border-b bg-background",
274
+ style: {
275
+ gridTemplateColumns: 'var(--data-grid-template-columns)',
276
+ height: resolvedRowHeight,
277
+ transform: `translateY(${rowIndex * resolvedRowHeight}px)`
278
+ },
279
+ children: visibleColumns.map((column, colIndex)=>{
280
+ const isPinned = pinnedColumnIds.has(column.id);
281
+ const isLastPinned = isPinned && lastPinnedColumnId === column.id;
282
+ return /*#__PURE__*/ _jsx(DataGridCell, {
283
+ isPinned: isPinned,
284
+ isLastPinned: isLastPinned,
285
+ colIndex: colIndex + 1,
286
+ style: isPinned ? {
287
+ position: 'sticky',
288
+ left: column.getStart('left'),
289
+ zIndex: PINNED_COLUMN_Z_INDEX
290
+ } : undefined,
291
+ children: renderLoadingCell?.({
292
+ rowIndex,
293
+ columnId: column.id,
294
+ columnIndex: colIndex,
295
+ size
296
+ }) ?? (column.id === 'select' ? /*#__PURE__*/ _jsx(Skeleton, {
297
+ className: "h-4 w-4 rounded"
298
+ }) : /*#__PURE__*/ _jsx(Skeleton, {
299
+ className: cn('h-4 max-w-full', colIndex === 0 ? 'w-3/4' : 'w-2/3')
300
+ }))
301
+ }, column.id);
302
+ })
303
+ }, `skeleton-row-${rowIndex}`)),
304
+ !hideRowsForLoading && !hasNoRows && !hasNoResults && virtualizer.getVirtualItems().map((virtualRow)=>/*#__PURE__*/ _jsx(DataGridRow, {
305
+ row: rows[virtualRow.index],
306
+ virtualRow: virtualRow,
307
+ headerGroupCount: headerGroups.length,
308
+ pinnedColumnIds: pinnedColumnIds,
309
+ lastPinnedColumnId: lastPinnedColumnId,
310
+ maxDepth: maxDepth,
311
+ hasExpanding: hasExpanding,
312
+ onRowClick: onRowClick
313
+ }, rows[virtualRow.index].id)),
314
+ !loading && hasNoRows && emptyState != null && /*#__PURE__*/ _jsx("div", {
315
+ className: "pt-2",
316
+ children: /*#__PURE__*/ _jsx("div", {
317
+ className: "flex items-center justify-center rounded-lg bg-medium-background",
318
+ children: renderDataGridState(emptyState, {
319
+ type: 'new-object',
320
+ title: 'No rows yet',
321
+ description: 'Add data to populate this table.'
322
+ })
334
323
  })
335
- })
336
- }),
337
- !loading && hasNoResults && /*#__PURE__*/ _jsx("div", {
338
- className: "pt-2",
339
- children: /*#__PURE__*/ _jsx("div", {
340
- className: "flex items-center justify-center bg-background",
341
- children: renderDataGridState(noResultsState, {
342
- type: 'no-results',
343
- title: 'No results found',
344
- description: queryMode === 'server' ? 'Apply a different query or clear filters.' : 'Try a different search term or clear filters.',
345
- action: onClearSearch || onClearFilters ? /*#__PURE__*/ _jsxs("div", {
346
- className: "mt-2 flex items-center justify-center gap-2",
347
- children: [
348
- onClearSearch ? /*#__PURE__*/ _jsx(Button, {
349
- size: "sm",
350
- variant: "secondary",
351
- onClick: onClearSearch,
352
- children: labels.clearSearch
353
- }) : null,
354
- onClearFilters ? /*#__PURE__*/ _jsx(Button, {
355
- size: "sm",
356
- variant: "secondary",
357
- onClick: onClearFilters,
358
- children: labels.clearFilters
359
- }) : null
360
- ]
361
- }) : undefined
324
+ }),
325
+ !loading && hasNoResults && /*#__PURE__*/ _jsx("div", {
326
+ className: "pt-2",
327
+ children: /*#__PURE__*/ _jsx("div", {
328
+ className: "flex items-center justify-center bg-background",
329
+ children: renderDataGridState(noResultsState, {
330
+ type: 'no-results',
331
+ title: 'No results found',
332
+ description: queryMode === 'server' ? 'Apply a different query or clear filters.' : 'Try a different search term or clear filters.',
333
+ action: onClearSearch || onClearFilters ? /*#__PURE__*/ _jsxs("div", {
334
+ className: "mt-2 flex items-center justify-center gap-2",
335
+ children: [
336
+ onClearSearch ? /*#__PURE__*/ _jsx(Button, {
337
+ size: "sm",
338
+ variant: "secondary",
339
+ onClick: onClearSearch,
340
+ children: labels.clearSearch
341
+ }) : null,
342
+ onClearFilters ? /*#__PURE__*/ _jsx(Button, {
343
+ size: "sm",
344
+ variant: "secondary",
345
+ onClick: onClearFilters,
346
+ children: labels.clearFilters
347
+ }) : null
348
+ ]
349
+ }) : undefined
350
+ })
362
351
  })
363
352
  })
364
- })
365
- ]
366
- })
367
- ]
368
- })
353
+ ]
354
+ })
355
+ ]
356
+ }),
357
+ enableRowSelection !== false ? /*#__PURE__*/ _jsx(DataGridSelectionToolbar, {
358
+ // The count includes every selected id.
359
+ // That covers parents and their children, rows on other pages, and rows hidden by search.
360
+ selectedCount: selectedRowCount,
361
+ rowSelection: resolvedRowSelection,
362
+ selectionActions: selectionActions,
363
+ onClear: ()=>setResolvedRowSelection({})
364
+ }) : null
365
+ ]
369
366
  })
370
367
  ]
371
368
  })