Skip to content

Commit

Permalink
fix(table): fix ColumnSetting style error
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Sep 13, 2022
1 parent 2088f06 commit ec39ccc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
25 changes: 16 additions & 9 deletions packages/table/src/components/ColumnSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
VerticalAlignTopOutlined,
} from '@ant-design/icons';
import { useIntl } from '@ant-design/pro-provider';
import { runFunction, useRefFunction } from '@ant-design/pro-utils';
import { runFunction, useRefFunction, useToken } from '@ant-design/pro-utils';
import type { TableColumnType } from 'antd';
import { Checkbox, ConfigProvider, Popover, Space, Tooltip, Tree } from 'antd';
import type { CheckboxChangeEvent } from 'antd/es/checkbox';
Expand Down Expand Up @@ -70,8 +70,10 @@ const CheckboxListItem: React.FC<{
isLeaf?: boolean;
}> = ({ columnKey, isLeaf, title, className, fixed }) => {
const intl = useIntl();
const { hashId } = useToken();

const dom = (
<span className={`${className}-list-item-option`}>
<span className={`${className}-list-item-option ${hashId}`}>
<ToolTipIcon
columnKey={columnKey}
fixed="left"
Expand Down Expand Up @@ -99,8 +101,8 @@ const CheckboxListItem: React.FC<{
</span>
);
return (
<span className={`${className}-list-item`} key={columnKey}>
<div className={`${className}-list-item-title`}>{title}</div>
<span className={`${className}-list-item ${hashId}`} key={columnKey}>
<div className={`${className}-list-item-title ${hashId}`}>{title}</div>
{!isLeaf ? dom : null}
</span>
);
Expand All @@ -123,6 +125,8 @@ const CheckboxList: React.FC<{
title: listTitle,
listHeight = 280,
}) => {
const { hashId } = useToken();

const { columnsMap, setColumnsMap, sortKeyColumns, setSortKeyColumns } = Container.useContainer();
const show = list && list.length > 0;
const treeDataConfig = useMemo(() => {
Expand Down Expand Up @@ -213,6 +217,7 @@ const CheckboxList: React.FC<{
showLine={false}
titleRender={(_node) => {
const node = { ..._node, children: undefined };
if (!node.title) return null;
return (
<CheckboxListItem
className={className}
Expand All @@ -228,7 +233,7 @@ const CheckboxList: React.FC<{
);
return (
<>
{showTitle && <span className={`${className}-list-title`}>{listTitle}</span>}
{showTitle && <span className={`${className}-list-title ${hashId}`}>{listTitle}</span>}
{listDom}
</>
);
Expand All @@ -241,6 +246,7 @@ const GroupCheckboxList: React.FC<{
checkable: boolean;
listsHeight?: number;
}> = ({ localColumns, className, draggable, checkable, listsHeight }) => {
const { hashId } = useToken();
const rightList: (ProColumns<any> & { index?: number })[] = [];
const leftList: (ProColumns<any> & { index?: number })[] = [];
const list: (ProColumns<any> & { index?: number })[] = [];
Expand All @@ -267,7 +273,7 @@ const GroupCheckboxList: React.FC<{
const showLeft = leftList && leftList.length > 0;
return (
<div
className={classNames(`${className}-list`, {
className={classNames(`${className}-list`, hashId, {
[`${className}-list-group`]: showRight || showLeft,
})}
>
Expand Down Expand Up @@ -303,6 +309,7 @@ const GroupCheckboxList: React.FC<{

function ColumnSetting<T>(props: ColumnSettingProps<T>) {
const columnRef = useRef({});
// 获得当前上下文的 hashID
const counter = Container.useContainer();
const localColumns: TableColumnType<T> &
{
Expand Down Expand Up @@ -371,12 +378,12 @@ function ColumnSetting<T>(props: ColumnSettingProps<T>) {
const intl = useIntl();
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const className = getPrefixCls('pro-table-column-setting');
const { wrapSSR } = useStyle(className);
const { wrapSSR, hashId } = useStyle(className);
return wrapSSR(
<Popover
arrowPointAtCenter
title={
<div className={`${className}-title`}>
<div className={`${className}-title ${hashId}`}>
<Checkbox
indeterminate={indeterminate}
checked={unCheckedKeys.length === 0 && unCheckedKeys.length !== localColumns.length}
Expand All @@ -396,7 +403,7 @@ function ColumnSetting<T>(props: ColumnSettingProps<T>) {
) : null}
</div>
}
overlayClassName={`${className}-overlay`}
overlayClassName={`${className}-overlay ${hashId}`}
trigger="click"
placement="bottomRight"
content={
Expand Down
7 changes: 3 additions & 4 deletions packages/table/src/components/ColumnSetting/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ const genProStyle: GenerateStyle<ProToken> = (token) => {
[`${token.antCls}-tree-treenode`]: {
alignItems: 'center',
'&:hover': {
backgroundColor: token.controlItemBgActive,
[`${token.componentCls}-list-item-option`]: {
display: 'block',
},
},
[`${token.antCls}-tree-checkbox`]: {
insetBlockStart: 0,
marginBlock: 0,
marginInline: 0,
marginInlineEnd: '4px',
},
[`${token.antCls}-tree-title`]: {
width: '100%',
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/components/LabelIconTip/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const genProStyle: GenerateStyle<ProToken> = (token) => {
marginInlineStart: '4px',
cursor: 'pointer',
'&:hover': {
color: token.colorPrimaryBgHover,
color: token.colorPrimary,
},
},
'&-title': { display: 'inline-flex', flex: '1' },
Expand Down

0 comments on commit ec39ccc

Please sign in to comment.