multiple.less 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. visibility: hidden;
  49. content: '\a0';
  50. }
  51. }
  52. &.@{select-prefix-cls}-show-arrow .@{select-prefix-cls}-selector,
  53. &.@{select-prefix-cls}-allow-clear .@{select-prefix-cls}-selector {
  54. padding-right: @font-size-sm + @control-padding-horizontal;
  55. }
  56. // ======================== Selections ========================
  57. .@{select-prefix-cls}-selection-item {
  58. position: relative;
  59. display: flex;
  60. flex: none;
  61. box-sizing: border-box;
  62. max-width: 100%;
  63. height: @select-multiple-item-height;
  64. margin-top: @select-multiple-item-spacing-half;
  65. margin-bottom: @select-multiple-item-spacing-half;
  66. line-height: @select-multiple-item-height - @select-multiple-item-border-width * 2;
  67. background: @select-selection-item-bg;
  68. border: 1px solid @select-selection-item-border-color;
  69. border-radius: @border-radius-base;
  70. cursor: default;
  71. transition: font-size 0.3s, line-height 0.3s, height 0.3s;
  72. user-select: none;
  73. margin-inline-end: @input-padding-vertical-base;
  74. padding-inline-start: @padding-xs;
  75. padding-inline-end: (@padding-xs / 2);
  76. .@{select-prefix-cls}-disabled& {
  77. color: @select-multiple-item-disabled-color;
  78. border-color: @select-multiple-item-disabled-border-color;
  79. cursor: not-allowed;
  80. }
  81. // It's ok not to do this, but 24px makes bottom narrow in view should adjust
  82. &-content {
  83. display: inline-block;
  84. margin-right: (@padding-xs / 2);
  85. overflow: hidden;
  86. white-space: pre; // fix whitespace wrapping. custom tags display all whitespace within.
  87. text-overflow: ellipsis;
  88. }
  89. &-remove {
  90. .iconfont-mixin();
  91. display: inline-flex;
  92. align-items: center;
  93. color: @text-color-secondary;
  94. font-weight: bold;
  95. font-size: 10px;
  96. line-height: inherit;
  97. cursor: pointer;
  98. > .@{iconfont-css-prefix} {
  99. vertical-align: middle;
  100. }
  101. &:hover {
  102. color: @icon-color-hover;
  103. }
  104. }
  105. }
  106. // ========================== Input ==========================
  107. .@{select-overflow-prefix-cls}-item + .@{select-overflow-prefix-cls}-item {
  108. .@{select-prefix-cls}-selection-search {
  109. margin-inline-start: 0;
  110. }
  111. }
  112. .@{select-prefix-cls}-selection-search {
  113. position: relative;
  114. max-width: 100%;
  115. margin-inline-start: @input-padding-horizontal-base - @input-padding-vertical-base;
  116. &-input,
  117. &-mirror {
  118. height: @select-multiple-item-height;
  119. font-family: @font-family;
  120. line-height: @select-multiple-item-height;
  121. transition: all 0.3s;
  122. }
  123. &-input {
  124. width: 100%;
  125. min-width: 4.1px; // fix search cursor missing
  126. }
  127. &-mirror {
  128. position: absolute;
  129. top: 0;
  130. left: 0;
  131. z-index: 999;
  132. white-space: pre; // fix whitespace wrapping caused width calculation bug
  133. visibility: hidden;
  134. }
  135. }
  136. // ======================= Placeholder =======================
  137. .@{select-prefix-cls}-selection-placeholder {
  138. position: absolute;
  139. top: 50%;
  140. right: @input-padding-horizontal;
  141. left: @input-padding-horizontal;
  142. transform: translateY(-50%);
  143. transition: all 0.3s;
  144. }
  145. // ============================================================
  146. // == Size ==
  147. // ============================================================
  148. .select-size(@suffix, @input-height) {
  149. @merged-cls: ~'@{select-prefix-cls}-@{suffix}';
  150. &.@{merged-cls} {
  151. @select-selection-height: @input-height - @input-padding-vertical-base * 2;
  152. @select-height-without-border: @input-height - @border-width-base * 2;
  153. .@{select-prefix-cls}-selector::after {
  154. line-height: @select-selection-height;
  155. }
  156. .@{select-prefix-cls}-selection-item {
  157. height: @select-selection-height;
  158. line-height: @select-selection-height - @border-width-base * 2;
  159. }
  160. .@{select-prefix-cls}-selection-search {
  161. height: @select-selection-height;
  162. line-height: @select-selection-height;
  163. &-input,
  164. &-mirror {
  165. height: @select-selection-height;
  166. line-height: @select-selection-height - @border-width-base * 2;
  167. }
  168. }
  169. }
  170. }
  171. .select-size('lg', @input-height-lg);
  172. .select-size('sm', @input-height-sm);
  173. // Size small need additional set padding
  174. &.@{select-prefix-cls}-sm {
  175. .@{select-prefix-cls}-selection-placeholder {
  176. left: @input-padding-horizontal-sm;
  177. }
  178. // https://github.com/ant-design/ant-design/issues/29559
  179. .@{select-prefix-cls}-selection-search {
  180. margin-inline-start: 3px;
  181. }
  182. }
  183. }
  184. &-disabled .@{select-prefix-cls}-selection-item-remove {
  185. display: none;
  186. }
  187. }