From 750dd7661b13e7c5f7e02a1be8defb756edf01c4 Mon Sep 17 00:00:00 2001 From: Anamika T S Date: Tue, 18 Jun 2024 11:53:12 +0530 Subject: [PATCH] refactor(useInlineEdit): add typescript types --- .../Datagrid/{useInlineEdit.js => useInlineEdit.tsx} | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) rename packages/ibm-products/src/components/Datagrid/{useInlineEdit.js => useInlineEdit.tsx} (89%) diff --git a/packages/ibm-products/src/components/Datagrid/useInlineEdit.js b/packages/ibm-products/src/components/Datagrid/useInlineEdit.tsx similarity index 89% rename from packages/ibm-products/src/components/Datagrid/useInlineEdit.js rename to packages/ibm-products/src/components/Datagrid/useInlineEdit.tsx index e4b43f2633..e472226ab1 100644 --- a/packages/ibm-products/src/components/Datagrid/useInlineEdit.js +++ b/packages/ibm-products/src/components/Datagrid/useInlineEdit.tsx @@ -9,10 +9,12 @@ import React from 'react'; import { pkg } from '../../settings'; import cx from 'classnames'; import { InlineEditCell } from './Datagrid/addons/InlineEdit/InlineEditCell'; +import { Hooks, TableInstance } from 'react-table'; +import { DataGridState } from './types'; const blockClass = `${pkg.prefix}--datagrid`; -const useInlineEdit = (hooks) => { +const useInlineEdit = (hooks: Hooks) => { const addInlineEdit = (props, { cell, instance }) => { const columnInlineEditConfig = cell.column.inlineEdit; const inlineEditType = cell.column?.inlineEdit?.type; @@ -24,7 +26,7 @@ const useInlineEdit = (hooks) => { tabIndex={-1} value={cell.value} cell={cell} - isDisabled={isDisabled} + disabledCell={isDisabled} instance={instance} type={type} /> @@ -73,8 +75,8 @@ const useInlineEdit = (hooks) => { ]; }; hooks.getCellProps.push(addInlineEdit); - hooks.useInstance.push((instance) => { - Object.assign(instance, { + hooks.useInstance.push((instance: TableInstance) => { + Object.assign(instance as DataGridState, { withInlineEdit: true, }); });