diff --git a/packages/features/users/components/UserTable/UserListTable.tsx b/packages/features/users/components/UserTable/UserListTable.tsx index b113f2a4d5..7e7670f37d 100644 --- a/packages/features/users/components/UserTable/UserListTable.tsx +++ b/packages/features/users/components/UserTable/UserListTable.tsx @@ -9,6 +9,7 @@ import { useReactTable, type ColumnDef, } from "@tanstack/react-table"; +import type { ColumnMeta } from "@tanstack/react-table"; import { useSession } from "next-auth/react"; import { useQueryState, parseAsBoolean } from "nuqs"; import { useMemo, useReducer, useRef, useState } from "react"; @@ -45,6 +46,11 @@ import { TableActions } from "./UserTableActions"; import type { UserTableState, UserTableAction, UserTableUser } from "./types"; import { useFetchMoreOnBottomReached } from "./useFetchMoreOnBottomReached"; +type CustomColumnMeta = ColumnMeta & { + sticky?: boolean; + stickLeft?: number; +}; + const initialState: UserTableState = { changeMemberRole: { showModal: false, @@ -186,6 +192,10 @@ export function UserListTable() { id: "select", enableHiding: false, enableSorting: false, + meta: { + sticky: true, + stickLeft: 0, + } as CustomColumnMeta, header: ({ table }) => ( { return `Members`; }, + meta: { + sticky: true, + stickyLeft: 24, + } as CustomColumnMeta, cell: ({ row }) => { const { username, email, avatarUrl } = row.original; return ( diff --git a/packages/ui/components/data-table/index.tsx b/packages/ui/components/data-table/index.tsx index c892e830d4..c07840f4e9 100644 --- a/packages/ui/components/data-table/index.tsx +++ b/packages/ui/components/data-table/index.tsx @@ -59,82 +59,102 @@ export function DataTable({ ...rest.style, }} data-testid={rest["data-testid"] ?? "data-table"}> -
-
-
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => ( - -
- {header.isPlaceholder - ? null - : flexRender(header.column.columnDef.header, header.getContext())} - {header.column.getIsSorted() && ( - - )} -
-
- ))} +
+
+ + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + const meta = header.column.columnDef.meta as { sticky?: boolean; stickyLeft?: number }; + return ( + +
+ {header.isPlaceholder + ? null + : flexRender(header.column.columnDef.header, header.getContext())} + {header.column.getIsSorted() && ( + + )} +
+
+ ); + })} +
+ ))} +
+ + {paddingTop > 0 && ( + + + )} + {virtualRows && !isPending ? ( + virtualRows.map((virtualRow) => { + const row = rows[virtualRow.index] as Row; + return ( + onRowMouseclick && onRowMouseclick(row)} + className={classNames( + onRowMouseclick && "hover:cursor-pointer", + variant === "compact" && "!border-0", + "group" + )}> + {row.getVisibleCells().map((cell) => { + const column = table.getColumn(cell.column.id); + const meta = column?.columnDef.meta as { sticky?: boolean; stickyLeft?: number }; + return ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ); + })} - ))} - - - {paddingTop > 0 && ( - - - )} - {virtualRows && !isPending ? ( - virtualRows.map((virtualRow) => { - const row = rows[virtualRow.index] as Row; - return ( - onRowMouseclick && onRowMouseclick(row)} - className={classNames( - onRowMouseclick && "hover:cursor-pointer", - variant === "compact" && "!border-0" - )}> - {row.getVisibleCells().map((cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - - ); - }) - ) : ( - - - No results. - - - )} - {paddingBottom > 0 && ( - - - )} - -
+
-
-
-
-
+ ); + }) + ) : ( + + + No results. + + + )} + {paddingBottom > 0 && ( + + + + )} + +
{children} diff --git a/packages/ui/components/data-table/tanstack.d.ts b/packages/ui/components/data-table/tanstack.d.ts new file mode 100644 index 0000000000..894448b6fe --- /dev/null +++ b/packages/ui/components/data-table/tanstack.d.ts @@ -0,0 +1,8 @@ +import "@tanstack/react-table"; + +declare module "@tanstack/react-table" { + interface ColumnMeta { + sticky?: boolean; + stickyLeft?: number; + } +} diff --git a/packages/ui/components/table/TableNew.tsx b/packages/ui/components/table/TableNew.tsx index ecdb234536..3791a4d76b 100644 --- a/packages/ui/components/table/TableNew.tsx +++ b/packages/ui/components/table/TableNew.tsx @@ -4,13 +4,11 @@ import { classNames } from "@calcom/lib"; const Table = React.forwardRef>( ({ className, ...props }, ref) => ( -
- - +
) ); Table.displayName = "Table";