input.scss 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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-regular;
  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. &:placeholder-shown {
  370. text-overflow: ellipsis;
  371. }
  372. &[type="password"]::-ms-reveal,
  373. &[type="password"]::-ms-clear {
  374. display: none;
  375. }
  376. &[type="search"]::-webkit-search-cancel-button {
  377. display: none;
  378. }
  379. &::placeholder {
  380. color: $color-input_placeholder-text-default;
  381. }
  382. &-large {
  383. height: $height-input_large;
  384. @include font-size-header-6;
  385. line-height: $height-input_large;
  386. }
  387. &-small {
  388. height: $height-input_small;
  389. @include font-size-regular;
  390. line-height: $height-input_small;
  391. }
  392. &-default {
  393. height: $height-input_default;
  394. @include font-size-regular;
  395. line-height: $height-input_default;
  396. }
  397. &-disabled {
  398. cursor: not-allowed;
  399. color: inherit;
  400. }
  401. // &-prefix {
  402. // padding: 0 $spacing-tight;
  403. // display: flex;
  404. // align-items: center;
  405. // height: 100%;
  406. // width: auto;
  407. // white-space: nowrap;
  408. // }
  409. &-inset-label {
  410. margin: 0 $spacing-input_prefix_suffix-marginX;
  411. font-weight: $font-input_prefix_suffix-fontWeight;
  412. color: $color-input_prefix-text-default;
  413. flex-shrink: 0;
  414. white-space: nowrap;
  415. }
  416. &-prefix,
  417. &-suffix {
  418. @include all-center;
  419. &-text {
  420. margin: 0 $spacing-input_prefix_suffix-marginX;
  421. color: $color-input_prefix-text-default;
  422. font-weight: $font-input_prefix_suffix-fontWeight;
  423. white-space: nowrap;
  424. }
  425. &-icon {
  426. color: $color-input-icon-default;
  427. margin: $spacing-input_prefix_icon-marginY $spacing-input_prefix_icon-marginX;
  428. }
  429. }
  430. &-suffix {
  431. @include all-center;
  432. }
  433. &-clearbtn,
  434. &-modebtn {
  435. display: flex;
  436. align-items: center;
  437. height: 100%;
  438. justify-content: center;
  439. min-width: $width-input-icon;
  440. }
  441. &-clearbtn + &-suffix {
  442. & + .#{$module}-suffix-text {
  443. margin-left: 0;
  444. }
  445. & + .#{$module}-suffix-icon {
  446. margin-left: 0;
  447. }
  448. }
  449. &-suffix-hidden {
  450. display: none;
  451. }
  452. &-prepend,
  453. &-append {
  454. height: 100%;
  455. display: flex;
  456. align-items: center;
  457. background-color: $color-input_default-bg-default;
  458. color: $color-input_prefix-text-default;
  459. @include font-size-regular;
  460. flex-shrink: 0;
  461. &-icon,
  462. &-text {
  463. padding: $spacing-input_prepend-paddingY $spacing-input_prepend-paddingX;
  464. }
  465. }
  466. &-append {
  467. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  468. border-left: $width-input_append-border $color-input_default-border-default solid;
  469. }
  470. &-prepend {
  471. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  472. border-right: $width-input_prepend-border $color-input_default-border-default solid;
  473. }
  474. &-disabled {
  475. &::placeholder {
  476. color: $color-input_disabled-text-default;
  477. }
  478. }
  479. &-group {
  480. display: inline-flex;
  481. align-items: center;
  482. align-content: center;
  483. flex-wrap: wrap;
  484. .#{$prefix}-select,
  485. .#{$prefix}-tagInput,
  486. .#{$prefix}-cascader,
  487. .#{$prefix}-tree-select,
  488. & > .#{$module}-wrapper {
  489. border-radius: 0;
  490. &:first-child {
  491. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  492. }
  493. &:last-child {
  494. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  495. }
  496. &:not(:last-child) {
  497. position: relative;
  498. &::after {
  499. content: '';
  500. background-color: $color-input_group-border-default;
  501. width: $width-input_group_pseudo-border;
  502. // height: $inputGroup-border-height;
  503. position: absolute;
  504. right: -1px;
  505. top: 1px;
  506. bottom: 1px;
  507. }
  508. }
  509. }
  510. .#{$prefix}-select{
  511. overflow-y: visible;
  512. }
  513. .#{$prefix}-input-number,
  514. .#{$prefix}-datepicker,
  515. .#{$prefix}-timepicker,
  516. .#{$prefix}-autocomplete {
  517. .#{$module}-wrapper,
  518. .#{$prefix}-datepicker-range-input {
  519. border-radius: 0;
  520. }
  521. &:first-child {
  522. .#{$module}-wrapper,
  523. .#{$prefix}-datepicker-range-input {
  524. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  525. }
  526. }
  527. &:last-child {
  528. .#{$module}-wrapper,
  529. .#{$prefix}-datepicker-range-input {
  530. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  531. }
  532. }
  533. &:not(:last-child) {
  534. position: relative;
  535. &::after {
  536. content: '';
  537. background-color: $color-input_group-border-default;
  538. width: $width-input_group_pseudo-border;
  539. // height: $inputGroup-border-height;
  540. position: absolute;
  541. right: -1px;
  542. top: 1px;
  543. bottom: 1px;
  544. }
  545. }
  546. }
  547. }
  548. &-group-wrapper {
  549. &-with-top-label {
  550. margin-top: $spacing-input_group_withTopLabel-marginTop;
  551. margin-bottom: $spacing-input_group_withTopLabel-marginBottom;
  552. .#{$prefix}-input-group {
  553. display: flex;
  554. }
  555. .#{$prefix}-input-group {
  556. .#{$prefix}-form-field {
  557. margin-top: 0;
  558. margin-bottom: 0;
  559. }
  560. }
  561. }
  562. }
  563. }
  564. .#{$module}-only_border{
  565. background: transparent;
  566. border-color: $color_input-default-border-only_border-default;
  567. &:hover{
  568. background: transparent;
  569. border-color: $color_input-default-border-only_border-hover;
  570. }
  571. &:focus-within{
  572. background: transparent;
  573. }
  574. }
  575. .#{$module}-borderless{
  576. &:not(:focus-within):not(:hover){
  577. background-color:transparent;
  578. border-color: transparent;
  579. }
  580. &:focus-within:not(:active){
  581. background-color:transparent;
  582. }
  583. &.#{$module}-wrapper-error:not(:focus-within){
  584. border-color: $color-input_danger-border-focus;
  585. }
  586. &.#{$module}-wrapper-warning:not(:focus-within){
  587. border-color: $color-input_warning-border-focus;
  588. }
  589. }
  590. @import "./rtl.scss";