From c60e864c60497dfb0f3aa79f2ee8c78eefe1278f Mon Sep 17 00:00:00 2001 From: Afsal K Date: Tue, 11 Jun 2024 12:44:38 +0530 Subject: [PATCH] refactor(useOnRowClick): implement types --- .../ibm-products/src/components/Datagrid/types/index.ts | 1 + .../Datagrid/{useOnRowClick.js => useOnRowClick.ts} | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) rename packages/ibm-products/src/components/Datagrid/{useOnRowClick.js => useOnRowClick.ts} (89%) diff --git a/packages/ibm-products/src/components/Datagrid/types/index.ts b/packages/ibm-products/src/components/Datagrid/types/index.ts index df6fd1e07a..cddcf4874d 100644 --- a/packages/ibm-products/src/components/Datagrid/types/index.ts +++ b/packages/ibm-products/src/components/Datagrid/types/index.ts @@ -264,6 +264,7 @@ export interface DataGridState onVirtualScroll?: (evt?: boolean) => void; fetchMoreData?: () => void; loadMoreThreshold?: number; + onRowClick?: (row, event) => void; } // DatagridHeaderRow related types diff --git a/packages/ibm-products/src/components/Datagrid/useOnRowClick.js b/packages/ibm-products/src/components/Datagrid/useOnRowClick.ts similarity index 89% rename from packages/ibm-products/src/components/Datagrid/useOnRowClick.js rename to packages/ibm-products/src/components/Datagrid/useOnRowClick.ts index f9b71bb73c..152bde3663 100644 --- a/packages/ibm-products/src/components/Datagrid/useOnRowClick.js +++ b/packages/ibm-products/src/components/Datagrid/useOnRowClick.ts @@ -5,11 +5,13 @@ * LICENSE file in the root directory of this source tree. */ +import { Hooks, TableInstance } from 'react-table'; import { pkg, carbon } from '../../settings'; +import { DataGridState } from './types'; -const useOnRowClick = (hooks) => { - const useInstance = (rowInstance) => { - const { onRowClick } = rowInstance; +const useOnRowClick = (hooks: Hooks) => { + const useInstance = (rowInstance: TableInstance) => { + const { onRowClick } = rowInstance as DataGridState; const getRowProps = (props, datagridState) => { const { isFetching, row, instance } = datagridState; const { id, toggleRowSelected } = row;