1 line
32 KiB
JSON
1 line
32 KiB
JSON
|
{"ast":null,"code":"import { unit } from '@ant-design/cssinjs';\nimport { TinyColor } from '@ctrl/tinycolor';\nimport { genFocusStyle, resetComponent } from '../../style';\nimport { genStyleHooks, mergeToken } from '../../theme/internal';\nconst genSwitchSmallStyle = token => {\n const {\n componentCls,\n trackHeightSM,\n trackPadding,\n trackMinWidthSM,\n innerMinMarginSM,\n innerMaxMarginSM,\n handleSizeSM,\n calc\n } = token;\n const switchInnerCls = `${componentCls}-inner`;\n const trackPaddingCalc = unit(calc(handleSizeSM).add(calc(trackPadding).mul(2)).equal());\n const innerMaxMarginCalc = unit(calc(innerMaxMarginSM).mul(2).equal());\n return {\n [componentCls]: {\n [`&${componentCls}-small`]: {\n minWidth: trackMinWidthSM,\n height: trackHeightSM,\n lineHeight: unit(trackHeightSM),\n [`${componentCls}-inner`]: {\n paddingInlineStart: innerMaxMarginSM,\n paddingInlineEnd: innerMinMarginSM,\n [`${switchInnerCls}-checked, ${switchInnerCls}-unchecked`]: {\n minHeight: trackHeightSM\n },\n [`${switchInnerCls}-checked`]: {\n marginInlineStart: `calc(-100% + ${trackPaddingCalc} - ${innerMaxMarginCalc})`,\n marginInlineEnd: `calc(100% - ${trackPaddingCalc} + ${innerMaxMarginCalc})`\n },\n [`${switchInnerCls}-unchecked`]: {\n marginTop: calc(trackHeightSM).mul(-1).equal(),\n marginInlineStart: 0,\n marginInlineEnd: 0\n }\n },\n [`${componentCls}-handle`]: {\n width: handleSizeSM,\n height: handleSizeSM\n },\n [`${componentCls}-loading-icon`]: {\n top: calc(calc(handleSizeSM).sub(token.switchLoadingIconSize)).div(2).equal(),\n fontSize: token.switchLoadingIconSize\n },\n [`&${componentCls}-checked`]: {\n [`${componentCls}-inner`]: {\n paddingInlineStart: innerMinMarginSM,\n paddingInlineEnd: innerMaxMarginSM,\n [`${switchInnerCls}-checked`]: {\n marginInlineStart: 0,\n marginInlineEnd: 0\n },\n [`${switchInnerCls}-unchecked`]: {\n marginInlineStart: `calc(100% - ${trackPaddingCalc} + ${innerMaxMarginCalc})`,\n marginInlineEnd: `calc(-100% + ${trackPaddingCalc} - ${innerMaxMarginCalc})`\n }\n },\n [`${componentCls}-handle`]: {\n insetInlineStart: `calc(100% - ${unit(calc(handleSizeSM).add(trackPadding).equal())})`\n }\n },\n [`&:not(${componentCls}-disabled):active`]: {\n [`&:not(${componentCls}-checked) ${switchInnerCls}`]: {\n [`${switchInnerCls}-unchecked`]: {\n marginInlineStart: calc(token.marginXXS).div(2).equal(),\n marginInlineEnd: calc(token.marginXXS).mul(-1).div(2).equal()\n }\n },\n [`&${componentCls}-checked ${switchInnerCls}`]: {\n [`${switchInnerCls}-checked`]: {\n marginInlineStart: calc(token.marginXXS).mul(-1).div(2).equal(),\n marginInlineEnd: calc(token.marginXXS).div(2).equal()\n }\n }\n }\n }\n }\n };\n};\nconst genSwitchLoadingStyle = token => {\n const {\n componentCls,\n handleSize,\n calc\n } = token;\n return {\n [componentCls]: {\n [`${componentCls}-loading-icon${token.iconCls}`]: {\n position: 'relative',\n top: calc(calc(handleSize).sub(token.fontSize)).div(2).equal(),\n color: token.switchLoadingIconColor,\n verticalAlign: 'top'\n },\n [`&${componentCls}-checked ${componentCls}-loading-icon`]: {\n color: token.switchColor\n }\n }\n };\n};\nconst genSwitchHandleStyle = token => {\n const {\n componentCls,\n trackPadding,\n handleBg,\n handleShadow,\n handleSize,\n calc\n } = token;\n const switchHandleCls = `${componentCls}-handle`;\n return {\n [componentCls]: {\n [switchHandleCls]: {\n
|