mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 22:39:34 +08:00
832cffcdf9
* refactor: support type update * chore: update clear style * chore: bump color picker * chore: use slider * chore: bump color picker * chore: range slider * chore: layout * chore: useModeColor * chore: simplify * chore: bump color picker * refactor: event * chore: tmp lock check * chore: of it * chore: update ts def * chore: update ts def * chore: remove useless ts * chore: linear * chore: adjust style * chore: rm useless code * chore: fill color * chore: basic linear * chore: support toStr * chore: limit minCount * chore: use cache * chore: drag support: * chore: yes * chore: update demo * chore: useLayoutEffect instead * chore: fix click to add point * chore: add smmoth * chore: support of locale * chore: add locale * chore: fix lint * chore: adjust style * chore: fix lint * chore: fix style * test: fix test case * chore: fix popover * test: fix test case * chore: fix test * test: clean up * chore: fix lint * chore: fix lint * chore: fix lint * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * chore: fix docs * docs: update demo desc * chore: enhance hover range * fix: delete not working * chore: fix lint * test: coverage * test: coverage * chore: clean up * chore: adjust * chore: highlight * chore: adjust style * chore: fix lint * chore: update demo * chore: memo perf * refactor: up to down colors * test: update snapshot
104 lines
2.7 KiB
TypeScript
104 lines
2.7 KiB
TypeScript
/* eslint-disable import/prefer-default-export */
|
|
import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import type { AliasToken, FullToken, OverrideComponent, CSSUtil } from '../theme/internal';
|
|
|
|
interface CompactItemOptions {
|
|
focus?: boolean;
|
|
/**
|
|
* Some component borders are implemented on child elements
|
|
* like `Select`
|
|
*/
|
|
borderElCls?: string;
|
|
/**
|
|
* Some components have special `focus` className especially with popovers
|
|
* like `Select` and `DatePicker`
|
|
*/
|
|
focusElCls?: string;
|
|
}
|
|
|
|
// handle border collapse
|
|
function compactItemBorder(
|
|
token: AliasToken & CSSUtil,
|
|
parentCls: string,
|
|
options: CompactItemOptions,
|
|
): CSSObject {
|
|
const { focusElCls, focus, borderElCls } = options;
|
|
const childCombinator = borderElCls ? '> *' : '';
|
|
const hoverEffects = ['hover', focus ? 'focus' : null, 'active']
|
|
.filter(Boolean)
|
|
.map((n) => `&:${n} ${childCombinator}`)
|
|
.join(',');
|
|
return {
|
|
[`&-item:not(${parentCls}-last-item)`]: {
|
|
marginInlineEnd: token.calc(token.lineWidth).mul(-1).equal(),
|
|
},
|
|
|
|
'&-item': {
|
|
[hoverEffects]: {
|
|
zIndex: 2,
|
|
},
|
|
|
|
...(focusElCls
|
|
? {
|
|
[`&${focusElCls}`]: {
|
|
zIndex: 2,
|
|
},
|
|
}
|
|
: {}),
|
|
|
|
[`&[disabled] ${childCombinator}`]: {
|
|
zIndex: 0,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
// handle border-radius
|
|
function compactItemBorderRadius(
|
|
prefixCls: string,
|
|
parentCls: string,
|
|
options: CompactItemOptions,
|
|
): CSSObject {
|
|
const { borderElCls } = options;
|
|
const childCombinator = borderElCls ? `> ${borderElCls}` : '';
|
|
|
|
return {
|
|
[`&-item:not(${parentCls}-first-item):not(${parentCls}-last-item) ${childCombinator}`]: {
|
|
borderRadius: 0,
|
|
},
|
|
|
|
[`&-item:not(${parentCls}-last-item)${parentCls}-first-item`]: {
|
|
[`& ${childCombinator}, &${prefixCls}-sm ${childCombinator}, &${prefixCls}-lg ${childCombinator}`]:
|
|
{
|
|
borderStartEndRadius: 0,
|
|
borderEndEndRadius: 0,
|
|
},
|
|
},
|
|
|
|
[`&-item:not(${parentCls}-first-item)${parentCls}-last-item`]: {
|
|
[`& ${childCombinator}, &${prefixCls}-sm ${childCombinator}, &${prefixCls}-lg ${childCombinator}`]:
|
|
{
|
|
borderStartStartRadius: 0,
|
|
borderEndStartRadius: 0,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export function genCompactItemStyle<T extends OverrideComponent>(
|
|
token: FullToken<T>,
|
|
options: CompactItemOptions = { focus: true },
|
|
): CSSInterpolation {
|
|
const { componentCls } = token;
|
|
|
|
const compactCls = `${componentCls}-compact`;
|
|
|
|
return {
|
|
[compactCls]: {
|
|
...compactItemBorder(token, compactCls, options),
|
|
...compactItemBorderRadius(componentCls, compactCls, options),
|
|
},
|
|
};
|
|
}
|