Skip to content

Commit

Permalink
feat(table): placement = top
Browse files Browse the repository at this point in the history
  • Loading branch information
chaishi committed Sep 5, 2022
1 parent 72aef32 commit 648b9c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/table/Ellipsis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import debounce from 'lodash/debounce';

import { TNode } from '../common';
import { isNodeOverflow } from '../_util/dom';
import TPopup, { PopupProps } from '../popup';
import Tooltip, { TooltipProps } from '../tooltip';
import useConfig from '../hooks/useConfig';

export interface EllipsisProps {
content?: string | TNode;
children?: string | TNode;
popupContent?: string | number | TNode;
placement?: PopupProps['placement'];
placement?: TooltipProps['placement'];
attach?: () => HTMLElement;
popupProps?: PopupProps;
tooltipProps?: TooltipProps;
zIndex?: number;
}

Expand Down Expand Up @@ -54,9 +54,9 @@ export default function Ellipsis(props: EllipsisProps) {
zIndex: props.zIndex,
attach: props.attach,
placement: props.placement,
...(props.popupProps || {}),
...(props.tooltipProps || {}),
};
content = <TPopup {...rProps}>{ellipsisContent}</TPopup>;
content = <Tooltip {...rProps}>{ellipsisContent}</Tooltip>;
} else {
content = ellipsisContent;
}
Expand Down
2 changes: 1 addition & 1 deletion src/table/THead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function THead(props: TheadProps) {
placement="bottom"
attach={theadRef.current ? () => theadRef.current.parentNode.parentNode as HTMLElement : undefined}
popupContent={content}
popupProps={typeof col.ellipsisTitle === 'object' ? col.ellipsisTitle : undefined}
tooltipProps={typeof col.ellipsisTitle === 'object' ? col.ellipsisTitle : undefined}
>
{innerTh}
</TEllipsis>
Expand Down
8 changes: 3 additions & 5 deletions src/table/TR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,15 @@ export default function TR(props: TrProps) {

function renderEllipsisCell(cellParams: BaseTableCellParams<TableRowData>, params: RenderEllipsisCellParams) {
const { cellNode } = params;
const { col, colIndex } = cellParams;
// 前两列左对齐显示
const placement = colIndex < 2 ? 'top-left' : 'top-right';
const { col } = cellParams;
const content = isFunction(col.ellipsis) ? col.ellipsis(cellParams) : undefined;
const tableElement = props.tableElm;
return (
<TEllipsis
placement={placement}
placement={'top'}
attach={tableElement ? () => tableElement : undefined}
popupContent={content}
popupProps={typeof col.ellipsis === 'object' ? col.ellipsis : undefined}
tooltipProps={typeof col.ellipsis === 'object' ? col.ellipsis : undefined}
>
{cellNode}
</TEllipsis>
Expand Down
4 changes: 2 additions & 2 deletions src/table/hooks/useTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export default function useTableHeader({ columns }: UseTableHeaderParams) {
<div className={tableSortClasses.title}>
{col.ellipsis && ellipsisTitle !== false && ellipsisTitle !== null ? (
<TEllipsis
placement="bottom-right"
placement="bottom"
attach={attach ? () => attach : undefined}
popupContent={content}
popupProps={typeof ellipsisTitle === 'object' ? ellipsisTitle : undefined}
tooltipProps={typeof ellipsisTitle === 'object' ? ellipsisTitle : undefined}
>
{title}
</TEllipsis>
Expand Down

0 comments on commit 648b9c8

Please sign in to comment.