136bc9815687f497ab775dcd886872bba19cb6b0ead3b9f0356618e8c39dc6e15cfde2d2611f9641c505a598ba85ccccb5be7c94334d0082c7299d3a6f15de 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/var' as *;
  4. @use 'common/var' as *;
  5. @mixin inset-prepend-border($color) {
  6. box-shadow: 1px 0 0 0 $color inset, 0 1px 0 0 $color inset,
  7. 0 -1px 0 0 $color inset;
  8. }
  9. @mixin inset-append-border($color) {
  10. box-shadow: 0 1px 0 0 $color inset, 0 -1px 0 0 $color inset,
  11. -1px 0 0 0 $color inset;
  12. }
  13. @mixin inset-prepend-input-border($color) {
  14. box-shadow: 1px 0 0 0 $color inset, 1px 0 0 0 $color, 0 1px 0 0 $color inset,
  15. 0 -1px 0 0 $color inset !important;
  16. }
  17. @mixin inset-append-input-border($color) {
  18. box-shadow: -1px 0 0 0 $color, -1px 0 0 0 $color inset, 0 1px 0 0 $color inset,
  19. 0 -1px 0 0 $color inset !important;
  20. }
  21. @mixin mixed-input-border($color) {
  22. box-shadow: 0 0 0 1px $color inset;
  23. }
  24. @include b(textarea) {
  25. @include set-component-css-var('input', $input);
  26. }
  27. @include b(textarea) {
  28. position: relative;
  29. display: inline-block;
  30. width: 100%;
  31. vertical-align: bottom;
  32. font-size: getCssVar('font-size', 'base');
  33. @include e(inner) {
  34. position: relative;
  35. display: block;
  36. resize: vertical;
  37. padding: 5px map.get($input-padding-horizontal, 'default')-$border-width;
  38. line-height: 1.5;
  39. box-sizing: border-box;
  40. width: 100%;
  41. font-size: inherit;
  42. font-family: inherit;
  43. color: var(
  44. #{getCssVarName('input-text-color')},
  45. map.get($input, 'text-color')
  46. );
  47. background-color: var(
  48. #{getCssVarName('input-bg-color')},
  49. map.get($input, 'bg-color')
  50. );
  51. background-image: none;
  52. -webkit-appearance: none;
  53. @include inset-input-border(
  54. var(
  55. #{getCssVarName('input-border-color')},
  56. map.get($input, 'border-color')
  57. )
  58. );
  59. border-radius: getCssVarWithDefault(
  60. 'input-border-radius',
  61. map.get($input, 'border-radius')
  62. );
  63. transition: getCssVar('transition-box-shadow');
  64. border: none;
  65. &::placeholder {
  66. color: getCssVarWithDefault(
  67. 'input-placeholder-color',
  68. map.get($input, 'placeholder-color')
  69. );
  70. }
  71. &:hover {
  72. @include inset-input-border(#{getCssVar('input', 'hover-border-color')});
  73. }
  74. &:focus {
  75. outline: none;
  76. @include inset-input-border(#{getCssVar('input', 'focus-border-color')});
  77. }
  78. }
  79. & .#{$namespace}-input__count {
  80. color: getCssVar('color-info');
  81. background: getCssVar('fill-color', 'blank');
  82. position: absolute;
  83. font-size: 12px;
  84. line-height: 14px;
  85. bottom: 5px;
  86. right: 10px;
  87. }
  88. @include when(disabled) {
  89. .#{$namespace}-textarea__inner {
  90. @include inset-input-border(#{getCssVar('disabled-border-color')});
  91. background-color: map.get($input-disabled, 'fill');
  92. color: map.get($input-disabled, 'text-color');
  93. cursor: not-allowed;
  94. &::placeholder {
  95. color: map.get($input-disabled, 'placeholder-color');
  96. }
  97. }
  98. }
  99. @include when(exceed) {
  100. .#{$namespace}-textarea__inner {
  101. @include mixed-input-border(#{getCssVar('color-danger')});
  102. }
  103. .#{$namespace}-input__count {
  104. color: getCssVar('color-danger');
  105. }
  106. }
  107. }
  108. @include b(input) {
  109. @include set-component-css-var('input', $input);
  110. }
  111. @include b(input) {
  112. @include css-var-from-global('input-height', 'component-size');
  113. position: relative;
  114. font-size: getCssVar('font-size', 'base');
  115. display: inline-flex;
  116. width: getCssVar('input-width');
  117. line-height: getCssVar('input-height');
  118. box-sizing: border-box;
  119. vertical-align: middle;
  120. @include scroll-bar;
  121. & .#{$namespace}-input__clear,
  122. & .#{$namespace}-input__password {
  123. color: getCssVar('input-icon-color');
  124. font-size: map.get($input-font-size, 'default');
  125. cursor: pointer;
  126. &:hover {
  127. color: getCssVar('input-clear-hover-color');
  128. }
  129. }
  130. & .#{$namespace}-input__count {
  131. height: 100%;
  132. display: inline-flex;
  133. align-items: center;
  134. color: getCssVar('color-info');
  135. font-size: 12px;
  136. .#{$namespace}-input__count-inner {
  137. background: getCssVar('fill-color', 'blank');
  138. line-height: initial;
  139. display: inline-block;
  140. padding-left: 8px;
  141. }
  142. }
  143. @include e(wrapper) {
  144. display: inline-flex;
  145. flex-grow: 1;
  146. align-items: center;
  147. justify-content: center;
  148. padding: $border-width map.get($input-padding-horizontal, 'default')-$border-width;
  149. background-color: var(
  150. #{getCssVarName('input-bg-color')},
  151. map.get($input, 'bg-color')
  152. );
  153. background-image: none;
  154. border-radius: getCssVarWithDefault(
  155. 'input-border-radius',
  156. map.get($input, 'border-radius')
  157. );
  158. cursor: text;
  159. transition: getCssVar('transition-box-shadow');
  160. transform: translate3d(0, 0, 0);
  161. @include inset-input-border(
  162. var(
  163. #{getCssVarName('input-border-color')},
  164. map.get($input, 'border-color')
  165. )
  166. );
  167. &:hover {
  168. @include inset-input-border(#{getCssVar('input', 'hover-border-color')});
  169. }
  170. @include when(focus) {
  171. @include inset-input-border(#{getCssVar('input', 'focus-border-color')});
  172. }
  173. }
  174. & {
  175. // use map.get as default value for date picker range
  176. @include set-css-var-value(
  177. 'input-inner-height',
  178. calc(
  179. var(
  180. #{getCssVarName('input-height')},
  181. #{map.get($input-height, 'default')}
  182. ) - $border-width * 2
  183. )
  184. );
  185. }
  186. @include e(inner) {
  187. width: 100%;
  188. flex-grow: 1;
  189. -webkit-appearance: none;
  190. color: var(
  191. #{getCssVarName('input-text-color')},
  192. map.get($input, 'text-color')
  193. );
  194. font-size: inherit;
  195. height: getCssVar('input-inner-height');
  196. line-height: getCssVar('input-inner-height');
  197. padding: 0;
  198. outline: none;
  199. border: none;
  200. background: none;
  201. box-sizing: border-box;
  202. &:focus {
  203. outline: none;
  204. }
  205. &::placeholder {
  206. color: getCssVarWithDefault(
  207. 'input-placeholder-color',
  208. map.get($input, 'placeholder-color')
  209. );
  210. }
  211. // override edge default style
  212. &[type='password']::-ms-reveal {
  213. display: none;
  214. }
  215. &[type='number'] {
  216. line-height: 1;
  217. }
  218. }
  219. @each $slot in (prefix, suffix) {
  220. @include e($slot) {
  221. display: inline-flex;
  222. white-space: nowrap;
  223. flex-shrink: 0;
  224. flex-wrap: nowrap;
  225. height: 100%;
  226. line-height: getCssVar('input-inner-height');
  227. text-align: center;
  228. color: var(
  229. #{getCssVarName('input-icon-color')},
  230. map.get($input, 'icon-color')
  231. );
  232. transition: all getCssVar('transition-duration');
  233. pointer-events: none;
  234. }
  235. @include e(#{$slot}-inner) {
  236. pointer-events: all;
  237. display: inline-flex;
  238. align-items: center;
  239. justify-content: center;
  240. @if $slot == prefix {
  241. > :last-child {
  242. margin-right: 8px;
  243. }
  244. > :first-child {
  245. &,
  246. &.#{$namespace}-input__icon {
  247. margin-left: 0;
  248. }
  249. }
  250. } @else {
  251. > :first-child {
  252. margin-left: 8px;
  253. }
  254. }
  255. }
  256. }
  257. & .#{$namespace}-input__icon {
  258. height: inherit;
  259. line-height: inherit;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. transition: all getCssVar('transition-duration');
  264. margin-left: 8px;
  265. }
  266. @include e(validateIcon) {
  267. pointer-events: none;
  268. }
  269. @include when(active) {
  270. .#{$namespace}-input__wrapper {
  271. @include mixed-input-border(
  272. var(
  273. #{getCssVarName('input-focus-color')},
  274. map.get($input, 'focus-color')
  275. )
  276. );
  277. }
  278. }
  279. @include when(disabled) {
  280. cursor: not-allowed;
  281. .#{$namespace}-input__wrapper {
  282. background-color: map.get($input-disabled, 'fill');
  283. cursor: not-allowed;
  284. @include mixed-input-border(map.get($input-disabled, 'border'));
  285. }
  286. .#{$namespace}-input__inner {
  287. color: map.get($input-disabled, 'text-color');
  288. -webkit-text-fill-color: map.get($input-disabled, 'text-color');
  289. cursor: not-allowed;
  290. &::placeholder {
  291. color: map.get($input-disabled, 'placeholder-color');
  292. }
  293. }
  294. .#{$namespace}-input__icon {
  295. cursor: not-allowed;
  296. }
  297. .#{$namespace}-input__prefix-inner,
  298. .#{$namespace}-input__suffix-inner {
  299. pointer-events: none;
  300. }
  301. }
  302. @include when(exceed) {
  303. .#{$namespace}-input__wrapper {
  304. @include mixed-input-border(#{getCssVar('color-danger')});
  305. }
  306. .#{$namespace}-input__suffix {
  307. .#{$namespace}-input__count {
  308. color: getCssVar('color-danger');
  309. }
  310. }
  311. }
  312. @each $size in (large, small) {
  313. @include m($size) {
  314. @include css-var-from-global('input-height', ('component-size', $size));
  315. font-size: map.get($input-font-size, $size);
  316. @include e(wrapper) {
  317. padding: $border-width map.get($input-padding-horizontal, $size)-$border-width;
  318. }
  319. & {
  320. @include set-css-var-value(
  321. 'input-inner-height',
  322. calc(
  323. var(
  324. #{getCssVarName('input-height')},
  325. #{map.get($input-height, $size)}
  326. ) - $border-width * 2
  327. )
  328. );
  329. }
  330. }
  331. }
  332. }
  333. @include b(input-group) {
  334. display: inline-flex;
  335. width: 100%;
  336. align-items: stretch;
  337. @include e((append, prepend)) {
  338. background-color: getCssVar('fill-color', 'light');
  339. color: getCssVar('color-info');
  340. position: relative;
  341. display: inline-flex;
  342. align-items: center;
  343. justify-content: center;
  344. min-height: 100%;
  345. border-radius: getCssVar('input-border-radius');
  346. padding: 0 20px;
  347. white-space: nowrap;
  348. &:focus {
  349. outline: none;
  350. }
  351. .#{$namespace}-select,
  352. .#{$namespace}-button {
  353. display: inline-block;
  354. flex: 1;
  355. margin: 0 -20px;
  356. }
  357. button.#{$namespace}-button,
  358. button.#{$namespace}-button:hover,
  359. div.#{$namespace}-select .#{$namespace}-select__wrapper,
  360. div.#{$namespace}-select:hover .#{$namespace}-select__wrapper {
  361. border-color: transparent;
  362. background-color: transparent;
  363. color: inherit;
  364. }
  365. .#{$namespace}-button,
  366. .#{$namespace}-input {
  367. font-size: inherit;
  368. }
  369. }
  370. @include e(prepend) {
  371. border-right: 0;
  372. border-top-right-radius: 0;
  373. border-bottom-right-radius: 0;
  374. @include inset-prepend-border(#{getCssVar('input-border-color')});
  375. }
  376. @include e(append) {
  377. border-left: 0;
  378. border-top-left-radius: 0;
  379. border-bottom-left-radius: 0;
  380. @include inset-append-border(#{getCssVar('input-border-color')});
  381. }
  382. @include m(prepend) {
  383. > .#{$namespace}-input__wrapper {
  384. border-top-left-radius: 0;
  385. border-bottom-left-radius: 0;
  386. }
  387. @include e(prepend) {
  388. .#{$namespace}-select {
  389. .#{$namespace}-select__wrapper {
  390. border-top-right-radius: 0;
  391. border-bottom-right-radius: 0;
  392. @include inset-prepend-border(#{getCssVar('input-border-color')});
  393. }
  394. }
  395. }
  396. }
  397. @include m(append) {
  398. > .#{$namespace}-input__wrapper {
  399. border-top-right-radius: 0;
  400. border-bottom-right-radius: 0;
  401. }
  402. @include e(append) {
  403. .#{$namespace}-select {
  404. .#{$namespace}-select__wrapper {
  405. border-top-left-radius: 0;
  406. border-bottom-left-radius: 0;
  407. @include inset-append-border(#{getCssVar('input-border-color')});
  408. }
  409. }
  410. }
  411. }
  412. }
  413. @include b(input-hidden) {
  414. display: none !important;
  415. }