Skip to content

Commit

Permalink
EPMRPP-96014 || Adjust rowActionMenu to renderRowActions function (#54)
Browse files Browse the repository at this point in the history
* EPMRPP-96014 || Adjust rowActionMenu to renderRowActions function

* EPMRPP-96014 || Adjust storybook example
  • Loading branch information
maria-hambardzumian authored Nov 6, 2024
1 parent 525d16d commit 9cf2894
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/table/table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default meta;

type Story = StoryObj<TableComponentProps>;

const rowActionMenu = (
const renderRowActions = () => (
<Popover
placement={'bottom-end'}
content={
Expand Down Expand Up @@ -151,7 +151,7 @@ export const Default: Story = {
args: {
primaryColumn,
fixedColumns,
rowActionMenu,
renderRowActions,
selectable: true,
},
};
10 changes: 6 additions & 4 deletions src/components/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const Table: FC<TableComponentProps> = ({
data,
primaryColumn,
fixedColumns,
rowActionMenu,
renderRowActions,
className = '',
rowClassName = '',
headerClassName = '',
Expand Down Expand Up @@ -121,7 +121,7 @@ export const Table: FC<TableComponentProps> = ({
</div>
</button>
))}
{rowActionMenu && <div className={cx('table-header-cell', 'action-menu-cell')} />}
{renderRowActions && <div className={cx('table-header-cell', 'action-menu-cell')} />}
</div>

<div className={cx('table-body')}>
Expand Down Expand Up @@ -156,8 +156,10 @@ export const Table: FC<TableComponentProps> = ({
</div>
))}

{rowActionMenu && (
<div className={cx('table-cell', 'action-menu-cell')}>{rowActionMenu}</div>
{renderRowActions && (
<div className={cx('table-cell', 'action-menu-cell')}>
{renderRowActions(item.metaData)}
</div>
)}
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/components/table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ export interface DetailedCellData {
content: string | number;
component: ReactNode;
}
export interface MetaData {
[key: string]: any;

Check warning on line 22 in src/components/table/types.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
}
export interface RowData {
id: string | number;
[key: string]: DetailedCellData | RowConfigs | string | number | any;

Check warning on line 26 in src/components/table/types.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
rowConfigs?: RowConfigs;
metaData?: MetaData;
}
export enum SortDirection {
ASC = 'asc',
Expand All @@ -35,7 +39,7 @@ export interface TableComponentProps {
data: RowData[];
primaryColumn: Column;
fixedColumns: FixedColumn[];
rowActionMenu?: ReactNode;
renderRowActions?: (metaData?: MetaData) => ReactNode;
selectable?: boolean;
className?: string;
headerClassName?: string;
Expand Down

0 comments on commit 9cf2894

Please sign in to comment.