single.less 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 .3s, visibility 0s;
  23. }
  24. .@{select-prefix-cls}-selection-item {
  25. position: relative;
  26. user-select: none;
  27. }
  28. .@{select-prefix-cls}-selection-placeholder {
  29. transition: none;
  30. pointer-events: none;
  31. }
  32. // For common baseline align
  33. &::after,
  34. /* For '' value baseline align */
  35. .@{select-prefix-cls}-selection-item::after,
  36. /* For undefined value baseline align */
  37. .@{select-prefix-cls}-selection-placeholder::after {
  38. display: inline-block;
  39. width: 0;
  40. visibility: hidden;
  41. content: '\a0';
  42. }
  43. }
  44. // With arrow should provides `padding-right` to show the arrow
  45. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-search {
  46. right: @input-padding-horizontal-base + @font-size-base;
  47. }
  48. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-item,
  49. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-placeholder {
  50. padding-right: @selection-item-padding;
  51. }
  52. // Opacity selection if open
  53. &.@{select-prefix-cls}-open .@{select-prefix-cls}-selection-item {
  54. color: @input-placeholder-color;
  55. }
  56. // ========================== Input ==========================
  57. // We only change the style of non-customize input which is only support by `combobox` mode.
  58. // Not customize
  59. &:not(.@{select-prefix-cls}-customize-input) {
  60. .@{select-prefix-cls}-selector {
  61. width: 100%;
  62. height: @input-height-base;
  63. padding: 0 @input-padding-horizontal-base;
  64. .@{select-prefix-cls}-selection-search-input {
  65. height: @select-height-without-border;
  66. }
  67. &::after {
  68. line-height: @select-height-without-border;
  69. }
  70. }
  71. }
  72. &.@{select-prefix-cls}-customize-input {
  73. .@{select-prefix-cls}-selector {
  74. &::after {
  75. display: none;
  76. }
  77. .@{select-prefix-cls}-selection-search {
  78. position: static;
  79. width: 100%;
  80. }
  81. .@{select-prefix-cls}-selection-placeholder {
  82. position: absolute;
  83. right: 0;
  84. left: 0;
  85. padding: 0 @input-padding-horizontal-base;
  86. &::after {
  87. display: none;
  88. }
  89. }
  90. }
  91. }
  92. // ============================================================
  93. // == Size ==
  94. // ============================================================
  95. .select-size(@suffix, @input-height) {
  96. @merged-cls: ~'@{select-prefix-cls}-@{suffix}';
  97. &.@{merged-cls}:not(.@{select-prefix-cls}-customize-input) {
  98. .@{select-prefix-cls}-selector {
  99. height: @input-height;
  100. &::after,
  101. .@{select-prefix-cls}-selection-item,
  102. .@{select-prefix-cls}-selection-placeholder {
  103. line-height: @input-height - 2 * @border-width-base;
  104. }
  105. }
  106. // Not customize
  107. &:not(.@{select-prefix-cls}-customize-input) {
  108. .@{select-prefix-cls}-selection-search-input {
  109. height: @input-height - 2 * @border-width-base;
  110. }
  111. }
  112. }
  113. }
  114. .select-size('lg', @select-single-item-height-lg);
  115. .select-size('sm', @input-height-sm);
  116. // Size small need additional set padding
  117. &.@{select-prefix-cls}-sm {
  118. &:not(.@{select-prefix-cls}-customize-input) {
  119. .@{select-prefix-cls}-selection-search {
  120. right: @input-padding-horizontal-sm;
  121. left: @input-padding-horizontal-sm;
  122. }
  123. .@{select-prefix-cls}-selector {
  124. padding: 0 @input-padding-horizontal-sm;
  125. }
  126. // With arrow should provides `padding-right` to show the arrow
  127. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-search {
  128. right: @input-padding-horizontal-sm + @font-size-base * 1.5;
  129. }
  130. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-item,
  131. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selection-placeholder {
  132. padding-right: @font-size-base * 1.5;
  133. }
  134. }
  135. }
  136. &.@{select-prefix-cls}-lg {
  137. &:not(.@{select-prefix-cls}-customize-input) {
  138. .@{select-prefix-cls}-selector {
  139. padding: 0 @input-padding-horizontal-lg;
  140. }
  141. }
  142. }
  143. }