input.scss 19 KB

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