index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. import { unit } from '@ant-design/cssinjs';
  2. import { clearFix, resetComponent } from '../../style';
  3. import { genCompactItemStyle } from '../../style/compact-item';
  4. import { genStyleHooks, mergeToken } from '../../theme/internal';
  5. import { initComponentToken, initInputToken } from './token';
  6. import { genBorderlessStyle, genFilledGroupStyle, genFilledStyle, genOutlinedGroupStyle, genOutlinedStyle, genUnderlinedStyle } from './variants';
  7. export { initComponentToken, initInputToken };
  8. export const genPlaceholderStyle = color => ({
  9. // Firefox
  10. '&::-moz-placeholder': {
  11. opacity: 1
  12. },
  13. '&::placeholder': {
  14. color,
  15. userSelect: 'none' // https://github.com/ant-design/ant-design/pull/32639
  16. },
  17. '&:placeholder-shown': {
  18. textOverflow: 'ellipsis'
  19. }
  20. });
  21. export const genActiveStyle = token => ({
  22. borderColor: token.activeBorderColor,
  23. boxShadow: token.activeShadow,
  24. outline: 0,
  25. backgroundColor: token.activeBg
  26. });
  27. const genInputLargeStyle = token => {
  28. const {
  29. paddingBlockLG,
  30. lineHeightLG,
  31. borderRadiusLG,
  32. paddingInlineLG
  33. } = token;
  34. return {
  35. padding: `${unit(paddingBlockLG)} ${unit(paddingInlineLG)}`,
  36. fontSize: token.inputFontSizeLG,
  37. lineHeight: lineHeightLG,
  38. borderRadius: borderRadiusLG
  39. };
  40. };
  41. export const genInputSmallStyle = token => ({
  42. padding: `${unit(token.paddingBlockSM)} ${unit(token.paddingInlineSM)}`,
  43. fontSize: token.inputFontSizeSM,
  44. borderRadius: token.borderRadiusSM
  45. });
  46. export const genBasicInputStyle = token => Object.assign(Object.assign({
  47. position: 'relative',
  48. display: 'inline-block',
  49. width: '100%',
  50. minWidth: 0,
  51. padding: `${unit(token.paddingBlock)} ${unit(token.paddingInline)}`,
  52. color: token.colorText,
  53. fontSize: token.inputFontSize,
  54. lineHeight: token.lineHeight,
  55. borderRadius: token.borderRadius,
  56. transition: `all ${token.motionDurationMid}`
  57. }, genPlaceholderStyle(token.colorTextPlaceholder)), {
  58. // Size
  59. '&-lg': Object.assign({}, genInputLargeStyle(token)),
  60. '&-sm': Object.assign({}, genInputSmallStyle(token)),
  61. // RTL
  62. '&-rtl, &-textarea-rtl': {
  63. direction: 'rtl'
  64. }
  65. });
  66. export const genInputGroupStyle = token => {
  67. const {
  68. componentCls,
  69. antCls
  70. } = token;
  71. return {
  72. position: 'relative',
  73. display: 'table',
  74. width: '100%',
  75. borderCollapse: 'separate',
  76. borderSpacing: 0,
  77. // Undo padding and float of grid classes
  78. "&[class*='col-']": {
  79. paddingInlineEnd: token.paddingXS,
  80. '&:last-child': {
  81. paddingInlineEnd: 0
  82. }
  83. },
  84. // Sizing options
  85. [`&-lg ${componentCls}, &-lg > ${componentCls}-group-addon`]: Object.assign({}, genInputLargeStyle(token)),
  86. [`&-sm ${componentCls}, &-sm > ${componentCls}-group-addon`]: Object.assign({}, genInputSmallStyle(token)),
  87. // Fix https://github.com/ant-design/ant-design/issues/5754
  88. [`&-lg ${antCls}-select-single ${antCls}-select-selector`]: {
  89. height: token.controlHeightLG
  90. },
  91. [`&-sm ${antCls}-select-single ${antCls}-select-selector`]: {
  92. height: token.controlHeightSM
  93. },
  94. [`> ${componentCls}`]: {
  95. display: 'table-cell',
  96. '&:not(:first-child):not(:last-child)': {
  97. borderRadius: 0
  98. }
  99. },
  100. [`${componentCls}-group`]: {
  101. '&-addon, &-wrap': {
  102. display: 'table-cell',
  103. width: 1,
  104. whiteSpace: 'nowrap',
  105. verticalAlign: 'middle',
  106. '&:not(:first-child):not(:last-child)': {
  107. borderRadius: 0
  108. }
  109. },
  110. '&-wrap > *': {
  111. display: 'block !important'
  112. },
  113. '&-addon': {
  114. position: 'relative',
  115. padding: `0 ${unit(token.paddingInline)}`,
  116. color: token.colorText,
  117. fontWeight: 'normal',
  118. fontSize: token.inputFontSize,
  119. textAlign: 'center',
  120. borderRadius: token.borderRadius,
  121. transition: `all ${token.motionDurationSlow}`,
  122. lineHeight: 1,
  123. // Reset Select's style in addon
  124. [`${antCls}-select`]: {
  125. margin: `${unit(token.calc(token.paddingBlock).add(1).mul(-1).equal())} ${unit(token.calc(token.paddingInline).mul(-1).equal())}`,
  126. [`&${antCls}-select-single:not(${antCls}-select-customize-input):not(${antCls}-pagination-size-changer)`]: {
  127. [`${antCls}-select-selector`]: {
  128. backgroundColor: 'inherit',
  129. border: `${unit(token.lineWidth)} ${token.lineType} transparent`,
  130. boxShadow: 'none'
  131. }
  132. }
  133. },
  134. // https://github.com/ant-design/ant-design/issues/31333
  135. [`${antCls}-cascader-picker`]: {
  136. margin: `-9px ${unit(token.calc(token.paddingInline).mul(-1).equal())}`,
  137. backgroundColor: 'transparent',
  138. [`${antCls}-cascader-input`]: {
  139. textAlign: 'start',
  140. border: 0,
  141. boxShadow: 'none'
  142. }
  143. }
  144. }
  145. },
  146. [componentCls]: {
  147. width: '100%',
  148. marginBottom: 0,
  149. textAlign: 'inherit',
  150. '&:focus': {
  151. zIndex: 1,
  152. // Fix https://gw.alipayobjects.com/zos/rmsportal/DHNpoqfMXSfrSnlZvhsJ.png
  153. borderInlineEndWidth: 1
  154. },
  155. '&:hover': {
  156. zIndex: 1,
  157. borderInlineEndWidth: 1,
  158. [`${componentCls}-search-with-button &`]: {
  159. zIndex: 0
  160. }
  161. }
  162. },
  163. // Reset rounded corners
  164. [`> ${componentCls}:first-child, ${componentCls}-group-addon:first-child`]: {
  165. borderStartEndRadius: 0,
  166. borderEndEndRadius: 0,
  167. // Reset Select's style in addon
  168. [`${antCls}-select ${antCls}-select-selector`]: {
  169. borderStartEndRadius: 0,
  170. borderEndEndRadius: 0
  171. }
  172. },
  173. [`> ${componentCls}-affix-wrapper`]: {
  174. [`&:not(:first-child) ${componentCls}`]: {
  175. borderStartStartRadius: 0,
  176. borderEndStartRadius: 0
  177. },
  178. [`&:not(:last-child) ${componentCls}`]: {
  179. borderStartEndRadius: 0,
  180. borderEndEndRadius: 0
  181. }
  182. },
  183. [`> ${componentCls}:last-child, ${componentCls}-group-addon:last-child`]: {
  184. borderStartStartRadius: 0,
  185. borderEndStartRadius: 0,
  186. // Reset Select's style in addon
  187. [`${antCls}-select ${antCls}-select-selector`]: {
  188. borderStartStartRadius: 0,
  189. borderEndStartRadius: 0
  190. }
  191. },
  192. [`${componentCls}-affix-wrapper`]: {
  193. '&:not(:last-child)': {
  194. borderStartEndRadius: 0,
  195. borderEndEndRadius: 0,
  196. [`${componentCls}-search &`]: {
  197. borderStartStartRadius: token.borderRadius,
  198. borderEndStartRadius: token.borderRadius
  199. }
  200. },
  201. [`&:not(:first-child), ${componentCls}-search &:not(:first-child)`]: {
  202. borderStartStartRadius: 0,
  203. borderEndStartRadius: 0
  204. }
  205. },
  206. [`&${componentCls}-group-compact`]: Object.assign(Object.assign({
  207. display: 'block'
  208. }, clearFix()), {
  209. [`${componentCls}-group-addon, ${componentCls}-group-wrap, > ${componentCls}`]: {
  210. '&:not(:first-child):not(:last-child)': {
  211. borderInlineEndWidth: token.lineWidth,
  212. '&:hover, &:focus': {
  213. zIndex: 1
  214. }
  215. }
  216. },
  217. '& > *': {
  218. display: 'inline-flex',
  219. float: 'none',
  220. verticalAlign: 'top',
  221. // https://github.com/ant-design/ant-design-pro/issues/139
  222. borderRadius: 0
  223. },
  224. [`
  225. & > ${componentCls}-affix-wrapper,
  226. & > ${componentCls}-number-affix-wrapper,
  227. & > ${antCls}-picker-range
  228. `]: {
  229. display: 'inline-flex'
  230. },
  231. '& > *:not(:last-child)': {
  232. marginInlineEnd: token.calc(token.lineWidth).mul(-1).equal(),
  233. borderInlineEndWidth: token.lineWidth
  234. },
  235. // Undo float for .ant-input-group .ant-input
  236. [componentCls]: {
  237. float: 'none'
  238. },
  239. // reset border for Select, DatePicker, AutoComplete, Cascader, Mention, TimePicker, Input
  240. [`& > ${antCls}-select > ${antCls}-select-selector,
  241. & > ${antCls}-select-auto-complete ${componentCls},
  242. & > ${antCls}-cascader-picker ${componentCls},
  243. & > ${componentCls}-group-wrapper ${componentCls}`]: {
  244. borderInlineEndWidth: token.lineWidth,
  245. borderRadius: 0,
  246. '&:hover, &:focus': {
  247. zIndex: 1
  248. }
  249. },
  250. [`& > ${antCls}-select-focused`]: {
  251. zIndex: 1
  252. },
  253. // update z-index for arrow icon
  254. [`& > ${antCls}-select > ${antCls}-select-arrow`]: {
  255. zIndex: 1 // https://github.com/ant-design/ant-design/issues/20371
  256. },
  257. [`& > *:first-child,
  258. & > ${antCls}-select:first-child > ${antCls}-select-selector,
  259. & > ${antCls}-select-auto-complete:first-child ${componentCls},
  260. & > ${antCls}-cascader-picker:first-child ${componentCls}`]: {
  261. borderStartStartRadius: token.borderRadius,
  262. borderEndStartRadius: token.borderRadius
  263. },
  264. [`& > *:last-child,
  265. & > ${antCls}-select:last-child > ${antCls}-select-selector,
  266. & > ${antCls}-cascader-picker:last-child ${componentCls},
  267. & > ${antCls}-cascader-picker-focused:last-child ${componentCls}`]: {
  268. borderInlineEndWidth: token.lineWidth,
  269. borderStartEndRadius: token.borderRadius,
  270. borderEndEndRadius: token.borderRadius
  271. },
  272. // https://github.com/ant-design/ant-design/issues/12493
  273. [`& > ${antCls}-select-auto-complete ${componentCls}`]: {
  274. verticalAlign: 'top'
  275. },
  276. [`${componentCls}-group-wrapper + ${componentCls}-group-wrapper`]: {
  277. marginInlineStart: token.calc(token.lineWidth).mul(-1).equal(),
  278. [`${componentCls}-affix-wrapper`]: {
  279. borderRadius: 0
  280. }
  281. },
  282. [`${componentCls}-group-wrapper:not(:last-child)`]: {
  283. [`&${componentCls}-search > ${componentCls}-group`]: {
  284. [`& > ${componentCls}-group-addon > ${componentCls}-search-button`]: {
  285. borderRadius: 0
  286. },
  287. [`& > ${componentCls}`]: {
  288. borderStartStartRadius: token.borderRadius,
  289. borderStartEndRadius: 0,
  290. borderEndEndRadius: 0,
  291. borderEndStartRadius: token.borderRadius
  292. }
  293. }
  294. }
  295. })
  296. };
  297. };
  298. export const genInputStyle = token => {
  299. const {
  300. componentCls,
  301. controlHeightSM,
  302. lineWidth,
  303. calc
  304. } = token;
  305. const FIXED_CHROME_COLOR_HEIGHT = 16;
  306. const colorSmallPadding = calc(controlHeightSM).sub(calc(lineWidth).mul(2)).sub(FIXED_CHROME_COLOR_HEIGHT).div(2).equal();
  307. return {
  308. [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, resetComponent(token)), genBasicInputStyle(token)), genOutlinedStyle(token)), genFilledStyle(token)), genBorderlessStyle(token)), genUnderlinedStyle(token)), {
  309. '&[type="color"]': {
  310. height: token.controlHeight,
  311. [`&${componentCls}-lg`]: {
  312. height: token.controlHeightLG
  313. },
  314. [`&${componentCls}-sm`]: {
  315. height: controlHeightSM,
  316. paddingTop: colorSmallPadding,
  317. paddingBottom: colorSmallPadding
  318. }
  319. },
  320. '&[type="search"]::-webkit-search-cancel-button, &[type="search"]::-webkit-search-decoration': {
  321. appearance: 'none'
  322. }
  323. })
  324. };
  325. };
  326. const genAllowClearStyle = token => {
  327. const {
  328. componentCls
  329. } = token;
  330. return {
  331. // ========================= Input =========================
  332. [`${componentCls}-clear-icon`]: {
  333. margin: 0,
  334. padding: 0,
  335. lineHeight: 0,
  336. color: token.colorTextQuaternary,
  337. fontSize: token.fontSizeIcon,
  338. verticalAlign: -1,
  339. // https://github.com/ant-design/ant-design/pull/18151
  340. // https://codesandbox.io/s/wizardly-sun-u10br
  341. cursor: 'pointer',
  342. transition: `color ${token.motionDurationSlow}`,
  343. border: 'none',
  344. outline: 'none',
  345. backgroundColor: 'transparent',
  346. '&:hover': {
  347. color: token.colorIcon
  348. },
  349. '&:active': {
  350. color: token.colorText
  351. },
  352. '&-hidden': {
  353. visibility: 'hidden'
  354. },
  355. '&-has-suffix': {
  356. margin: `0 ${unit(token.inputAffixPadding)}`
  357. }
  358. }
  359. };
  360. };
  361. export const genAffixStyle = token => {
  362. const {
  363. componentCls,
  364. inputAffixPadding,
  365. colorTextDescription,
  366. motionDurationSlow,
  367. colorIcon,
  368. colorIconHover,
  369. iconCls
  370. } = token;
  371. const affixCls = `${componentCls}-affix-wrapper`;
  372. const affixClsDisabled = `${componentCls}-affix-wrapper-disabled`;
  373. return {
  374. [affixCls]: Object.assign(Object.assign(Object.assign(Object.assign({}, genBasicInputStyle(token)), {
  375. display: 'inline-flex',
  376. [`&:not(${componentCls}-disabled):hover`]: {
  377. zIndex: 1,
  378. [`${componentCls}-search-with-button &`]: {
  379. zIndex: 0
  380. }
  381. },
  382. '&-focused, &:focus': {
  383. zIndex: 1
  384. },
  385. [`> input${componentCls}`]: {
  386. padding: 0
  387. },
  388. [`> input${componentCls}, > textarea${componentCls}`]: {
  389. fontSize: 'inherit',
  390. border: 'none',
  391. borderRadius: 0,
  392. outline: 'none',
  393. background: 'transparent',
  394. color: 'inherit',
  395. '&::-ms-reveal': {
  396. display: 'none'
  397. },
  398. '&:focus': {
  399. boxShadow: 'none !important'
  400. }
  401. },
  402. '&::before': {
  403. display: 'inline-block',
  404. width: 0,
  405. visibility: 'hidden',
  406. content: '"\\a0"'
  407. },
  408. [componentCls]: {
  409. '&-prefix, &-suffix': {
  410. display: 'flex',
  411. flex: 'none',
  412. alignItems: 'center',
  413. '> *:not(:last-child)': {
  414. marginInlineEnd: token.paddingXS
  415. }
  416. },
  417. '&-show-count-suffix': {
  418. color: colorTextDescription,
  419. direction: 'ltr'
  420. },
  421. '&-show-count-has-suffix': {
  422. marginInlineEnd: token.paddingXXS
  423. },
  424. '&-prefix': {
  425. marginInlineEnd: inputAffixPadding
  426. },
  427. '&-suffix': {
  428. marginInlineStart: inputAffixPadding
  429. }
  430. }
  431. }), genAllowClearStyle(token)), {
  432. // password
  433. [`${iconCls}${componentCls}-password-icon`]: {
  434. color: colorIcon,
  435. cursor: 'pointer',
  436. transition: `all ${motionDurationSlow}`,
  437. '&:hover': {
  438. color: colorIconHover
  439. }
  440. }
  441. }),
  442. // 覆盖 affix-wrapper borderRadius!
  443. [`${componentCls}-underlined`]: {
  444. borderRadius: 0
  445. },
  446. [affixClsDisabled]: {
  447. // password disabled
  448. [`${iconCls}${componentCls}-password-icon`]: {
  449. color: colorIcon,
  450. cursor: 'not-allowed',
  451. '&:hover': {
  452. color: colorIcon
  453. }
  454. }
  455. }
  456. };
  457. };
  458. const genGroupStyle = token => {
  459. const {
  460. componentCls,
  461. borderRadiusLG,
  462. borderRadiusSM
  463. } = token;
  464. return {
  465. [`${componentCls}-group`]: Object.assign(Object.assign(Object.assign({}, resetComponent(token)), genInputGroupStyle(token)), {
  466. '&-rtl': {
  467. direction: 'rtl'
  468. },
  469. '&-wrapper': Object.assign(Object.assign(Object.assign({
  470. display: 'inline-block',
  471. width: '100%',
  472. textAlign: 'start',
  473. verticalAlign: 'top',
  474. '&-rtl': {
  475. direction: 'rtl'
  476. },
  477. // Size
  478. '&-lg': {
  479. [`${componentCls}-group-addon`]: {
  480. borderRadius: borderRadiusLG,
  481. fontSize: token.inputFontSizeLG
  482. }
  483. },
  484. '&-sm': {
  485. [`${componentCls}-group-addon`]: {
  486. borderRadius: borderRadiusSM
  487. }
  488. }
  489. }, genOutlinedGroupStyle(token)), genFilledGroupStyle(token)), {
  490. // '&-disabled': {
  491. // [`${componentCls}-group-addon`]: {
  492. // ...genDisabledStyle(token),
  493. // },
  494. // },
  495. // Fix the issue of using icons in Space Compact mode
  496. // https://github.com/ant-design/ant-design/issues/42122
  497. [`&:not(${componentCls}-compact-first-item):not(${componentCls}-compact-last-item)${componentCls}-compact-item`]: {
  498. [`${componentCls}, ${componentCls}-group-addon`]: {
  499. borderRadius: 0
  500. }
  501. },
  502. [`&:not(${componentCls}-compact-last-item)${componentCls}-compact-first-item`]: {
  503. [`${componentCls}, ${componentCls}-group-addon`]: {
  504. borderStartEndRadius: 0,
  505. borderEndEndRadius: 0
  506. }
  507. },
  508. [`&:not(${componentCls}-compact-first-item)${componentCls}-compact-last-item`]: {
  509. [`${componentCls}, ${componentCls}-group-addon`]: {
  510. borderStartStartRadius: 0,
  511. borderEndStartRadius: 0
  512. }
  513. },
  514. // Fix the issue of input use show-count param in space compact mode
  515. // https://github.com/ant-design/ant-design/issues/46872
  516. [`&:not(${componentCls}-compact-last-item)${componentCls}-compact-item`]: {
  517. [`${componentCls}-affix-wrapper`]: {
  518. borderStartEndRadius: 0,
  519. borderEndEndRadius: 0
  520. }
  521. },
  522. // Fix the issue of input use `addonAfter` param in space compact mode
  523. // https://github.com/ant-design/ant-design/issues/52483
  524. [`&:not(${componentCls}-compact-first-item)${componentCls}-compact-item`]: {
  525. [`${componentCls}-affix-wrapper`]: {
  526. borderStartStartRadius: 0,
  527. borderEndStartRadius: 0
  528. }
  529. }
  530. })
  531. })
  532. };
  533. };
  534. const genSearchInputStyle = token => {
  535. const {
  536. componentCls,
  537. antCls
  538. } = token;
  539. const searchPrefixCls = `${componentCls}-search`;
  540. return {
  541. [searchPrefixCls]: {
  542. [componentCls]: {
  543. '&:not([disabled]):hover, &:not([disabled]):focus': {
  544. [`+ ${componentCls}-group-addon ${searchPrefixCls}-button:not(${antCls}-btn-color-primary):not(${antCls}-btn-variant-text)`]: {
  545. borderInlineStartColor: token.colorPrimaryHover
  546. }
  547. }
  548. },
  549. [`${componentCls}-affix-wrapper`]: {
  550. height: token.controlHeight,
  551. borderRadius: 0
  552. },
  553. // fix slight height diff in Firefox:
  554. // https://ant.design/components/auto-complete-cn/#auto-complete-demo-certain-category
  555. [`${componentCls}-lg`]: {
  556. lineHeight: token.calc(token.lineHeightLG).sub(0.0002).equal()
  557. },
  558. [`> ${componentCls}-group`]: {
  559. [`> ${componentCls}-group-addon:last-child`]: {
  560. insetInlineStart: -1,
  561. padding: 0,
  562. border: 0,
  563. [`${searchPrefixCls}-button`]: {
  564. // Fix https://github.com/ant-design/ant-design/issues/47150
  565. marginInlineEnd: -1,
  566. borderStartStartRadius: 0,
  567. borderEndStartRadius: 0,
  568. boxShadow: 'none'
  569. },
  570. [`${searchPrefixCls}-button:not(${antCls}-btn-color-primary)`]: {
  571. color: token.colorTextDescription,
  572. '&:not([disabled]):hover': {
  573. color: token.colorPrimaryHover
  574. },
  575. '&:active': {
  576. color: token.colorPrimaryActive
  577. },
  578. [`&${antCls}-btn-loading::before`]: {
  579. inset: 0
  580. }
  581. }
  582. }
  583. },
  584. [`${searchPrefixCls}-button`]: {
  585. height: token.controlHeight,
  586. '&:hover, &:focus': {
  587. zIndex: 1
  588. }
  589. },
  590. '&-large': {
  591. [`${componentCls}-affix-wrapper, ${searchPrefixCls}-button`]: {
  592. height: token.controlHeightLG
  593. }
  594. },
  595. '&-small': {
  596. [`${componentCls}-affix-wrapper, ${searchPrefixCls}-button`]: {
  597. height: token.controlHeightSM
  598. }
  599. },
  600. '&-rtl': {
  601. direction: 'rtl'
  602. },
  603. // ===================== Compact Item Customized Styles =====================
  604. [`&${componentCls}-compact-item`]: {
  605. [`&:not(${componentCls}-compact-last-item)`]: {
  606. [`${componentCls}-group-addon`]: {
  607. [`${componentCls}-search-button`]: {
  608. marginInlineEnd: token.calc(token.lineWidth).mul(-1).equal(),
  609. borderRadius: 0
  610. }
  611. }
  612. },
  613. [`&:not(${componentCls}-compact-first-item)`]: {
  614. [`${componentCls},${componentCls}-affix-wrapper`]: {
  615. borderRadius: 0
  616. }
  617. },
  618. [`> ${componentCls}-group-addon ${componentCls}-search-button,
  619. > ${componentCls},
  620. ${componentCls}-affix-wrapper`]: {
  621. '&:hover, &:focus, &:active': {
  622. zIndex: 2
  623. }
  624. },
  625. [`> ${componentCls}-affix-wrapper-focused`]: {
  626. zIndex: 2
  627. }
  628. }
  629. }
  630. };
  631. };
  632. // ============================== Range ===============================
  633. const genRangeStyle = token => {
  634. const {
  635. componentCls
  636. } = token;
  637. return {
  638. [`${componentCls}-out-of-range`]: {
  639. [`&, & input, & textarea, ${componentCls}-show-count-suffix, ${componentCls}-data-count`]: {
  640. color: token.colorError
  641. }
  642. }
  643. };
  644. };
  645. // ============================== Export ==============================
  646. export const useSharedStyle = genStyleHooks(['Input', 'Shared'], token => {
  647. const inputToken = mergeToken(token, initInputToken(token));
  648. return [genInputStyle(inputToken), genAffixStyle(inputToken)];
  649. }, initComponentToken, {
  650. resetFont: false
  651. });
  652. export default genStyleHooks(['Input', 'Component'], token => {
  653. const inputToken = mergeToken(token, initInputToken(token));
  654. return [genGroupStyle(inputToken), genSearchInputStyle(inputToken), genRangeStyle(inputToken),
  655. // =====================================================
  656. // == Space Compact ==
  657. // =====================================================
  658. genCompactItemStyle(inputToken)];
  659. }, initComponentToken, {
  660. resetFont: false
  661. });