index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _internal = require("../../theme/internal");
  9. var _style = require("../../style");
  10. const genTransferCustomizeStyle = token => {
  11. const {
  12. antCls,
  13. componentCls,
  14. listHeight,
  15. controlHeightLG,
  16. marginXXS,
  17. margin
  18. } = token;
  19. const tableCls = `${antCls}-table`;
  20. const inputCls = `${antCls}-input`;
  21. return {
  22. [`${componentCls}-customize-list`]: {
  23. [`${componentCls}-list`]: {
  24. flex: '1 1 50%',
  25. width: 'auto',
  26. height: 'auto',
  27. minHeight: listHeight
  28. },
  29. // =================== Hook Components ===================
  30. [`${tableCls}-wrapper`]: {
  31. [`${tableCls}-small`]: {
  32. border: 0,
  33. borderRadius: 0,
  34. [`${tableCls}-selection-column`]: {
  35. width: controlHeightLG,
  36. minWidth: controlHeightLG
  37. }
  38. },
  39. [`${tableCls}-pagination${tableCls}-pagination`]: {
  40. margin: `${margin}px 0 ${marginXXS}px`
  41. }
  42. },
  43. [`${inputCls}[disabled]`]: {
  44. backgroundColor: 'transparent'
  45. }
  46. }
  47. };
  48. };
  49. const genTransferStatusColor = (token, color) => {
  50. const {
  51. componentCls,
  52. colorBorder
  53. } = token;
  54. return {
  55. [`${componentCls}-list`]: {
  56. borderColor: color,
  57. '&-search:not([disabled])': {
  58. borderColor: colorBorder
  59. }
  60. }
  61. };
  62. };
  63. const genTransferStatusStyle = token => {
  64. const {
  65. componentCls
  66. } = token;
  67. return {
  68. [`${componentCls}-status-error`]: (0, _extends2.default)({}, genTransferStatusColor(token, token.colorError)),
  69. [`${componentCls}-status-warning`]: (0, _extends2.default)({}, genTransferStatusColor(token, token.colorWarning))
  70. };
  71. };
  72. const genTransferListStyle = token => {
  73. const {
  74. componentCls,
  75. colorBorder,
  76. colorSplit,
  77. lineWidth,
  78. transferItemHeight,
  79. transferHeaderHeight,
  80. transferHeaderVerticalPadding,
  81. transferItemPaddingVertical,
  82. controlItemBgActive,
  83. controlItemBgActiveHover,
  84. colorTextDisabled,
  85. listHeight,
  86. listWidth,
  87. listWidthLG,
  88. fontSizeIcon,
  89. marginXS,
  90. paddingSM,
  91. lineType,
  92. iconCls,
  93. motionDurationSlow
  94. } = token;
  95. return {
  96. display: 'flex',
  97. flexDirection: 'column',
  98. width: listWidth,
  99. height: listHeight,
  100. border: `${lineWidth}px ${lineType} ${colorBorder}`,
  101. borderRadius: token.borderRadiusLG,
  102. '&-with-pagination': {
  103. width: listWidthLG,
  104. height: 'auto'
  105. },
  106. '&-search': {
  107. [`${iconCls}-search`]: {
  108. color: colorTextDisabled
  109. }
  110. },
  111. '&-header': {
  112. display: 'flex',
  113. flex: 'none',
  114. alignItems: 'center',
  115. height: transferHeaderHeight,
  116. // border-top is on the transfer dom. We should minus 1px for this
  117. padding: `${transferHeaderVerticalPadding - lineWidth}px ${paddingSM}px ${transferHeaderVerticalPadding}px`,
  118. color: token.colorText,
  119. background: token.colorBgContainer,
  120. borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
  121. borderRadius: `${token.borderRadiusLG}px ${token.borderRadiusLG}px 0 0`,
  122. '> *:not(:last-child)': {
  123. marginInlineEnd: 4 // This is magic and fixed number, DO NOT use token since it may change.
  124. },
  125. '> *': {
  126. flex: 'none'
  127. },
  128. '&-title': (0, _extends2.default)((0, _extends2.default)({}, _style.textEllipsis), {
  129. flex: 'auto',
  130. textAlign: 'end'
  131. }),
  132. '&-dropdown': (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetIcon)()), {
  133. fontSize: fontSizeIcon,
  134. transform: 'translateY(10%)',
  135. cursor: 'pointer',
  136. '&[disabled]': {
  137. cursor: 'not-allowed'
  138. }
  139. })
  140. },
  141. '&-body': {
  142. display: 'flex',
  143. flex: 'auto',
  144. flexDirection: 'column',
  145. overflow: 'hidden',
  146. fontSize: token.fontSize,
  147. '&-search-wrapper': {
  148. position: 'relative',
  149. flex: 'none',
  150. padding: paddingSM
  151. }
  152. },
  153. '&-content': {
  154. flex: 'auto',
  155. margin: 0,
  156. padding: 0,
  157. overflow: 'auto',
  158. listStyle: 'none',
  159. '&-item': {
  160. display: 'flex',
  161. alignItems: 'center',
  162. minHeight: transferItemHeight,
  163. padding: `${transferItemPaddingVertical}px ${paddingSM}px`,
  164. transition: `all ${motionDurationSlow}`,
  165. '> *:not(:last-child)': {
  166. marginInlineEnd: marginXS
  167. },
  168. '> *': {
  169. flex: 'none'
  170. },
  171. '&-text': (0, _extends2.default)((0, _extends2.default)({}, _style.textEllipsis), {
  172. flex: 'auto'
  173. }),
  174. '&-remove': {
  175. position: 'relative',
  176. color: colorBorder,
  177. cursor: 'pointer',
  178. transition: `all ${motionDurationSlow}`,
  179. '&:hover': {
  180. color: token.colorLinkHover
  181. },
  182. '&::after': {
  183. position: 'absolute',
  184. insert: `-${transferItemPaddingVertical}px -50%`,
  185. content: '""'
  186. }
  187. },
  188. [`&:not(${componentCls}-list-content-item-disabled)`]: {
  189. '&:hover': {
  190. backgroundColor: token.controlItemBgHover,
  191. cursor: 'pointer'
  192. },
  193. [`&${componentCls}-list-content-item-checked:hover`]: {
  194. backgroundColor: controlItemBgActiveHover
  195. }
  196. },
  197. '&-checked': {
  198. backgroundColor: controlItemBgActive
  199. },
  200. '&-disabled': {
  201. color: colorTextDisabled,
  202. cursor: 'not-allowed'
  203. }
  204. },
  205. // Do not change hover style when `oneWay` mode
  206. [`&-show-remove ${componentCls}-list-content-item:not(${componentCls}-list-content-item-disabled):hover`]: {
  207. background: 'transparent',
  208. cursor: 'default'
  209. }
  210. },
  211. '&-pagination': {
  212. padding: `${token.paddingXS}px 0`,
  213. textAlign: 'end',
  214. borderTop: `${lineWidth}px ${lineType} ${colorSplit}`
  215. },
  216. '&-body-not-found': {
  217. flex: 'none',
  218. width: '100%',
  219. margin: 'auto 0',
  220. color: colorTextDisabled,
  221. textAlign: 'center'
  222. },
  223. '&-footer': {
  224. borderTop: `${lineWidth}px ${lineType} ${colorSplit}`
  225. },
  226. '&-checkbox': {
  227. lineHeight: 1
  228. }
  229. };
  230. };
  231. const genTransferStyle = token => {
  232. const {
  233. antCls,
  234. iconCls,
  235. componentCls,
  236. transferHeaderHeight,
  237. marginXS,
  238. marginXXS,
  239. fontSizeIcon,
  240. fontSize,
  241. lineHeight
  242. } = token;
  243. return {
  244. [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  245. position: 'relative',
  246. display: 'flex',
  247. alignItems: 'stretch',
  248. [`${componentCls}-disabled`]: {
  249. [`${componentCls}-list`]: {
  250. background: token.colorBgContainerDisabled
  251. }
  252. },
  253. [`${componentCls}-list`]: genTransferListStyle(token),
  254. [`${componentCls}-operation`]: {
  255. display: 'flex',
  256. flex: 'none',
  257. flexDirection: 'column',
  258. alignSelf: 'center',
  259. margin: `0 ${marginXS}px`,
  260. verticalAlign: 'middle',
  261. [`${antCls}-btn`]: {
  262. display: 'block',
  263. '&:first-child': {
  264. marginBottom: marginXXS
  265. },
  266. [iconCls]: {
  267. fontSize: fontSizeIcon
  268. }
  269. }
  270. },
  271. [`${antCls}-empty-image`]: {
  272. maxHeight: transferHeaderHeight / 2 - Math.round(fontSize * lineHeight)
  273. }
  274. })
  275. };
  276. };
  277. const genTransferRTLStyle = token => {
  278. const {
  279. componentCls
  280. } = token;
  281. return {
  282. [`${componentCls}-rtl`]: {
  283. direction: 'rtl'
  284. }
  285. };
  286. };
  287. // ============================== Export ==============================
  288. var _default = exports.default = (0, _internal.genComponentStyleHook)('Transfer', token => {
  289. const {
  290. fontSize,
  291. lineHeight,
  292. lineWidth,
  293. controlHeightLG,
  294. controlHeight
  295. } = token;
  296. const fontHeight = Math.round(fontSize * lineHeight);
  297. const transferHeaderHeight = controlHeightLG;
  298. const transferItemHeight = controlHeight;
  299. const transferToken = (0, _internal.mergeToken)(token, {
  300. transferItemHeight,
  301. transferHeaderHeight,
  302. transferHeaderVerticalPadding: Math.ceil((transferHeaderHeight - lineWidth - fontHeight) / 2),
  303. transferItemPaddingVertical: (transferItemHeight - fontHeight) / 2
  304. });
  305. return [genTransferStyle(transferToken), genTransferCustomizeStyle(transferToken), genTransferStatusStyle(transferToken), genTransferRTLStyle(transferToken)];
  306. }, {
  307. listWidth: 180,
  308. listHeight: 200,
  309. listWidthLG: 250
  310. });