From 2a91c02fadac22cbef3892c669b91201de33920c Mon Sep 17 00:00:00 2001 From: Kamal Qureshi Date: Wed, 23 Jul 2025 01:35:32 +0500 Subject: [PATCH] fix:- Table column alignment --- .../comps/comps/tableComp/tableCompView.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx b/client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx index 139cc396d..9702008da 100644 --- a/client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx +++ b/client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx @@ -373,7 +373,7 @@ const TableTh = styled.th<{ width?: number }>` ${(props) => props.width && `width: ${props.width}px`}; `; -const TableTd = styled.td<{ +interface TableTdProps { $background: string; $style: TableColumnStyleType & { rowHeight?: string }; $defaultThemeDetail: ThemeDetail; @@ -381,7 +381,9 @@ const TableTd = styled.td<{ $isEditing: boolean; $tableSize?: string; $autoHeight?: boolean; -}>` + $customAlign?: 'left' | 'center' | 'right'; +} +const TableTd = styled.td` .ant-table-row-expand-icon, .ant-table-row-indent { display: ${(props) => (props.$isEditing ? "none" : "initial")}; @@ -394,6 +396,7 @@ const TableTd = styled.td<{ border-color: ${(props) => props.$style.border} !important; border-radius: ${(props) => props.$style.radius}; padding: 0 !important; + text-align: ${(props) => props.$customAlign || 'left'} !important; > div:not(.editing-border, .editing-wrapper), .editing-wrapper .ant-input, @@ -404,8 +407,13 @@ const TableTd = styled.td<{ font-weight: ${(props) => props.$style.textWeight}; font-family: ${(props) => props.$style.fontFamily}; overflow: hidden; + display: flex; + justify-content: ${(props) => props.$customAlign === 'center' ? 'center' : props.$customAlign === 'right' ? 'flex-end' : 'flex-start'}; + align-items: center; + text-align: ${(props) => props.$customAlign || 'left'}; + padding: 0 8px; + box-sizing: border-box; ${(props) => props.$tableSize === 'small' && ` - padding: 1px 8px; font-size: ${props.$defaultThemeDetail.textSize == props.$style.textSize ? '14px !important' : props.$style.textSize + ' !important'}; font-style:${props.$style.fontStyle} !important; min-height: ${props.$style.rowHeight || '14px'}; @@ -416,7 +424,6 @@ const TableTd = styled.td<{ `}; `}; ${(props) => props.$tableSize === 'middle' && ` - padding: 8px 8px; font-size: ${props.$defaultThemeDetail.textSize == props.$style.textSize ? '16px !important' : props.$style.textSize + ' !important'}; font-style:${props.$style.fontStyle} !important; min-height: ${props.$style.rowHeight || '24px'}; @@ -427,7 +434,6 @@ const TableTd = styled.td<{ `}; `}; ${(props) => props.$tableSize === 'large' && ` - padding: 16px 16px; font-size: ${props.$defaultThemeDetail.textSize == props.$style.textSize ? '18px !important' : props.$style.textSize + ' !important'}; font-style:${props.$style.fontStyle} !important; min-height: ${props.$style.rowHeight || '48px'}; @@ -573,6 +579,7 @@ const TableCellView = React.memo((props: { tableSize?: string; autoHeight?: boolean; loading?: boolean; + customAlign?: 'left' | 'center' | 'right'; }) => { const { record, @@ -588,6 +595,7 @@ const TableCellView = React.memo((props: { tableSize, autoHeight, loading, + customAlign, ...restProps } = props; @@ -648,6 +656,7 @@ const TableCellView = React.memo((props: { $isEditing={editing} $tableSize={tableSize} $autoHeight={autoHeight} + $customAlign={customAlign} > {loading ? @@ -735,6 +744,7 @@ function ResizeableTableComp(props: CustomTableProps< autoHeight: rowAutoHeight, onClick: () => onCellClick(col.titleText, String(col.dataIndex)), loading: customLoading, + customAlign: col.align, }); }, [rowColorFn, rowHeightFn, columnsStyle, size, rowAutoHeight, onCellClick, customLoading]);