From 10983a0f54112cf6f8d1b5dfb6fae0e38a97e5fb Mon Sep 17 00:00:00 2001 From: Diogo Mateus Date: Wed, 24 Jul 2024 11:28:29 +0100 Subject: [PATCH] refactor(table): Add modalContentRenderer prop --- src/lib/components/table/Table.stories.tsx | 3 +++ src/lib/components/table/Table.tsx | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/components/table/Table.stories.tsx b/src/lib/components/table/Table.stories.tsx index 7a410af7..258a33d5 100644 --- a/src/lib/components/table/Table.stories.tsx +++ b/src/lib/components/table/Table.stories.tsx @@ -206,6 +206,9 @@ const story = { hideColumns: { subContent: 'This property allows to hide defined columns by index.', }, + modalContentRenderer: { + subContent: 'This property allows to render custom modal content.', + }, onSelectionChanged: { subContent: 'This event is triggered when a selection is changed. It receives the index of the selection as an argument.', diff --git a/src/lib/components/table/Table.tsx b/src/lib/components/table/Table.tsx index a3ca2f05..24f6c914 100644 --- a/src/lib/components/table/Table.tsx +++ b/src/lib/components/table/Table.tsx @@ -33,6 +33,7 @@ export interface TableProps { hideColumns?: number[]; hideDetails?: boolean; imageComponent?: (args: any) => JSX.Element; + modalContentRenderer?: (content: ReactNode) => ReactNode; onModalOpen?: ModalFunction; onSelectionChanged?: (index: number) => void; stickyHeaderTopOffset?: number; @@ -53,6 +54,7 @@ const Table = ({ hideColumns = [], hideDetails, imageComponent, + modalContentRenderer, onModalOpen, onSelectionChanged, stickyHeaderTopOffset = 0, @@ -185,7 +187,11 @@ const Table = ({ title={infoModalData?.title} onClose={() => setInfoModalData(null)} > -
{infoModalData?.body}
+
+ {modalContentRenderer + ? modalContentRenderer(infoModalData?.body) + : infoModalData?.body} +
);