From 7a7a4663c5bc722d0b2f6cabbae2b7542294cca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Mon, 30 Aug 2021 15:11:21 +0500 Subject: [PATCH] Remove padding from EditableCell. Add types into otherColumsParams. --- src/components/Table/EditableCell.jsx | 6 +++++- src/components/Table/EditableTable.jsx | 2 +- src/components/Table/index.ts | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Table/EditableCell.jsx b/src/components/Table/EditableCell.jsx index d953678..84dae08 100644 --- a/src/components/Table/EditableCell.jsx +++ b/src/components/Table/EditableCell.jsx @@ -28,7 +28,11 @@ export const EditableCell = ({ {inputNode} - return ( + const tdStyle = editing + ? { padding:0 } + : null + + return ( {editing ? editor: children} ) } \ No newline at end of file diff --git a/src/components/Table/EditableTable.jsx b/src/components/Table/EditableTable.jsx index 8e18eea..d363c28 100644 --- a/src/components/Table/EditableTable.jsx +++ b/src/components/Table/EditableTable.jsx @@ -30,7 +30,7 @@ export const EditableTable = ({ setData(tryAddKeys(dataSource)) },[dataSource]) - const isEditing = (record) => record.key === editingKey + const isEditing = (record) => record?.key === editingKey const edit = (record) => { form.setFieldsValue({...record}) diff --git a/src/components/Table/index.ts b/src/components/Table/index.ts index bf62c31..fe5fe21 100644 --- a/src/components/Table/index.ts +++ b/src/components/Table/index.ts @@ -1,3 +1,4 @@ +import { ReactNode } from 'react' export { Table } from 'antd' export { EditableTable } from './EditableTable' export { DatePickerWrapper } from './DatePickerWrapper' @@ -27,7 +28,7 @@ interface columnPropsOther { // редактируемая колонка editable?: boolean // react компонента редактора - input?: any + input?: ReactNode // значение может быть пустым isRequired?: boolean // css класс для , если требуется @@ -38,14 +39,14 @@ interface columnPropsOther { initialValue?: string|number } -export const makeColumn = (title:string, key:string, other?:columnPropsOther) => ({ +export const makeColumn = (title:string | ReactNode, key:string, other?:columnPropsOther) => ({ title: title, key: key, dataIndex: key, ...other, }) -export const makeColumnsPlanFact = (title:string, key:string|string[], columsOther?:any|any[], gruopOther?:any) => +export const makeColumnsPlanFact = (title:string | ReactNode, key:string|string[], columsOther?:any|any[], gruopOther?:any) => { let keyPlanLocal = key let keyFactLocal = key