mixin.less 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @input-affix-with-clear-btn-width: 38px;
  4. // size mixins for input
  5. .input-lg() {
  6. padding: @input-padding-vertical-lg @input-padding-horizontal-lg;
  7. font-size: @font-size-lg;
  8. }
  9. .input-sm() {
  10. padding: @input-padding-vertical-sm @input-padding-horizontal-sm;
  11. }
  12. // input status
  13. // == when focus or active
  14. .active(@borderColor: @primary-color; @hoverBorderColor: @primary-color-hover; @outlineColor: @primary-color-outline) {
  15. & when (@theme = dark) {
  16. border-color: @borderColor;
  17. }
  18. & when (not (@theme = dark) and not (@theme = variable)) {
  19. border-color: @hoverBorderColor;
  20. }
  21. & when not (@theme = variable) {
  22. box-shadow: @input-outline-offset @outline-blur-size @outline-width
  23. fade(@borderColor, @outline-fade);
  24. }
  25. & when (@theme = variable) {
  26. border-color: @hoverBorderColor;
  27. box-shadow: @input-outline-offset @outline-blur-size @outline-width @outlineColor;
  28. }
  29. border-right-width: @border-width-base;
  30. outline: 0;
  31. }
  32. // == when hover
  33. .hover(@color: @input-hover-border-color) {
  34. border-color: @color;
  35. border-right-width: @border-width-base;
  36. }
  37. .disabled() {
  38. color: @input-disabled-color;
  39. background-color: @input-disabled-bg;
  40. border-color: @input-border-color;
  41. box-shadow: none;
  42. cursor: not-allowed;
  43. opacity: 1;
  44. &:hover {
  45. .hover(@input-border-color);
  46. }
  47. }
  48. // Basic style for input
  49. .input() {
  50. position: relative;
  51. display: inline-block;
  52. width: 100%;
  53. min-width: 0;
  54. padding: @input-padding-vertical-base @input-padding-horizontal-base;
  55. color: @input-color;
  56. font-size: @font-size-base;
  57. line-height: @line-height-base;
  58. background-color: @input-bg;
  59. background-image: none;
  60. border: @border-width-base @border-style-base @input-border-color;
  61. border-radius: @control-border-radius;
  62. transition: all 0.3s;
  63. .placeholder(); // Reset placeholder
  64. &:hover {
  65. .hover();
  66. }
  67. &:focus,
  68. &-focused {
  69. .active();
  70. }
  71. &-disabled {
  72. .disabled();
  73. }
  74. &[disabled] {
  75. .disabled();
  76. }
  77. &-borderless {
  78. &,
  79. &:hover,
  80. &:focus,
  81. &-focused,
  82. &-disabled,
  83. &[disabled] {
  84. background-color: transparent;
  85. border: none;
  86. box-shadow: none;
  87. }
  88. }
  89. // Reset height for `textarea`s
  90. textarea& {
  91. max-width: 100%; // prevent textearea resize from coming out of its container
  92. height: auto;
  93. min-height: @input-height-base;
  94. line-height: @line-height-base;
  95. vertical-align: bottom;
  96. transition: all 0.3s, height 0s;
  97. }
  98. // Size
  99. &-lg {
  100. .input-lg();
  101. }
  102. &-sm {
  103. .input-sm();
  104. }
  105. }
  106. // label input
  107. .input-group(@inputClass) {
  108. position: relative;
  109. display: table;
  110. width: 100%;
  111. border-collapse: separate;
  112. border-spacing: 0;
  113. // Undo padding and float of grid classes
  114. &[class*='col-'] {
  115. float: none;
  116. padding-right: 0;
  117. padding-left: 0;
  118. }
  119. > [class*='col-'] {
  120. padding-right: 8px;
  121. &:last-child {
  122. padding-right: 0;
  123. }
  124. }
  125. &-addon,
  126. &-wrap,
  127. > .@{inputClass} {
  128. display: table-cell;
  129. &:not(:first-child):not(:last-child) {
  130. border-radius: 0;
  131. }
  132. }
  133. &-addon,
  134. &-wrap {
  135. width: 1px; // To make addon/wrap as small as possible
  136. white-space: nowrap;
  137. vertical-align: middle;
  138. }
  139. &-wrap > * {
  140. display: block !important;
  141. }
  142. .@{inputClass} {
  143. float: left;
  144. width: 100%;
  145. margin-bottom: 0;
  146. text-align: inherit;
  147. &:focus {
  148. z-index: 1; // Fix https://gw.alipayobjects.com/zos/rmsportal/DHNpoqfMXSfrSnlZvhsJ.png
  149. border-right-width: 1px;
  150. }
  151. &:hover {
  152. z-index: 1;
  153. border-right-width: 1px;
  154. .@{ant-prefix}-input-search-with-button & {
  155. z-index: 0;
  156. }
  157. }
  158. }
  159. &-addon {
  160. position: relative;
  161. padding: 0 @input-padding-horizontal-base;
  162. color: @input-color;
  163. font-weight: normal;
  164. font-size: @font-size-base;
  165. text-align: center;
  166. background-color: @input-addon-bg;
  167. border: @border-width-base @border-style-base @input-border-color;
  168. border-radius: @control-border-radius;
  169. transition: all 0.3s;
  170. // Reset Select's style in addon
  171. .@{ant-prefix}-select {
  172. margin: -(@input-padding-vertical-base + 1px) (-@input-padding-horizontal-base);
  173. &.@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
  174. .@{ant-prefix}-select-selector {
  175. background-color: inherit;
  176. border: @border-width-base @border-style-base transparent;
  177. box-shadow: none;
  178. }
  179. &-open,
  180. &-focused {
  181. .@{ant-prefix}-select-selector {
  182. color: @primary-color;
  183. }
  184. }
  185. }
  186. // https://github.com/ant-design/ant-design/issues/31333
  187. .@{ant-prefix}-cascader-picker {
  188. margin: -9px (-@control-padding-horizontal);
  189. background-color: transparent;
  190. .@{ant-prefix}-cascader-input {
  191. text-align: left;
  192. border: 0;
  193. box-shadow: none;
  194. }
  195. }
  196. }
  197. // Reset rounded corners
  198. > .@{inputClass}:first-child,
  199. &-addon:first-child {
  200. border-top-right-radius: 0;
  201. border-bottom-right-radius: 0;
  202. // Reset Select's style in addon
  203. .@{ant-prefix}-select .@{ant-prefix}-select-selector {
  204. border-top-right-radius: 0;
  205. border-bottom-right-radius: 0;
  206. }
  207. }
  208. > .@{inputClass}-affix-wrapper {
  209. &:not(:first-child) .@{inputClass} {
  210. border-top-left-radius: 0;
  211. border-bottom-left-radius: 0;
  212. }
  213. &:not(:last-child) .@{inputClass} {
  214. border-top-right-radius: 0;
  215. border-bottom-right-radius: 0;
  216. }
  217. }
  218. &-addon:first-child {
  219. border-right: 0;
  220. }
  221. &-addon:last-child {
  222. border-left: 0;
  223. }
  224. > .@{inputClass}:last-child,
  225. &-addon:last-child {
  226. border-top-left-radius: 0;
  227. border-bottom-left-radius: 0;
  228. // Reset Select's style in addon
  229. .@{ant-prefix}-select .@{ant-prefix}-select-selector {
  230. border-top-left-radius: 0;
  231. border-bottom-left-radius: 0;
  232. }
  233. }
  234. // Sizing options
  235. &-lg .@{inputClass},
  236. &-lg > &-addon {
  237. .input-lg();
  238. }
  239. &-sm .@{inputClass},
  240. &-sm > &-addon {
  241. .input-sm();
  242. }
  243. // Fix https://github.com/ant-design/ant-design/issues/5754
  244. &-lg .@{ant-prefix}-select-single .@{ant-prefix}-select-selector {
  245. height: @input-height-lg;
  246. }
  247. &-sm .@{ant-prefix}-select-single .@{ant-prefix}-select-selector {
  248. height: @input-height-sm;
  249. }
  250. .@{inputClass}-affix-wrapper {
  251. &:not(:last-child) {
  252. border-top-right-radius: 0;
  253. border-bottom-right-radius: 0;
  254. .@{ant-prefix}-input-search & {
  255. border-top-left-radius: @control-border-radius;
  256. border-bottom-left-radius: @control-border-radius;
  257. }
  258. }
  259. &:not(:first-child),
  260. .@{ant-prefix}-input-search &:not(:first-child) {
  261. border-top-left-radius: 0;
  262. border-bottom-left-radius: 0;
  263. }
  264. }
  265. &&-compact {
  266. display: block;
  267. .clearfix();
  268. &-addon,
  269. &-wrap,
  270. > .@{inputClass} {
  271. &:not(:first-child):not(:last-child) {
  272. border-right-width: @border-width-base;
  273. &:hover {
  274. z-index: 1;
  275. }
  276. &:focus {
  277. z-index: 1;
  278. }
  279. }
  280. }
  281. & > * {
  282. display: inline-block;
  283. float: none;
  284. vertical-align: top; // https://github.com/ant-design/ant-design-pro/issues/139
  285. border-radius: 0;
  286. }
  287. & > .@{inputClass}-affix-wrapper,
  288. & > .@{inputClass}-number-affix-wrapper,
  289. & > .@{ant-prefix}-picker-range {
  290. display: inline-flex;
  291. }
  292. & > *:not(:last-child) {
  293. margin-right: -@border-width-base;
  294. border-right-width: @border-width-base;
  295. }
  296. // Undo float for .ant-input-group .ant-input
  297. .@{inputClass} {
  298. float: none;
  299. }
  300. // reset border for Select, DatePicker, AutoComplete, Cascader, Mention, TimePicker, Input
  301. & > .@{ant-prefix}-select > .@{ant-prefix}-select-selector,
  302. & > .@{ant-prefix}-select-auto-complete .@{ant-prefix}-input,
  303. & > .@{ant-prefix}-cascader-picker .@{ant-prefix}-input,
  304. & > .@{ant-prefix}-input-group-wrapper .@{ant-prefix}-input {
  305. border-right-width: @border-width-base;
  306. border-radius: 0;
  307. &:hover {
  308. z-index: 1;
  309. }
  310. &:focus {
  311. z-index: 1;
  312. }
  313. }
  314. & > .@{ant-prefix}-select-focused {
  315. z-index: 1;
  316. }
  317. // update z-index for arrow icon
  318. & > .@{ant-prefix}-select > .@{ant-prefix}-select-arrow {
  319. z-index: 1; // https://github.com/ant-design/ant-design/issues/20371
  320. }
  321. & > *:first-child,
  322. & > .@{ant-prefix}-select:first-child > .@{ant-prefix}-select-selector,
  323. & > .@{ant-prefix}-select-auto-complete:first-child .@{ant-prefix}-input,
  324. & > .@{ant-prefix}-cascader-picker:first-child .@{ant-prefix}-input {
  325. border-top-left-radius: @control-border-radius;
  326. border-bottom-left-radius: @control-border-radius;
  327. }
  328. & > *:last-child,
  329. & > .@{ant-prefix}-select:last-child > .@{ant-prefix}-select-selector,
  330. & > .@{ant-prefix}-cascader-picker:last-child .@{ant-prefix}-input,
  331. & > .@{ant-prefix}-cascader-picker-focused:last-child .@{ant-prefix}-input {
  332. border-right-width: @border-width-base;
  333. border-top-right-radius: @control-border-radius;
  334. border-bottom-right-radius: @control-border-radius;
  335. }
  336. // https://github.com/ant-design/ant-design/issues/12493
  337. & > .@{ant-prefix}-select-auto-complete .@{ant-prefix}-input {
  338. vertical-align: top;
  339. }
  340. .@{ant-prefix}-input-group-wrapper + .@{ant-prefix}-input-group-wrapper {
  341. margin-left: -1px;
  342. .@{ant-prefix}-input-affix-wrapper {
  343. border-radius: 0;
  344. }
  345. }
  346. .@{ant-prefix}-input-group-wrapper:not(:last-child) {
  347. &.@{ant-prefix}-input-search > .@{ant-prefix}-input-group {
  348. & > .@{ant-prefix}-input-group-addon > .@{ant-prefix}-input-search-button {
  349. border-radius: 0;
  350. }
  351. & > .@{ant-prefix}-input {
  352. border-radius: @control-border-radius 0 0 @control-border-radius;
  353. }
  354. }
  355. }
  356. }
  357. }
  358. .status-color(
  359. @prefix-cls: @input-prefix-cls;
  360. @text-color: @input-color;
  361. @border-color: @input-border-color;
  362. @background-color: @input-bg;
  363. @hoverBorderColor: @primary-color-hover;
  364. @outlineColor: @primary-color-outline;
  365. ) {
  366. &:not(.@{prefix-cls}-disabled):not(.@{prefix-cls}-borderless).@{prefix-cls} {
  367. &,
  368. &:hover {
  369. background: @background-color;
  370. border-color: @border-color;
  371. }
  372. &:focus,
  373. &-focused {
  374. .active(@text-color, @hoverBorderColor, @outlineColor);
  375. }
  376. }
  377. }
  378. .status-color-common(
  379. @prefix-cls: @input-prefix-cls;
  380. @text-color: @input-color;
  381. @border-color: @input-border-color;
  382. @background-color: @input-bg;
  383. @hoverBorderColor: @primary-color-hover;
  384. @outlineColor: @primary-color-outline;
  385. ) {
  386. .@{prefix-cls}-prefix {
  387. color: @text-color;
  388. }
  389. }
  390. .group-status-color(
  391. @prefix-cls: @input-prefix-cls;
  392. @text-color: @input-color;
  393. @border-color: @input-border-color;
  394. ) {
  395. .@{prefix-cls}-group-addon {
  396. color: @text-color;
  397. border-color: @border-color;
  398. }
  399. }