e2815e2324333d43a22965d25559500e7c87abd33609ab48daa825ab4a780324fed3d526f6510a3f88c62a350b1e9f2728f9e99e67da246995deefe6f54e34 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/utils' as *;
  4. @use 'mixins/var' as *;
  5. @use 'common/var' as *;
  6. $form-item-margin-bottom: () !default;
  7. $form-item-margin-bottom: map.merge(
  8. (
  9. 'large': 22px,
  10. 'default': 18px,
  11. 'small': 18px,
  12. ),
  13. $form-item-margin-bottom
  14. );
  15. $form-item-line-height: () !default;
  16. $form-item-line-height: map.merge(
  17. (
  18. 'large': 40px,
  19. 'default': 32px,
  20. 'small': 24px,
  21. ),
  22. $form-item-line-height
  23. );
  24. $form-item-error-padding-top: () !default;
  25. $form-item-error-padding-top: map.merge(
  26. (
  27. 'large': 4px,
  28. 'default': 2px,
  29. 'small': 2px,
  30. ),
  31. $form-item-error-padding-top
  32. );
  33. $form-item-label-top-line-height: () !default;
  34. $form-item-label-top-line-height: map.merge(
  35. (
  36. 'large': 22px,
  37. 'default': 22px,
  38. 'small': 20px,
  39. ),
  40. $form-item-label-top-line-height
  41. );
  42. $form-item-label-top-margin-bottom: () !default;
  43. $form-item-label-top-margin-bottom: map.merge(
  44. (
  45. 'large': 12px,
  46. 'default': 8px,
  47. 'small': 4px,
  48. ),
  49. $form-item-label-top-margin-bottom
  50. );
  51. @include b(form) {
  52. @include set-component-css-var('form', $form);
  53. @include m(inline) {
  54. .#{$namespace}-form-item {
  55. display: inline-flex;
  56. vertical-align: middle;
  57. margin-right: 32px;
  58. }
  59. &.#{$namespace}-form--label-top {
  60. display: flex;
  61. flex-wrap: wrap;
  62. .#{$namespace}-form-item {
  63. display: block;
  64. }
  65. }
  66. }
  67. }
  68. @include b(form-item) {
  69. display: flex;
  70. --font-size: #{map.get($input-font-size, 'default')};
  71. margin-bottom: #{map.get($form-item-margin-bottom, 'default')};
  72. .#{$namespace}-form-item {
  73. margin-bottom: 0;
  74. }
  75. .#{$namespace}-input__validateIcon {
  76. display: none;
  77. }
  78. @each $size in (large, default, small) {
  79. @include m($size) {
  80. --font-size: #{map.get($input-font-size, $size)};
  81. @include set-css-var-value(('form', 'label-font-size'), var(--font-size));
  82. margin-bottom: #{map.get($form-item-margin-bottom, $size)};
  83. @include e(label) {
  84. height: #{map.get($form-item-line-height, $size)};
  85. line-height: #{map.get($form-item-line-height, $size)};
  86. }
  87. @include e(content) {
  88. line-height: #{map.get($form-item-line-height, $size)};
  89. }
  90. @include e(error) {
  91. padding-top: #{map.get($form-item-error-padding-top, $size)};
  92. }
  93. }
  94. }
  95. @include m(label-left) {
  96. .#{$namespace}-form-item__label {
  97. text-align: left;
  98. justify-content: flex-start;
  99. }
  100. }
  101. @include m(label-right) {
  102. .#{$namespace}-form-item__label {
  103. text-align: right;
  104. justify-content: flex-end;
  105. }
  106. }
  107. @include m(label-top) {
  108. display: block;
  109. .#{$namespace}-form-item__label {
  110. display: block;
  111. width: fit-content;
  112. height: auto;
  113. text-align: left;
  114. margin-bottom: #{map.get($form-item-label-top-margin-bottom, 'default')};
  115. line-height: #{map.get($form-item-label-top-line-height, 'default')};
  116. }
  117. }
  118. @include e(label-wrap) {
  119. display: flex;
  120. }
  121. @include e(label) {
  122. display: inline-flex;
  123. align-items: flex-start;
  124. flex: 0 0 auto;
  125. font-size: getCssVar('form-label-font-size');
  126. color: getCssVar('text-color', 'regular');
  127. height: #{map.get($form-item-line-height, 'default')};
  128. line-height: #{map.get($form-item-line-height, 'default')};
  129. padding: 0 12px 0 0;
  130. box-sizing: border-box;
  131. }
  132. @include e(content) {
  133. display: flex;
  134. flex-wrap: wrap;
  135. align-items: center;
  136. flex: 1;
  137. line-height: #{map.get($form-item-line-height, 'default')};
  138. position: relative;
  139. font-size: var(--font-size);
  140. min-width: 0;
  141. .#{$namespace}-input-group {
  142. vertical-align: top;
  143. }
  144. }
  145. @include e(error) {
  146. color: getCssVar('color-danger');
  147. font-size: 12px;
  148. line-height: 1;
  149. padding-top: #{map.get($form-item-error-padding-top, 'default')};
  150. position: absolute;
  151. top: 100%;
  152. left: 0;
  153. @include m(inline) {
  154. position: relative;
  155. top: auto;
  156. left: auto;
  157. display: inline-block;
  158. margin-left: 10px;
  159. }
  160. }
  161. @include when(required) {
  162. @include pseudo('not(.is-no-asterisk)') {
  163. &.asterisk-left {
  164. > .#{$namespace}-form-item__label:before,
  165. > .#{$namespace}-form-item__label-wrap
  166. > .#{$namespace}-form-item__label:before {
  167. content: '*';
  168. color: getCssVar('color-danger');
  169. margin-right: 4px;
  170. }
  171. }
  172. &.asterisk-right {
  173. > .#{$namespace}-form-item__label:after,
  174. > .#{$namespace}-form-item__label-wrap
  175. > .#{$namespace}-form-item__label:after {
  176. content: '*';
  177. color: getCssVar('color-danger');
  178. margin-left: 4px;
  179. }
  180. }
  181. }
  182. }
  183. @include when(error) {
  184. @include e(content) {
  185. .#{$namespace}-input__wrapper,
  186. .#{$namespace}-textarea__inner,
  187. .#{$namespace}-select__wrapper,
  188. .#{$namespace}-input-tag__wrapper {
  189. &,
  190. &:hover,
  191. &:focus,
  192. &.is-focus {
  193. box-shadow: 0 0 0 1px getCssVar('color-danger') inset;
  194. }
  195. }
  196. .#{$namespace}-input-group__append,
  197. .#{$namespace}-input-group__prepend {
  198. .#{$namespace}-input__wrapper {
  199. box-shadow: 0 0 0 1px transparent inset;
  200. }
  201. .#{$namespace}-input__validateIcon {
  202. display: none;
  203. }
  204. }
  205. .#{$namespace}-input__validateIcon {
  206. color: getCssVar('color-danger');
  207. }
  208. }
  209. }
  210. @include m(feedback) {
  211. .#{$namespace}-input__validateIcon {
  212. display: inline-flex;
  213. }
  214. }
  215. }