UNPKG

antd

Version:

An enterprise-class UI design language and React components implementation

78 lines (77 loc) • 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.genCompactItemStyle = genCompactItemStyle; // handle border collapse function compactItemBorder(token, parentCls, options, prefixCls) { const { focusElCls, focus } = options; const genEffects = effects => effects.filter(Boolean).map(n => `&:${n}`).join(','); const hoverEffects = genEffects(['hover', focusElCls ? `hover${focusElCls}` : null]); const focusEffects = genEffects([focus ? 'focus' : null, 'active']); return { [`&-item:not(${parentCls}-last-item)`]: { marginInlineEnd: token.calc(token.lineWidth).mul(-1).equal() }, [`&-item:not(${prefixCls}-status-success)`]: { zIndex: 2 }, '&-item': { [focusEffects]: { zIndex: 3 }, [hoverEffects]: { zIndex: 4 }, ...(focusElCls ? { [`&${focusElCls}`]: { zIndex: 3 } } : {}), '&[disabled]': { zIndex: 0 } } }; } // handle border-radius function compactItemBorderRadius(prefixCls, parentCls) { return { [`&-item:not(${parentCls}-first-item):not(${parentCls}-last-item)`]: { borderRadius: 0 }, [`&-item:not(${parentCls}-last-item)${parentCls}-first-item`]: { [`&, &${prefixCls}-sm, &${prefixCls}-lg`]: { borderStartEndRadius: 0, borderEndEndRadius: 0 } }, [`&-item:not(${parentCls}-first-item)${parentCls}-last-item`]: { [`&, &${prefixCls}-sm, &${prefixCls}-lg`]: { borderStartStartRadius: 0, borderEndStartRadius: 0 } } }; } function genCompactItemStyle(token, options = { focus: true }) { const { componentCls } = token; const { componentCls: customizePrefixCls } = options; const mergedComponentCls = customizePrefixCls || componentCls; const compactCls = `${mergedComponentCls}-compact`; return { [compactCls]: { ...compactItemBorder(token, compactCls, options, mergedComponentCls), ...compactItemBorderRadius(mergedComponentCls, compactCls) } }; }