input.scss 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. //@import '../theme/variables.scss';
  2. @import './variables.scss';
  3. $module: #{$prefix}-input;
  4. @keyframes #{$module}-active {
  5. from {
  6. transform: scale($motion-scale_size-inactive);
  7. }
  8. to {
  9. transform: scale($motion-scale_size-active);
  10. }
  11. }
  12. @keyframes #{$module}-inactive {
  13. from {
  14. transform: scale($motion-scale_size-active);
  15. }
  16. to {
  17. transform: scale($motion-scale_size-inactive);
  18. }
  19. }
  20. .#{$module}-wrapper {
  21. display: inline-block;
  22. position: relative;
  23. vertical-align: middle;
  24. @include shadow-0;
  25. @include font-size-regular;
  26. background-color: $color-input_default-bg-default;
  27. border: $width-input_wrapper-border $color-input_default-border-default solid;
  28. border-radius: $radius-input_wrapper;
  29. width: 100%;
  30. outline: none;
  31. cursor: text;
  32. box-sizing: border-box;
  33. color: $color-input_default-text-default;
  34. &-default {
  35. height: $height-input_wrapper_default;
  36. @include font-size-regular;
  37. line-height: $height-input_default;
  38. }
  39. &-small {
  40. height: $height-input_wrapper_small;
  41. @include font-size-header-6;
  42. line-height: $height-input_small;
  43. }
  44. &-large {
  45. height: $height-input_wrapper_large;
  46. @include font-size-header-6;
  47. line-height: $height-input_large;
  48. }
  49. &:hover {
  50. background-color: $color-input_default-bg-hover;
  51. border-color: $color-input_default-border-hover;
  52. }
  53. // &:active {
  54. // background-color: $color-input_default-bg-active;
  55. // }
  56. &-focus {
  57. background-color: $color-input_default-bg-focus;
  58. border: $color-input_default-border-focus solid $width-input_wrapper_focus-border;
  59. &:hover {
  60. background-color: $color-input_default-bg-focus;
  61. border-color: $color-input_default-border-focus;
  62. }
  63. &:active {
  64. background-color: $color-input_default-bg-focus;
  65. border-color: $color-input_default-border-focus;
  66. }
  67. }
  68. &.#{$module}-readonly {
  69. cursor: default;
  70. }
  71. &-error {
  72. background-color: $color-input_danger-bg-default;
  73. border-color: $color-input_danger-border-default;
  74. &:hover {
  75. background-color: $color-input_danger-bg-hover;
  76. border-color: $color-input_danger-border-hover;
  77. }
  78. &.#{$module}-wrapper-focus {
  79. background-color: $color-input_danger-bg-focus;
  80. border-color: $color-input_danger-border-focus;
  81. }
  82. // &:active {
  83. // background-color: $color-input_danger-bg-active;
  84. // border-color: $color-input_danger-border-active;
  85. // }
  86. }
  87. &-warning {
  88. background-color: $color-input_warning-bg-default;
  89. border-color: $color-input_warning-border-default;
  90. &:hover {
  91. background-color: $color-input_warning-bg-hover;
  92. border-color: $color-input_warning-border-hover;
  93. }
  94. &.#{$module}-wrapper-focus {
  95. background-color: $color-input_warning-bg-focus;
  96. border-color: $color-input_warning-border-focus;
  97. }
  98. // &:active {
  99. // background-color: $color-input_warning-bg-active;
  100. // border-color: $color-input_warning-border-active;
  101. // }
  102. }
  103. &__with-prefix {
  104. display: inline-flex;
  105. align-items: center;
  106. .#{$module} {
  107. padding-left: 0;
  108. }
  109. }
  110. &__with-suffix {
  111. display: inline-flex;
  112. align-items: center;
  113. .#{$module} {
  114. padding-right: 0;
  115. }
  116. }
  117. &-clearable,
  118. &-modebtn {
  119. display: inline-flex;
  120. align-items: center;
  121. }
  122. &-hidden {
  123. border: none;
  124. }
  125. .#{$prefix}-icon {
  126. color: $color-input-icon-default;
  127. }
  128. .#{$module}-clearbtn,
  129. .#{$module}-modebtn {
  130. color: $color-input-icon-hover;
  131. & > svg {
  132. pointer-events: none;
  133. }
  134. &:hover {
  135. cursor: pointer;
  136. .#{$prefix}-icon {
  137. color: $color-input-icon-hover;
  138. }
  139. }
  140. }
  141. &__with-suffix-icon.#{$module}-wrapper-clearable:not(.#{$module}-wrapper__with-suffix-hidden) {
  142. .#{$module}-clearbtn {
  143. min-width: $width-input-icon_clear_before_suffix;
  144. justify-content: flex-end;
  145. }
  146. }
  147. &-modebtn.#{$module}-wrapper-clearable {
  148. .#{$module}-clearbtn {
  149. min-width: $width-input-icon_clear_before_modebtn;
  150. justify-content: center;
  151. }
  152. }
  153. &.#{$module}-wrapper__with-append-only {
  154. .#{$module} {
  155. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  156. &:not(:last-child) {
  157. border-right-style: none;
  158. border-radius: 0;
  159. }
  160. }
  161. }
  162. &.#{$module}-wrapper__with-prepend-only {
  163. .#{$module} {
  164. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  165. &:not(:last-child) {
  166. border-right-style: none;
  167. border-radius: 0;
  168. }
  169. }
  170. }
  171. &.#{$module}-wrapper__with-prepend,
  172. &.#{$module}-wrapper__with-append {
  173. display: inline-flex;
  174. align-items: center;
  175. background-color: transparent;
  176. &:hover {
  177. background-color: transparent;
  178. }
  179. &.#{$module}-wrapper-focus {
  180. border: $width-input_wrapper_focus-border $color-input_default-border-default solid;
  181. background-color: transparent;
  182. }
  183. .#{$module} {
  184. background-color: $color-input_default-bg-default;
  185. border: $width-input_wrapper_focus-border transparent solid;
  186. &:hover {
  187. background-color: $color-input_default-bg-hover;
  188. & + .#{$module}-clearbtn,
  189. & ~ .#{$module}-modebtn {
  190. background-color: $color-input_default-bg-hover;
  191. }
  192. }
  193. &:focus {
  194. border: $width-input_wrapper_focus-border $color-input_default-border-focus solid;
  195. background-color: $color-input_default-bg-focus;
  196. &.#{$module}-sibling-clearbtn,
  197. &.#{$module}-sibling-modebtn {
  198. border-right-style: none;
  199. }
  200. &.#{$module}-sibling-modebtn {
  201. & + .#{$module}-clearbtn {
  202. border-right-style: none;
  203. }
  204. }
  205. & + .#{$module}-clearbtn,
  206. & ~ .#{$module}-modebtn {
  207. box-sizing: border-box;
  208. background-color: $color-input_default-bg-focus;
  209. }
  210. & + .#{$module}-clearbtn {
  211. border: $width-input_wrapper_focus-border $color-input_default-border-focus solid;
  212. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  213. border-left-style: none;
  214. &:not(:last-child) {
  215. border-radius: 0;
  216. }
  217. }
  218. & ~ .#{$module}-modebtn {
  219. border: $width-input_wrapper_focus-border $color-input_default-border-focus solid;
  220. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  221. border-left-style: none;
  222. &:not(:last-child) {
  223. border-radius: 0;
  224. }
  225. }
  226. }
  227. &-clearbtn,
  228. &-modebtn,
  229. &-clearbtn:hover,
  230. &-modebtn:hover {
  231. background-color: $color-input_default-bg-default;
  232. &:last-child {
  233. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  234. }
  235. }
  236. }
  237. &.#{$module}-wrapper-error {
  238. border-color: transparent;
  239. .#{$module} {
  240. background-color: $color-input_danger-bg-default;
  241. border-color: $color-input_danger-border-default;
  242. &:hover {
  243. background-color: $color-input_danger-bg-hover;
  244. border-color: $color-input_danger-border-hover;
  245. & + .#{$module}-clearbtn,
  246. & + .#{$module}-modebtn {
  247. background-color: $color-input_danger-bg-hover;
  248. }
  249. }
  250. &:focus {
  251. background-color: $color-input_danger-bg-focus;
  252. border-color: $color-input_danger-border-focus;
  253. & + .#{$module}-clearbtn,
  254. & + .#{$module}-modebtn {
  255. background-color: $color-input_danger-bg-focus;
  256. border-color: $color-input_danger-border-focus;
  257. }
  258. }
  259. &-clearbtn,
  260. &-modebtn,
  261. &-clearbtn:hover,
  262. &-modebtn:hover {
  263. background-color: $color-input_danger-bg-default;
  264. &:last-child {
  265. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  266. }
  267. }
  268. }
  269. }
  270. &.#{$module}-wrapper-warning {
  271. border-color: transparent;
  272. .#{$module} {
  273. background-color: $color-input_warning-bg-default;
  274. border-color: $color-input_warning-border-default;
  275. &:hover {
  276. background-color: $color-input_warning-bg-hover;
  277. border-color: $color-input_warning-border-hover;
  278. & + .#{$module}-clearbtn,
  279. & + .#{$module}-modebtn {
  280. background-color: $color-input_warning-bg-hover;
  281. }
  282. }
  283. &:focus {
  284. background-color: $color-input_warning-bg-focus;
  285. border-color: $color-input_warning-border-focus;
  286. & + .#{$module}-clearbtn,
  287. & + .#{$module}-modebtn {
  288. background-color: $color-input_warning-bg-focus;
  289. border-color: $color-input_warning-border-focus;
  290. }
  291. }
  292. &-clearbtn,
  293. &-modebtn,
  294. &-clearbtn:hover,
  295. &-modebtn:hover {
  296. background-color: $color-input_warning-bg-default;
  297. &:last-child {
  298. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. &-disabled {
  305. cursor: not-allowed;
  306. // border: $border-thickness-control $color-input_disabled-border-default solid;
  307. color: $color-input_disabled-text-default;
  308. background-color: $color-input_disabled-bg-default;
  309. // fix issue 670 in safari
  310. -webkit-text-fill-color: $color-input_disabled-text-default;
  311. &:hover {
  312. background-color: $color-input_disabled-bg-default;
  313. }
  314. .#{$module}-append,
  315. .#{$module}-prepend,
  316. .#{$module}-suffix,
  317. .#{$module}-prefix,
  318. .#{$prefix}-icon {
  319. color: $color-input_disabled-text-default;
  320. }
  321. }
  322. }
  323. .#{$module} {
  324. border: none;
  325. outline: none;
  326. width: 100%;
  327. color: inherit;
  328. padding-left: $spacing-input-paddingLeft;
  329. padding-right: $spacing-input-paddingRight;
  330. background-color: transparent;
  331. box-sizing: border-box;
  332. &::placeholder {
  333. color: $color-input_placeholder-text-default;
  334. }
  335. &-large {
  336. height: $height-input_large;
  337. @include font-size-header-6;
  338. line-height: $height-input_large;
  339. }
  340. &-small {
  341. height: $height-input_small;
  342. @include font-size-regular;
  343. line-height: $height-input_small;
  344. }
  345. &-default {
  346. height: $height-input_default;
  347. @include font-size-regular;
  348. line-height: $height-input_default;
  349. }
  350. &-disabled {
  351. cursor: not-allowed;
  352. color: inherit;
  353. }
  354. // &-prefix {
  355. // padding: 0 $spacing-tight;
  356. // display: flex;
  357. // align-items: center;
  358. // height: 100%;
  359. // width: auto;
  360. // white-space: nowrap;
  361. // }
  362. &-inset-label {
  363. margin-right: $spacing-input_insetLabel-marginRight;
  364. font-weight: $font-input_insetLabel-fontWeight;
  365. @include font-size-regular;
  366. color: $color-input_prefix-text-default;
  367. flex-shrink: 0;
  368. white-space: nowrap;
  369. }
  370. &-prefix,
  371. &-suffix {
  372. @include all-center;
  373. &-text {
  374. margin: 0 $spacing-base-tight;
  375. color: $color-input_prefix-text-default;
  376. font-weight: 600;
  377. white-space: nowrap;
  378. }
  379. &-icon {
  380. color: $color-input-icon-default;
  381. margin: $spacing-input_prefix_icon-marginY $spacing-input_prefix_icon-marginX;
  382. }
  383. }
  384. &-suffix {
  385. @include all-center;
  386. }
  387. &-clearbtn,
  388. &-modebtn {
  389. display: flex;
  390. align-items: center;
  391. height: 100%;
  392. justify-content: center;
  393. min-width: $width-input-icon;
  394. }
  395. &-clearbtn + &-suffix {
  396. & + .#{$module}-suffix-text {
  397. margin-left: 0;
  398. }
  399. & + .#{$module}-suffix-icon {
  400. margin-left: 0;
  401. }
  402. }
  403. &-suffix-hidden {
  404. display: none;
  405. }
  406. &-prepend,
  407. &-append {
  408. height: 100%;
  409. display: flex;
  410. align-items: center;
  411. background-color: $color-input_default-bg-default;
  412. color: $color-input_prefix-text-default;
  413. &-icon,
  414. &-text {
  415. padding: $spacing-input_prepend-paddingY $spacing-input_prepend-paddingX;
  416. }
  417. @include font-size-regular;
  418. flex-shrink: 0;
  419. }
  420. &-append {
  421. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  422. border-left: $width-input_append-border $color-input_default-border-default solid;
  423. }
  424. &-prepend {
  425. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  426. border-right: $width-input_prepend-border $color-input_default-border-default solid;
  427. }
  428. &-disabled {
  429. &::placeholder {
  430. color: $color-input_disabled-text-default;
  431. }
  432. }
  433. &-group {
  434. display: inline-flex;
  435. align-items: center;
  436. align-content: center;
  437. flex-wrap: wrap;
  438. // select与autocomplete的border-radius都是基于select
  439. .#{$prefix}-select,
  440. .#{$prefix}-cascader,
  441. .#{$prefix}-tree-select,
  442. & > .#{$module}-wrapper {
  443. border-radius: 0;
  444. &:first-child {
  445. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  446. }
  447. &:last-child {
  448. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  449. }
  450. &:not(:last-child) {
  451. position: relative;
  452. &::after {
  453. content: '';
  454. background-color: $color-input_group-border-default;
  455. width: $width-input_group_pseudo-border;
  456. // height: $inputGroup-border-height;
  457. position: absolute;
  458. right: -1px;
  459. top: 1px;
  460. bottom: 1px;
  461. }
  462. }
  463. }
  464. .#{$prefix}-input-number,
  465. .#{$prefix}-datepicker,
  466. .#{$prefix}-autocomplete {
  467. border-radius: 0;
  468. .#{$prefix}-datepicker-range-input {
  469. border-radius: 0;
  470. }
  471. &:first-child {
  472. .#{$module}-wrapper,
  473. .#{$prefix}-datepicker-range-input {
  474. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  475. }
  476. }
  477. &:last-child {
  478. .#{$module}-wrapper,
  479. .#{$prefix}-datepicker-range-input {
  480. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  481. }
  482. }
  483. &:not(:last-child) {
  484. position: relative;
  485. &::after {
  486. content: '';
  487. background-color: $color-input_group-border-default;
  488. width: $width-input_group_pseudo-border;
  489. // height: $inputGroup-border-height;
  490. position: absolute;
  491. right: -1px;
  492. top: 1px;
  493. bottom: 1px;
  494. }
  495. }
  496. }
  497. }
  498. &-group-wrapper {
  499. &-with-top-label {
  500. margin-top: $spacing-input_group_withTopLabel-marginTop;
  501. margin-bottom: $spacing-input_group_withTopLabel-marginBottom;
  502. .#{$prefix}-input-group {
  503. display: flex;
  504. }
  505. .#{$prefix}-input-group {
  506. .#{$prefix}-form-field {
  507. margin-top: 0;
  508. margin-bottom: 0;
  509. }
  510. }
  511. }
  512. }
  513. }
  514. @import "./rtl.scss";