input.scss 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. //@import '../theme/variables.scss';
  2. @import "./animation.scss";
  3. @import './variables.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-hover;
  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. }
  182. }
  183. }
  184. &.#{$module}-wrapper__with-prepend,
  185. &.#{$module}-wrapper__with-append {
  186. display: inline-flex;
  187. align-items: center;
  188. background-color: transparent;
  189. &:hover {
  190. background-color: transparent;
  191. }
  192. &.#{$module}-wrapper-focus {
  193. border: $width-input_wrapper_focus-border $color-input_default-border-default solid;
  194. background-color: transparent;
  195. }
  196. .#{$module} {
  197. background-color: $color-input_default-bg-default;
  198. border: $width-input_wrapper_focus-border transparent solid;
  199. &:hover {
  200. background-color: $color-input_default-bg-hover;
  201. & + .#{$module}-clearbtn,
  202. & ~ .#{$module}-modebtn {
  203. background-color: $color-input_default-bg-hover;
  204. }
  205. }
  206. &:focus {
  207. border: $width-input_wrapper_focus-border $color-input_default-border-focus solid;
  208. background-color: $color-input_default-bg-focus;
  209. &.#{$module}-sibling-clearbtn,
  210. &.#{$module}-sibling-modebtn {
  211. border-right-style: none;
  212. }
  213. &.#{$module}-sibling-modebtn {
  214. & + .#{$module}-clearbtn {
  215. border-right-style: none;
  216. }
  217. }
  218. & + .#{$module}-clearbtn,
  219. & ~ .#{$module}-modebtn {
  220. box-sizing: border-box;
  221. background-color: $color-input_default-bg-focus;
  222. }
  223. & + .#{$module}-clearbtn {
  224. border: $width-input_wrapper_focus-border $color-input_default-border-focus solid;
  225. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  226. border-left-style: none;
  227. &:not(:last-child) {
  228. border-radius: 0;
  229. }
  230. }
  231. & ~ .#{$module}-modebtn {
  232. border: $width-input_wrapper_focus-border $color-input_default-border-focus solid;
  233. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  234. border-left-style: none;
  235. &:not(:last-child) {
  236. border-radius: 0;
  237. }
  238. }
  239. }
  240. // when have prepend and append, only make the input have active bg color
  241. &:active {
  242. background-color: $color-input_default-bg-active;
  243. & + .#{$module}-clearbtn,
  244. & ~ .#{$module}-modebtn {
  245. background-color: $color-input_default-bg-active;
  246. }
  247. }
  248. &-clearbtn,
  249. &-modebtn,
  250. &-clearbtn:hover,
  251. &-modebtn:hover {
  252. background-color: $color-input_default-bg-default;
  253. &:last-child {
  254. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  255. }
  256. }
  257. }
  258. &.#{$module}-wrapper-error {
  259. border-color: transparent;
  260. .#{$module} {
  261. background-color: $color-input_danger-bg-default;
  262. border-color: $color-input_danger-border-default;
  263. &:hover {
  264. background-color: $color-input_danger-bg-hover;
  265. border-color: $color-input_danger-border-hover;
  266. & + .#{$module}-clearbtn,
  267. & + .#{$module}-modebtn {
  268. background-color: $color-input_danger-bg-hover;
  269. }
  270. }
  271. &:focus {
  272. background-color: $color-input_danger-bg-focus;
  273. border-color: $color-input_danger-border-focus;
  274. & + .#{$module}-clearbtn,
  275. & + .#{$module}-modebtn {
  276. background-color: $color-input_danger-bg-focus;
  277. border-color: $color-input_danger-border-focus;
  278. }
  279. }
  280. &:active {
  281. background-color: $color-input_danger-bg-active;
  282. & + .#{$module}-clearbtn,
  283. & + .#{$module}-modebtn {
  284. background-color: $color-input_danger-bg-active;
  285. border-color: $color-input_danger-border-focus;
  286. }
  287. }
  288. &-clearbtn,
  289. &-modebtn,
  290. &-clearbtn:hover,
  291. &-modebtn:hover {
  292. background-color: $color-input_danger-bg-default;
  293. &:last-child {
  294. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  295. }
  296. }
  297. }
  298. }
  299. &.#{$module}-wrapper-warning {
  300. border-color: transparent;
  301. .#{$module} {
  302. background-color: $color-input_warning-bg-default;
  303. border-color: $color-input_warning-border-default;
  304. &:hover {
  305. background-color: $color-input_warning-bg-hover;
  306. border-color: $color-input_warning-border-hover;
  307. & + .#{$module}-clearbtn,
  308. & + .#{$module}-modebtn {
  309. background-color: $color-input_warning-bg-hover;
  310. }
  311. }
  312. &:focus {
  313. background-color: $color-input_warning-bg-focus;
  314. border-color: $color-input_warning-border-focus;
  315. & + .#{$module}-clearbtn,
  316. & + .#{$module}-modebtn {
  317. background-color: $color-input_warning-bg-focus;
  318. border-color: $color-input_warning-border-focus;
  319. }
  320. }
  321. &:active {
  322. background-color: $color-input_warning-bg-active;
  323. & + .#{$module}-clearbtn,
  324. & + .#{$module}-modebtn {
  325. background-color: $color-input_warning-bg-active;
  326. border-color: $color-input_warning-border-focus;
  327. }
  328. }
  329. &-clearbtn,
  330. &-modebtn,
  331. &-clearbtn:hover,
  332. &-modebtn:hover {
  333. background-color: $color-input_warning-bg-default;
  334. &:last-child {
  335. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. &-disabled {
  342. cursor: not-allowed;
  343. // border: $border-thickness-control $color-input_disabled-border-default solid;
  344. color: $color-input_disabled-text-default;
  345. background-color: $color-input_disabled-bg-default;
  346. // fix issue 670 in safari
  347. -webkit-text-fill-color: $color-input_disabled-text-default;
  348. &:hover {
  349. background-color: $color-input_disabled-bg-default;
  350. }
  351. .#{$module}-append,
  352. .#{$module}-prepend,
  353. .#{$module}-suffix,
  354. .#{$module}-prefix,
  355. .#{$prefix}-icon {
  356. color: $color-input_disabled-text-default;
  357. }
  358. }
  359. }
  360. .#{$module} {
  361. border: none;
  362. outline: none;
  363. width: 100%;
  364. color: inherit;
  365. padding-left: $spacing-input-paddingLeft;
  366. padding-right: $spacing-input-paddingRight;
  367. background-color: transparent;
  368. box-sizing: border-box;
  369. &[type="password"]::-ms-reveal,
  370. &[type="password"]::-ms-clear {
  371. display: none;
  372. }
  373. &[type="search"]::-webkit-search-cancel-button {
  374. display: none;
  375. }
  376. &::placeholder {
  377. color: $color-input_placeholder-text-default;
  378. }
  379. &-large {
  380. height: $height-input_large;
  381. @include font-size-header-6;
  382. line-height: $height-input_large;
  383. }
  384. &-small {
  385. height: $height-input_small;
  386. @include font-size-regular;
  387. line-height: $height-input_small;
  388. }
  389. &-default {
  390. height: $height-input_default;
  391. @include font-size-regular;
  392. line-height: $height-input_default;
  393. }
  394. &-disabled {
  395. cursor: not-allowed;
  396. color: inherit;
  397. }
  398. // &-prefix {
  399. // padding: 0 $spacing-tight;
  400. // display: flex;
  401. // align-items: center;
  402. // height: 100%;
  403. // width: auto;
  404. // white-space: nowrap;
  405. // }
  406. &-inset-label {
  407. margin-right: $spacing-input_insetLabel-marginRight;
  408. font-weight: $font-input_insetLabel-fontWeight;
  409. @include font-size-regular;
  410. color: $color-input_prefix-text-default;
  411. flex-shrink: 0;
  412. white-space: nowrap;
  413. }
  414. &-prefix,
  415. &-suffix {
  416. @include all-center;
  417. &-text {
  418. margin: 0 $spacing-base-tight;
  419. color: $color-input_prefix-text-default;
  420. font-weight: $font-weight-bold;
  421. white-space: nowrap;
  422. }
  423. &-icon {
  424. color: $color-input-icon-default;
  425. margin: $spacing-input_prefix_icon-marginY $spacing-input_prefix_icon-marginX;
  426. }
  427. }
  428. &-suffix {
  429. @include all-center;
  430. }
  431. &-clearbtn,
  432. &-modebtn {
  433. display: flex;
  434. align-items: center;
  435. height: 100%;
  436. justify-content: center;
  437. min-width: $width-input-icon;
  438. }
  439. &-clearbtn + &-suffix {
  440. & + .#{$module}-suffix-text {
  441. margin-left: 0;
  442. }
  443. & + .#{$module}-suffix-icon {
  444. margin-left: 0;
  445. }
  446. }
  447. &-suffix-hidden {
  448. display: none;
  449. }
  450. &-prepend,
  451. &-append {
  452. height: 100%;
  453. display: flex;
  454. align-items: center;
  455. background-color: $color-input_default-bg-default;
  456. color: $color-input_prefix-text-default;
  457. &-icon,
  458. &-text {
  459. padding: $spacing-input_prepend-paddingY $spacing-input_prepend-paddingX;
  460. }
  461. @include font-size-regular;
  462. flex-shrink: 0;
  463. }
  464. &-append {
  465. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  466. border-left: $width-input_append-border $color-input_default-border-default solid;
  467. }
  468. &-prepend {
  469. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  470. border-right: $width-input_prepend-border $color-input_default-border-default solid;
  471. }
  472. &-disabled {
  473. &::placeholder {
  474. color: $color-input_disabled-text-default;
  475. }
  476. }
  477. &-group {
  478. display: inline-flex;
  479. align-items: center;
  480. align-content: center;
  481. flex-wrap: wrap;
  482. // select与autocomplete的border-radius都是基于select
  483. .#{$prefix}-select,
  484. .#{$prefix}-tagInput,
  485. .#{$prefix}-cascader,
  486. .#{$prefix}-tree-select,
  487. & > .#{$module}-wrapper {
  488. border-radius: 0;
  489. &:first-child {
  490. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  491. }
  492. &:last-child {
  493. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  494. }
  495. &:not(:last-child) {
  496. position: relative;
  497. &::after {
  498. content: '';
  499. background-color: $color-input_group-border-default;
  500. width: $width-input_group_pseudo-border;
  501. // height: $inputGroup-border-height;
  502. position: absolute;
  503. right: -1px;
  504. top: 1px;
  505. bottom: 1px;
  506. }
  507. }
  508. }
  509. .#{$prefix}-select{
  510. overflow-y: visible;
  511. }
  512. .#{$prefix}-input-number,
  513. .#{$prefix}-datepicker,
  514. .#{$prefix}-timepicker,
  515. .#{$prefix}-autocomplete {
  516. border-radius: 0;
  517. .#{$prefix}-datepicker-range-input {
  518. border-radius: 0;
  519. }
  520. &:first-child {
  521. .#{$module}-wrapper,
  522. .#{$prefix}-datepicker-range-input {
  523. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  524. }
  525. }
  526. &:last-child {
  527. .#{$module}-wrapper,
  528. .#{$prefix}-datepicker-range-input {
  529. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  530. }
  531. }
  532. &:not(:last-child) {
  533. position: relative;
  534. &::after {
  535. content: '';
  536. background-color: $color-input_group-border-default;
  537. width: $width-input_group_pseudo-border;
  538. // height: $inputGroup-border-height;
  539. position: absolute;
  540. right: -1px;
  541. top: 1px;
  542. bottom: 1px;
  543. }
  544. }
  545. }
  546. }
  547. &-group-wrapper {
  548. &-with-top-label {
  549. margin-top: $spacing-input_group_withTopLabel-marginTop;
  550. margin-bottom: $spacing-input_group_withTopLabel-marginBottom;
  551. .#{$prefix}-input-group {
  552. display: flex;
  553. }
  554. .#{$prefix}-input-group {
  555. .#{$prefix}-form-field {
  556. margin-top: 0;
  557. margin-bottom: 0;
  558. }
  559. }
  560. }
  561. }
  562. }
  563. .#{$module}-only_border{
  564. background: transparent;
  565. &:hover{
  566. background: transparent;
  567. border-color: $color_input-default-border-only_border-hover;
  568. }
  569. &:focus-within{
  570. background: transparent;
  571. }
  572. border-color: $color_input-default-border-only_border-default;
  573. }
  574. .#{$module}-borderless{
  575. &:not(:focus-within):not(:hover){
  576. background-color:transparent;
  577. border-color: transparent;
  578. }
  579. &:focus-within:not(:active){
  580. background-color:transparent;
  581. }
  582. &.#{$module}-wrapper-error:not(:focus-within){
  583. border-color: $color-input_danger-border-focus;
  584. }
  585. &.#{$module}-wrapper-warning:not(:focus-within){
  586. border-color: $color-input_warning-border-focus;
  587. }
  588. }
  589. @import "./rtl.scss";