2022-10-28 16:09:38 +08:00
|
|
|
/* eslint-disable import/prefer-default-export */
|
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { DerivativeToken } from '../theme/internal';
|
2022-10-28 16:09:38 +08:00
|
|
|
|
|
|
|
// handle border collapse
|
|
|
|
function compactItemBorder(
|
|
|
|
token: DerivativeToken,
|
|
|
|
borderedItemCls?: string,
|
|
|
|
popoverFocusedCls?: string,
|
|
|
|
): CSSObject {
|
|
|
|
const childCombinator = borderedItemCls ? '> *' : '';
|
|
|
|
return {
|
|
|
|
'&-item:not(&-last-item)': {
|
2022-11-01 15:06:38 +08:00
|
|
|
marginInlineEnd: -token.lineWidth,
|
2022-10-28 16:09:38 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-item': {
|
|
|
|
[`&:hover ${childCombinator}, &:focus ${childCombinator}, &:active ${childCombinator}`]: {
|
|
|
|
zIndex: 2,
|
|
|
|
},
|
|
|
|
|
|
|
|
...(popoverFocusedCls
|
|
|
|
? {
|
|
|
|
[`&${popoverFocusedCls}`]: {
|
|
|
|
zIndex: 2,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
|
|
|
|
[`&[disabled] ${childCombinator}`]: {
|
|
|
|
zIndex: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle border-radius
|
|
|
|
function compactItemBorderRadius(prefixCls: string, borderedElementCls?: string): CSSObject {
|
|
|
|
const childCombinator = borderedElementCls ? `> ${borderedElementCls}` : '';
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`&-item:not(&-first-item):not(&-last-item) ${childCombinator}`]: {
|
|
|
|
borderRadius: 0,
|
|
|
|
},
|
|
|
|
|
2022-11-24 12:10:54 +08:00
|
|
|
'&-item:not(&-last-item)&-first-item': {
|
2022-10-28 16:09:38 +08:00
|
|
|
[`& ${childCombinator}, &${prefixCls}-sm ${childCombinator}, &${prefixCls}-lg ${childCombinator}`]:
|
|
|
|
{
|
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-24 12:10:54 +08:00
|
|
|
'&-item:not(&-first-item)&-last-item': {
|
2022-10-28 16:09:38 +08:00
|
|
|
[`& ${childCombinator}, &${prefixCls}-sm ${childCombinator}, &${prefixCls}-lg ${childCombinator}`]:
|
|
|
|
{
|
|
|
|
borderStartStartRadius: 0,
|
|
|
|
borderEndStartRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function genCompactItemStyle(
|
|
|
|
token: DerivativeToken,
|
|
|
|
prefixCls: string,
|
|
|
|
/** Some component borders are implemented on child elements like `Select` */
|
|
|
|
borderedElementCls?: string,
|
|
|
|
/**
|
|
|
|
* Some components have special `focus` className especially with popovers like `Select` and
|
|
|
|
* `DatePicker`
|
|
|
|
*/
|
|
|
|
popoverFocusedCls?: string,
|
|
|
|
): CSSObject {
|
|
|
|
return {
|
|
|
|
'&-compact': {
|
|
|
|
...compactItemBorder(token, borderedElementCls, popoverFocusedCls),
|
|
|
|
...compactItemBorderRadius(prefixCls, borderedElementCls),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|