Skip to content

Commit 2a91c02

Browse files
committed
fix:- Table column alignment
1 parent 40a8975 commit 2a91c02

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,17 @@ const TableTh = styled.th<{ width?: number }>`
373373
${(props) => props.width && `width: ${props.width}px`};
374374
`;
375375

376-
const TableTd = styled.td<{
376+
interface TableTdProps {
377377
$background: string;
378378
$style: TableColumnStyleType & { rowHeight?: string };
379379
$defaultThemeDetail: ThemeDetail;
380380
$linkStyle?: TableColumnLinkStyleType;
381381
$isEditing: boolean;
382382
$tableSize?: string;
383383
$autoHeight?: boolean;
384-
}>`
384+
$customAlign?: 'left' | 'center' | 'right';
385+
}
386+
const TableTd = styled.td<TableTdProps>`
385387
.ant-table-row-expand-icon,
386388
.ant-table-row-indent {
387389
display: ${(props) => (props.$isEditing ? "none" : "initial")};
@@ -394,6 +396,7 @@ const TableTd = styled.td<{
394396
border-color: ${(props) => props.$style.border} !important;
395397
border-radius: ${(props) => props.$style.radius};
396398
padding: 0 !important;
399+
text-align: ${(props) => props.$customAlign || 'left'} !important;
397400
398401
> div:not(.editing-border, .editing-wrapper),
399402
.editing-wrapper .ant-input,
@@ -404,8 +407,13 @@ const TableTd = styled.td<{
404407
font-weight: ${(props) => props.$style.textWeight};
405408
font-family: ${(props) => props.$style.fontFamily};
406409
overflow: hidden;
410+
display: flex;
411+
justify-content: ${(props) => props.$customAlign === 'center' ? 'center' : props.$customAlign === 'right' ? 'flex-end' : 'flex-start'};
412+
align-items: center;
413+
text-align: ${(props) => props.$customAlign || 'left'};
414+
padding: 0 8px;
415+
box-sizing: border-box;
407416
${(props) => props.$tableSize === 'small' && `
408-
padding: 1px 8px;
409417
font-size: ${props.$defaultThemeDetail.textSize == props.$style.textSize ? '14px !important' : props.$style.textSize + ' !important'};
410418
font-style:${props.$style.fontStyle} !important;
411419
min-height: ${props.$style.rowHeight || '14px'};
@@ -416,7 +424,6 @@ const TableTd = styled.td<{
416424
`};
417425
`};
418426
${(props) => props.$tableSize === 'middle' && `
419-
padding: 8px 8px;
420427
font-size: ${props.$defaultThemeDetail.textSize == props.$style.textSize ? '16px !important' : props.$style.textSize + ' !important'};
421428
font-style:${props.$style.fontStyle} !important;
422429
min-height: ${props.$style.rowHeight || '24px'};
@@ -427,7 +434,6 @@ const TableTd = styled.td<{
427434
`};
428435
`};
429436
${(props) => props.$tableSize === 'large' && `
430-
padding: 16px 16px;
431437
font-size: ${props.$defaultThemeDetail.textSize == props.$style.textSize ? '18px !important' : props.$style.textSize + ' !important'};
432438
font-style:${props.$style.fontStyle} !important;
433439
min-height: ${props.$style.rowHeight || '48px'};
@@ -573,6 +579,7 @@ const TableCellView = React.memo((props: {
573579
tableSize?: string;
574580
autoHeight?: boolean;
575581
loading?: boolean;
582+
customAlign?: 'left' | 'center' | 'right';
576583
}) => {
577584
const {
578585
record,
@@ -588,6 +595,7 @@ const TableCellView = React.memo((props: {
588595
tableSize,
589596
autoHeight,
590597
loading,
598+
customAlign,
591599
...restProps
592600
} = props;
593601

@@ -648,6 +656,7 @@ const TableCellView = React.memo((props: {
648656
$isEditing={editing}
649657
$tableSize={tableSize}
650658
$autoHeight={autoHeight}
659+
$customAlign={customAlign}
651660
>
652661
{loading
653662
? <TableTdLoading block active $tableSize={tableSize} />
@@ -735,6 +744,7 @@ function ResizeableTableComp<RecordType extends object>(props: CustomTableProps<
735744
autoHeight: rowAutoHeight,
736745
onClick: () => onCellClick(col.titleText, String(col.dataIndex)),
737746
loading: customLoading,
747+
customAlign: col.align,
738748
});
739749
}, [rowColorFn, rowHeightFn, columnsStyle, size, rowAutoHeight, onCellClick, customLoading]);
740750

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy