multiple.less 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. @import (reference) '../../style/themes/index';
  2. @select-prefix-cls: ~'@{ant-prefix}-select';
  3. @select-overflow-prefix-cls: ~'@{select-prefix-cls}-selection-overflow';
  4. @select-multiple-item-border-width: 1px;
  5. @select-multiple-padding: max(
  6. @input-padding-vertical-base - @select-multiple-item-border-width -
  7. @select-multiple-item-spacing-half,
  8. 0
  9. );
  10. /**
  11. * Do not merge `height` & `line-height` under style with `selection` & `search`,
  12. * since chrome may update to redesign with its align logic.
  13. */
  14. // =========================== Overflow ===========================
  15. .@{select-overflow-prefix-cls} {
  16. position: relative;
  17. display: flex;
  18. flex: auto;
  19. flex-wrap: wrap;
  20. max-width: 100%;
  21. &-item {
  22. flex: none;
  23. align-self: center;
  24. max-width: 100%;
  25. }
  26. }
  27. .@{select-prefix-cls} {
  28. &-multiple {
  29. // ========================= Selector =========================
  30. .@{select-prefix-cls}-selector {
  31. display: flex;
  32. flex-wrap: wrap;
  33. align-items: center;
  34. // Multiple is little different that horizontal is follow the vertical
  35. padding: @select-multiple-padding @input-padding-vertical-base;
  36. .@{select-prefix-cls}-show-search& {
  37. cursor: text;
  38. }
  39. .@{select-prefix-cls}-disabled& {
  40. background: @select-multiple-disabled-background;
  41. cursor: not-allowed;
  42. }
  43. &::after {
  44. display: inline-block;
  45. width: 0;
  46. margin: @select-multiple-item-spacing-half 0;
  47. line-height: @select-multiple-item-height;
  48. content: '\a0';
  49. }
  50. }
  51. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selector,
  52. &.@{select-prefix-cls}-allow-clear .@{select-prefix-cls}-selector {
  53. padding-right: @font-size-sm + @control-padding-horizontal;
  54. }
  55. // ======================== Selections ========================
  56. .@{select-prefix-cls}-selection-item {
  57. position: relative;
  58. display: flex;
  59. flex: none;
  60. box-sizing: border-box;
  61. max-width: 100%;
  62. height: @select-multiple-item-height;
  63. margin-top: @select-multiple-item-spacing-half;
  64. margin-bottom: @select-multiple-item-spacing-half;
  65. line-height: @select-multiple-item-height - @select-multiple-item-border-width * 2;
  66. background: @select-selection-item-bg;
  67. border: 1px solid @select-selection-item-border-color;
  68. border-radius: @border-radius-base;
  69. cursor: default;
  70. transition: font-size 0.3s, line-height 0.3s, height 0.3s;
  71. user-select: none;
  72. margin-inline-end: @input-padding-vertical-base;
  73. padding-inline-start: @padding-xs;
  74. padding-inline-end: (@padding-xs / 2);
  75. .@{select-prefix-cls}-disabled& {
  76. color: @select-multiple-item-disabled-color;
  77. border-color: @select-multiple-item-disabled-border-color;
  78. cursor: not-allowed;
  79. }
  80. // It's ok not to do this, but 24px makes bottom narrow in view should adjust
  81. &-content {
  82. display: inline-block;
  83. margin-right: (@padding-xs / 2);
  84. overflow: hidden;
  85. white-space: pre; // fix whitespace wrapping. custom tags display all whitespace within.
  86. text-overflow: ellipsis;
  87. }
  88. &-remove {
  89. .iconfont-mixin();
  90. display: inline-block;
  91. color: @text-color-secondary;
  92. font-weight: bold;
  93. font-size: 10px;
  94. line-height: inherit;
  95. cursor: pointer;
  96. > .@{iconfont-css-prefix} {
  97. vertical-align: -0.2em;
  98. }
  99. &:hover {
  100. color: @icon-color-hover;
  101. }
  102. }
  103. }
  104. // ========================== Input ==========================
  105. .@{select-overflow-prefix-cls}-item + .@{select-overflow-prefix-cls}-item {
  106. .@{select-prefix-cls}-selection-search {
  107. margin-inline-start: 0;
  108. }
  109. }
  110. .@{select-prefix-cls}-selection-search {
  111. position: relative;
  112. max-width: 100%;
  113. margin-inline-start: @input-padding-horizontal-base - @input-padding-vertical-base;
  114. &-input,
  115. &-mirror {
  116. height: @select-multiple-item-height;
  117. font-family: @font-family;
  118. line-height: @select-multiple-item-height;
  119. transition: all 0.3s;
  120. }
  121. &-input {
  122. width: 100%;
  123. min-width: 4.1px; // fix search cursor missing
  124. }
  125. &-mirror {
  126. position: absolute;
  127. top: 0;
  128. left: 0;
  129. z-index: 999;
  130. white-space: pre; // fix whitespace wrapping caused width calculation bug
  131. visibility: hidden;
  132. }
  133. }
  134. // ======================= Placeholder =======================
  135. .@{select-prefix-cls}-selection-placeholder {
  136. position: absolute;
  137. top: 50%;
  138. right: @input-padding-horizontal;
  139. left: @input-padding-horizontal;
  140. transform: translateY(-50%);
  141. transition: all 0.3s;
  142. }
  143. // ============================================================
  144. // == Size ==
  145. // ============================================================
  146. .select-size(@suffix, @input-height) {
  147. @merged-cls: ~'@{select-prefix-cls}-@{suffix}';
  148. &.@{merged-cls} {
  149. @select-selection-height: @input-height - @input-padding-vertical-base * 2;
  150. @select-height-without-border: @input-height - @border-width-base * 2;
  151. .@{select-prefix-cls}-selector::after {
  152. line-height: @select-selection-height;
  153. }
  154. .@{select-prefix-cls}-selection-item {
  155. height: @select-selection-height;
  156. line-height: @select-selection-height - @border-width-base * 2;
  157. }
  158. .@{select-prefix-cls}-selection-search {
  159. height: @select-selection-height;
  160. line-height: @select-selection-height;
  161. &-input,
  162. &-mirror {
  163. height: @select-selection-height;
  164. line-height: @select-selection-height - @border-width-base * 2;
  165. }
  166. }
  167. }
  168. }
  169. .select-size('lg', @input-height-lg);
  170. .select-size('sm', @input-height-sm);
  171. // Size small need additional set padding
  172. &.@{select-prefix-cls}-sm {
  173. .@{select-prefix-cls}-selection-placeholder {
  174. left: @input-padding-horizontal-sm;
  175. }
  176. // https://github.com/ant-design/ant-design/issues/29559
  177. .@{select-prefix-cls}-selection-search {
  178. margin-inline-start: 3px;
  179. }
  180. }
  181. &.@{select-prefix-cls}-lg {
  182. .@{select-prefix-cls}-selection-item {
  183. height: @select-multiple-item-height-lg;
  184. line-height: @select-multiple-item-height-lg;
  185. }
  186. }
  187. }
  188. &-disabled .@{select-prefix-cls}-selection-item-remove {
  189. display: none;
  190. }
  191. }