1 line
21 KiB
JSON
1 line
21 KiB
JSON
|
{"ast":null,"code":"import { unit } from '@ant-design/cssinjs';\nimport { resetComponent, textEllipsis } from '../../style';\nimport { genStyleHooks, mergeToken } from '../../theme/internal';\n// ============================== Mixins ==============================\nfunction getItemDisabledStyle(cls, token) {\n return {\n [`${cls}, ${cls}:hover, ${cls}:focus`]: {\n color: token.colorTextDisabled,\n cursor: 'not-allowed'\n }\n };\n}\nfunction getItemSelectedStyle(token) {\n return {\n backgroundColor: token.itemSelectedBg,\n boxShadow: token.boxShadowTertiary\n };\n}\nconst segmentedTextEllipsisCss = Object.assign({\n overflow: 'hidden'\n}, textEllipsis);\n// ============================== Styles ==============================\nconst genSegmentedStyle = token => {\n const {\n componentCls\n } = token;\n const labelHeight = token.calc(token.controlHeight).sub(token.calc(token.trackPadding).mul(2)).equal();\n const labelHeightLG = token.calc(token.controlHeightLG).sub(token.calc(token.trackPadding).mul(2)).equal();\n const labelHeightSM = token.calc(token.controlHeightSM).sub(token.calc(token.trackPadding).mul(2)).equal();\n return {\n [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, resetComponent(token)), {\n display: 'inline-block',\n padding: token.trackPadding,\n color: token.itemColor,\n background: token.trackBg,\n borderRadius: token.borderRadius,\n transition: `all ${token.motionDurationMid} ${token.motionEaseInOut}`,\n [`${componentCls}-group`]: {\n position: 'relative',\n display: 'flex',\n alignItems: 'stretch',\n justifyItems: 'flex-start',\n width: '100%'\n },\n // RTL styles\n [`&${componentCls}-rtl`]: {\n direction: 'rtl'\n },\n // block styles\n [`&${componentCls}-block`]: {\n display: 'flex'\n },\n [`&${componentCls}-block ${componentCls}-item`]: {\n flex: 1,\n minWidth: 0\n },\n // item styles\n [`${componentCls}-item`]: {\n position: 'relative',\n textAlign: 'center',\n cursor: 'pointer',\n transition: `color ${token.motionDurationMid} ${token.motionEaseInOut}`,\n borderRadius: token.borderRadiusSM,\n // Fix Safari render bug\n // https://github.com/ant-design/ant-design/issues/45250\n transform: 'translateZ(0)',\n '&-selected': Object.assign(Object.assign({}, getItemSelectedStyle(token)), {\n color: token.itemSelectedColor\n }),\n '&::after': {\n content: '\"\"',\n position: 'absolute',\n zIndex: -1,\n width: '100%',\n height: '100%',\n top: 0,\n insetInlineStart: 0,\n borderRadius: 'inherit',\n transition: `background-color ${token.motionDurationMid}`,\n // This is mandatory to make it not clickable or hoverable\n // Ref: https://github.com/ant-design/ant-design/issues/40888\n pointerEvents: 'none'\n },\n [`&:hover:not(${componentCls}-item-selected):not(${componentCls}-item-disabled)`]: {\n color: token.itemHoverColor,\n '&::after': {\n backgroundColor: token.itemHoverBg\n }\n },\n [`&:active:not(${componentCls}-item-selected):not(${componentCls}-item-disabled)`]: {\n color: token.itemHoverColor,\n '&::after': {\n backgroundColor: token.itemActiveBg\n }\n },\n '&-label': Object.assign({\n minHeight: labelHeight,\n lineHeight: unit(labelHeight),\n padding: `0 ${unit(token.segmentedPaddingHorizontal)}`\n }, segmentedTextEllipsisCss),\n // syntactic sugar to add `icon` for Segmented Item\n '&-icon + *': {\n marginInlineStart: token.calc(token.marginSM).div(2).equal()\n },\n '&-input': {\n position: 'absolute',\n insetBlockStart: 0,\n insetInlineStart: 0,\n width: 0,
|