input.scss 17 KB

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