From b3f9f56a792c225a7583fda1dda2d88d0839e139 Mon Sep 17 00:00:00 2001 From: Jordan Koschei Date: Tue, 30 Jul 2024 08:44:24 -0400 Subject: [PATCH 1/4] feat: fix column growth issue --- .../src/DataTable/DataTable.tsx | 134 ++++++++++-------- .../src/labs/DataComponents/TableContent.tsx | 49 ++++++- .../labs/DataComponents/tableConstants.tsx | 19 --- .../src/theme/components.tsx | 39 ++++- .../DataComponents/DataComponents.stories.tsx | 64 +++++++++ .../DataTable/DataTable.stories.tsx | 64 +++++++++ 6 files changed, 284 insertions(+), 85 deletions(-) diff --git a/packages/odyssey-react-mui/src/DataTable/DataTable.tsx b/packages/odyssey-react-mui/src/DataTable/DataTable.tsx index ec80de53ee..83841b3742 100644 --- a/packages/odyssey-react-mui/src/DataTable/DataTable.tsx +++ b/packages/odyssey-react-mui/src/DataTable/DataTable.tsx @@ -61,6 +61,7 @@ import { import { useScrollIndication } from "./useScrollIndication"; import styled from "@emotion/styled"; import { EmptyState } from "../EmptyState"; +import { Button } from "../Button"; import { Callout } from "../Callout"; export type DataTableColumn = MRT_ColumnDef & { @@ -255,62 +256,6 @@ export type DataTableProps = { maxPages?: number; }; -const displayColumnDefOptions = { - "mrt-row-actions": { - header: "", - grow: true, - muiTableBodyCellProps: { - align: "right", - sx: { - overflow: "visible", - width: "unset", - }, - className: "ods-actions-cell", - }, - muiTableHeadCellProps: { - align: "right", - sx: { - width: "unset", - }, - className: "ods-actions-cell", - }, - }, - "mrt-row-drag": { - header: "", - muiTableBodyCellProps: { - sx: { - minWidth: 0, - width: "auto", - }, - className: "ods-drag-handle", - }, - muiTableHeadCellProps: { - sx: { - minWidth: 0, - width: "auto", - }, - children: ( - // Add a spacer to simulate the width of the drag handle in the column. - // Without this, the head cells are offset from their body cell counterparts - - - - ), - }, - }, - "mrt-row-select": { - muiTableHeadCellProps: { - padding: "checkbox", - }, - muiTableBodyCellProps: { - padding: "checkbox", - }, - }, - "mrt-row-expand": { - header: "", - }, -}; - const ScrollableTableContainer = styled("div", { shouldForwardProp: (prop) => prop !== "odysseyDesignTokens" && @@ -677,14 +622,87 @@ const DataTable = ({ }, }, selectAllMode: "all", - displayColumnDefOptions: - displayColumnDefOptions as MRT_TableOptions["displayColumnDefOptions"], + displayColumnDefOptions: { + "mrt-row-actions": { + header: "", + grow: true, + muiTableBodyCellProps: { + align: "right", + sx: { + overflow: "visible", + width: "unset", + }, + className: "ods-actions-cell", + }, + muiTableHeadCellProps: { + align: "right", + sx: { + width: "unset", + }, + className: "ods-actions-cell", + children: ( + + {rowActionButtons && rowActionButtons({ id: null })} + {((hasRowReordering === true && onReorderRows) || + rowActionMenuItems) && ( + +