| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.genBaseStyle = exports.default = void 0;
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
- var _motion = require("../../style/motion");
- var _internal = require("../../theme/internal");
- var _style = require("../../style");
- const genBaseStyle = token => {
- const {
- componentCls,
- collapseContentBg,
- padding,
- collapseContentPaddingHorizontal,
- collapseHeaderBg,
- collapseHeaderPadding,
- collapsePanelBorderRadius,
- lineWidth,
- lineType,
- colorBorder,
- colorText,
- colorTextHeading,
- colorTextDisabled,
- fontSize,
- lineHeight,
- marginSM,
- paddingSM,
- motionDurationSlow,
- fontSizeIcon
- } = token;
- const borderBase = `${lineWidth}px ${lineType} ${colorBorder}`;
- return {
- [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
- backgroundColor: collapseHeaderBg,
- border: borderBase,
- borderBottom: 0,
- borderRadius: `${collapsePanelBorderRadius}px`,
- [`&-rtl`]: {
- direction: 'rtl'
- },
- [`& > ${componentCls}-item`]: {
- borderBottom: borderBase,
- [`&:last-child`]: {
- [`
- &,
- & > ${componentCls}-header`]: {
- borderRadius: `0 0 ${collapsePanelBorderRadius}px ${collapsePanelBorderRadius}px`
- }
- },
- [`> ${componentCls}-header`]: {
- position: 'relative',
- display: 'flex',
- flexWrap: 'nowrap',
- alignItems: 'flex-start',
- padding: collapseHeaderPadding,
- color: colorTextHeading,
- lineHeight,
- cursor: 'pointer',
- transition: `all ${motionDurationSlow}, visibility 0s`,
- [`> ${componentCls}-header-text`]: {
- flex: 'auto'
- },
- '&:focus': {
- outline: 'none'
- },
- // >>>>> Arrow
- [`${componentCls}-expand-icon`]: {
- height: fontSize * lineHeight,
- display: 'flex',
- alignItems: 'center',
- paddingInlineEnd: marginSM
- },
- [`${componentCls}-arrow`]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetIcon)()), {
- fontSize: fontSizeIcon,
- svg: {
- transition: `transform ${motionDurationSlow}`
- }
- }),
- // >>>>> Text
- [`${componentCls}-header-text`]: {
- marginInlineEnd: 'auto'
- }
- },
- [`${componentCls}-header-collapsible-only`]: {
- cursor: 'default',
- [`${componentCls}-header-text`]: {
- flex: 'none',
- cursor: 'pointer'
- },
- [`${componentCls}-expand-icon`]: {
- cursor: 'pointer'
- }
- },
- [`${componentCls}-icon-collapsible-only`]: {
- cursor: 'default',
- [`${componentCls}-expand-icon`]: {
- cursor: 'pointer'
- }
- },
- [`&${componentCls}-no-arrow`]: {
- [`> ${componentCls}-header`]: {
- paddingInlineStart: paddingSM
- }
- }
- },
- [`${componentCls}-content`]: {
- color: colorText,
- backgroundColor: collapseContentBg,
- borderTop: borderBase,
- [`& > ${componentCls}-content-box`]: {
- padding: `${padding}px ${collapseContentPaddingHorizontal}px`
- },
- [`&-hidden`]: {
- display: 'none'
- }
- },
- [`${componentCls}-item:last-child`]: {
- [`> ${componentCls}-content`]: {
- borderRadius: `0 0 ${collapsePanelBorderRadius}px ${collapsePanelBorderRadius}px`
- }
- },
- [`& ${componentCls}-item-disabled > ${componentCls}-header`]: {
- [`
- &,
- & > .arrow
- `]: {
- color: colorTextDisabled,
- cursor: 'not-allowed'
- }
- },
- // ========================== Icon Position ==========================
- [`&${componentCls}-icon-position-end`]: {
- [`& > ${componentCls}-item`]: {
- [`> ${componentCls}-header`]: {
- [`${componentCls}-expand-icon`]: {
- order: 1,
- paddingInlineEnd: 0,
- paddingInlineStart: marginSM
- }
- }
- }
- }
- })
- };
- };
- exports.genBaseStyle = genBaseStyle;
- const genArrowStyle = token => {
- const {
- componentCls
- } = token;
- const fixedSelector = `> ${componentCls}-item > ${componentCls}-header ${componentCls}-arrow svg`;
- return {
- [`${componentCls}-rtl`]: {
- [fixedSelector]: {
- transform: `rotate(180deg)`
- }
- }
- };
- };
- const genBorderlessStyle = token => {
- const {
- componentCls,
- collapseHeaderBg,
- paddingXXS,
- colorBorder
- } = token;
- return {
- [`${componentCls}-borderless`]: {
- backgroundColor: collapseHeaderBg,
- border: 0,
- [`> ${componentCls}-item`]: {
- borderBottom: `1px solid ${colorBorder}`
- },
- [`
- > ${componentCls}-item:last-child,
- > ${componentCls}-item:last-child ${componentCls}-header
- `]: {
- borderRadius: 0
- },
- [`> ${componentCls}-item:last-child`]: {
- borderBottom: 0
- },
- [`> ${componentCls}-item > ${componentCls}-content`]: {
- backgroundColor: 'transparent',
- borderTop: 0
- },
- [`> ${componentCls}-item > ${componentCls}-content > ${componentCls}-content-box`]: {
- paddingTop: paddingXXS
- }
- }
- };
- };
- const genGhostStyle = token => {
- const {
- componentCls,
- paddingSM
- } = token;
- return {
- [`${componentCls}-ghost`]: {
- backgroundColor: 'transparent',
- border: 0,
- [`> ${componentCls}-item`]: {
- borderBottom: 0,
- [`> ${componentCls}-content`]: {
- backgroundColor: 'transparent',
- border: 0,
- [`> ${componentCls}-content-box`]: {
- paddingBlock: paddingSM
- }
- }
- }
- }
- };
- };
- var _default = exports.default = (0, _internal.genComponentStyleHook)('Collapse', token => {
- const collapseToken = (0, _internal.mergeToken)(token, {
- collapseContentBg: token.colorBgContainer,
- collapseHeaderBg: token.colorFillAlter,
- collapseHeaderPadding: `${token.paddingSM}px ${token.padding}px`,
- collapsePanelBorderRadius: token.borderRadiusLG,
- collapseContentPaddingHorizontal: 16 // Fixed value
- });
- return [genBaseStyle(collapseToken), genBorderlessStyle(collapseToken), genGhostStyle(collapseToken), genArrowStyle(collapseToken), (0, _motion.genCollapseMotion)(collapseToken)];
- });
|