single.less 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. @import (reference) '../../style/themes/index';
  2. @select-prefix-cls: ~'@{ant-prefix}-select';
  3. @selection-item-padding: ceil(@font-size-base * 1.25);
  4. .@{select-prefix-cls}-single {
  5. // ========================= Selector =========================
  6. .@{select-prefix-cls}-selector {
  7. display: flex;
  8. .@{select-prefix-cls}-selection-search {
  9. position: absolute;
  10. top: 0;
  11. right: @input-padding-horizontal-base;
  12. bottom: 0;
  13. left: @input-padding-horizontal-base;
  14. &-input {
  15. width: 100%;
  16. }
  17. }
  18. .@{select-prefix-cls}-selection-item,
  19. .@{select-prefix-cls}-selection-placeholder {
  20. padding: 0;
  21. line-height: @select-height-without-border;
  22. transition: all 0.3s;
  23. // Firefox inline-block position calculation is not same as Chrome & Safari. Patch this:
  24. @supports (-moz-appearance: meterbar) {
  25. & {
  26. line-height: @select-height-without-border;
  27. }
  28. }
  29. }
  30. .@{select-prefix-cls}-selection-item {
  31. position: relative;
  32. user-select: none;
  33. }
  34. .@{select-prefix-cls}-selection-placeholder {
  35. transition: none;
  36. pointer-events: none;
  37. }
  38. // For common baseline align
  39. &::after,
  40. /* For '' value baseline align */
  41. .@{select-prefix-cls}-selection-item::after,
  42. /* For undefined value baseline align */
  43. .@{select-prefix-cls}-selection-placeholder::after {
  44. display: inline-block;
  45. width: 0;
  46. visibility: hidden;
  47. content: '\a0';
  48. }
  49. }
  50. // With arrow should provides `padding-right` to show the arrow
  51. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-search {
  52. right: @input-padding-horizontal-base + @font-size-base;
  53. }
  54. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-item,
  55. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-placeholder {
  56. padding-right: @selection-item-padding;
  57. }
  58. // Opacity selection if open
  59. &.@{select-prefix-cls}-open .@{select-prefix-cls}-selection-item {
  60. color: @input-placeholder-color;
  61. }
  62. // ========================== Input ==========================
  63. // We only change the style of non-customize input which is only support by `combobox` mode.
  64. // Not customize
  65. &:not(.@{select-prefix-cls}-customize-input) {
  66. .@{select-prefix-cls}-selector {
  67. width: 100%;
  68. height: @input-height-base;
  69. padding: 0 @input-padding-horizontal-base;
  70. .@{select-prefix-cls}-selection-search-input {
  71. height: @select-height-without-border;
  72. }
  73. &::after {
  74. line-height: @select-height-without-border;
  75. }
  76. }
  77. }
  78. &.@{select-prefix-cls}-customize-input {
  79. .@{select-prefix-cls}-selector {
  80. &::after {
  81. display: none;
  82. }
  83. .@{select-prefix-cls}-selection-search {
  84. position: static;
  85. width: 100%;
  86. }
  87. .@{select-prefix-cls}-selection-placeholder {
  88. position: absolute;
  89. right: 0;
  90. left: 0;
  91. padding: 0 @input-padding-horizontal-base;
  92. &::after {
  93. display: none;
  94. }
  95. }
  96. }
  97. }
  98. // ============================================================
  99. // == Size ==
  100. // ============================================================
  101. .select-size(@suffix, @input-height) {
  102. @merged-cls: ~'@{select-prefix-cls}-@{suffix}';
  103. &.@{merged-cls}:not(.@{select-prefix-cls}-customize-input) {
  104. .@{select-prefix-cls}-selector {
  105. height: @input-height;
  106. &::after,
  107. .@{select-prefix-cls}-selection-item,
  108. .@{select-prefix-cls}-selection-placeholder {
  109. line-height: @input-height - 2 * @border-width-base;
  110. }
  111. }
  112. // Not customize
  113. &:not(.@{select-prefix-cls}-customize-input) {
  114. .@{select-prefix-cls}-selection-search-input {
  115. height: @input-height - 2 * @border-width-base;
  116. }
  117. }
  118. }
  119. }
  120. .select-size('lg', @select-single-item-height-lg);
  121. .select-size('sm', @input-height-sm);
  122. // Size small need additional set padding
  123. &.@{select-prefix-cls}-sm {
  124. &:not(.@{select-prefix-cls}-customize-input) {
  125. .@{select-prefix-cls}-selection-search {
  126. right: @input-padding-horizontal-sm;
  127. left: @input-padding-horizontal-sm;
  128. }
  129. .@{select-prefix-cls}-selector {
  130. padding: 0 @input-padding-horizontal-sm;
  131. }
  132. // With arrow should provides `padding-right` to show the arrow
  133. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-search {
  134. right: @input-padding-horizontal-sm + @font-size-base * 1.5;
  135. }
  136. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-item,
  137. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-placeholder {
  138. padding-right: @font-size-base * 1.5;
  139. }
  140. }
  141. }
  142. &.@{select-prefix-cls}-lg {
  143. &:not(.@{select-prefix-cls}-customize-input) {
  144. .@{select-prefix-cls}-selector {
  145. padding: 0 @input-padding-horizontal-lg;
  146. }
  147. }
  148. }
  149. }