input.scss 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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. &:hover {
  310. background-color: $color-input_disabled-bg-default;
  311. }
  312. .#{$module}-append,
  313. .#{$module}-prepend,
  314. .#{$module}-suffix,
  315. .#{$module}-prefix,
  316. .#{$prefix}-icon {
  317. color: $color-input_disabled-text-default;
  318. }
  319. }
  320. }
  321. .#{$module} {
  322. border: none;
  323. outline: none;
  324. width: 100%;
  325. color: inherit;
  326. padding-left: $spacing-input-paddingLeft;
  327. padding-right: $spacing-input-paddingRight;
  328. background-color: transparent;
  329. box-sizing: border-box;
  330. &::placeholder {
  331. color: $color-input_placeholder-text-default;
  332. }
  333. &-large {
  334. height: $height-input_large;
  335. @include font-size-header-6;
  336. line-height: $height-input_large;
  337. }
  338. &-small {
  339. height: $height-input_small;
  340. @include font-size-regular;
  341. line-height: $height-input_small;
  342. }
  343. &-default {
  344. height: $height-input_default;
  345. @include font-size-regular;
  346. line-height: $height-input_default;
  347. }
  348. &-disabled {
  349. cursor: not-allowed;
  350. color: inherit;
  351. }
  352. // &-prefix {
  353. // padding: 0 $spacing-tight;
  354. // display: flex;
  355. // align-items: center;
  356. // height: 100%;
  357. // width: auto;
  358. // white-space: nowrap;
  359. // }
  360. &-inset-label {
  361. margin-right: $spacing-input_insetLabel-marginRight;
  362. font-weight: $font-input_insetLabel-fontWeight;
  363. @include font-size-regular;
  364. color: $color-input_prefix-text-default;
  365. flex-shrink: 0;
  366. white-space: nowrap;
  367. }
  368. &-prefix,
  369. &-suffix {
  370. @include all-center;
  371. &-text {
  372. margin: 0 $spacing-base-tight;
  373. color: $color-input_prefix-text-default;
  374. font-weight: 600;
  375. white-space: nowrap;
  376. }
  377. &-icon {
  378. color: $color-input-icon-default;
  379. margin: $spacing-input_prefix_icon-marginY $spacing-input_prefix_icon-marginX;
  380. }
  381. }
  382. &-suffix {
  383. @include all-center;
  384. }
  385. &-clearbtn,
  386. &-modebtn {
  387. display: flex;
  388. align-items: center;
  389. height: 100%;
  390. justify-content: center;
  391. min-width: $width-input-icon;
  392. }
  393. &-clearbtn + &-suffix {
  394. & + .#{$module}-suffix-text {
  395. margin-left: 0;
  396. }
  397. & + .#{$module}-suffix-icon {
  398. margin-left: 0;
  399. }
  400. }
  401. &-suffix-hidden {
  402. display: none;
  403. }
  404. &-prepend,
  405. &-append {
  406. height: 100%;
  407. display: flex;
  408. align-items: center;
  409. background-color: $color-input_default-bg-default;
  410. color: $color-input_prefix-text-default;
  411. &-icon,
  412. &-text {
  413. padding: $spacing-input_prepend-paddingY $spacing-input_prepend-paddingX;
  414. }
  415. @include font-size-regular;
  416. flex-shrink: 0;
  417. }
  418. &-append {
  419. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  420. border-left: $width-input_append-border $color-input_default-border-default solid;
  421. }
  422. &-prepend {
  423. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  424. border-right: $width-input_prepend-border $color-input_default-border-default solid;
  425. }
  426. &-disabled {
  427. &::placeholder {
  428. color: $color-input_disabled-text-default;
  429. }
  430. }
  431. &-group {
  432. display: inline-flex;
  433. align-items: center;
  434. align-content: center;
  435. flex-wrap: wrap;
  436. // select与autocomplete的border-radius都是基于select
  437. .#{$prefix}-select,
  438. .#{$prefix}-cascader,
  439. .#{$prefix}-tree-select,
  440. & > .#{$module}-wrapper {
  441. border-radius: 0;
  442. &:first-child {
  443. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  444. }
  445. &:last-child {
  446. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  447. }
  448. &:not(:last-child) {
  449. position: relative;
  450. &::after {
  451. content: '';
  452. background-color: $color-input_group-border-default;
  453. width: $width-input_group_pseudo-border;
  454. // height: $inputGroup-border-height;
  455. position: absolute;
  456. right: -1px;
  457. top: 1px;
  458. bottom: 1px;
  459. }
  460. }
  461. }
  462. .#{$prefix}-input-number,
  463. .#{$prefix}-datepicker,
  464. .#{$prefix}-autocomplete {
  465. border-radius: 0;
  466. .#{$prefix}-datepicker-range-input {
  467. border-radius: 0;
  468. }
  469. &:first-child {
  470. .#{$module}-wrapper,
  471. .#{$prefix}-datepicker-range-input {
  472. border-radius: $radius-input_wrapper 0 0 $radius-input_wrapper;
  473. }
  474. }
  475. &:last-child {
  476. .#{$module}-wrapper,
  477. .#{$prefix}-datepicker-range-input {
  478. border-radius: 0 $radius-input_wrapper $radius-input_wrapper 0;
  479. }
  480. }
  481. &:not(:last-child) {
  482. position: relative;
  483. &::after {
  484. content: '';
  485. background-color: $color-input_group-border-default;
  486. width: $width-input_group_pseudo-border;
  487. // height: $inputGroup-border-height;
  488. position: absolute;
  489. right: -1px;
  490. top: 1px;
  491. bottom: 1px;
  492. }
  493. }
  494. }
  495. }
  496. &-group-wrapper {
  497. &-with-top-label {
  498. margin-top: $spacing-input_group_withTopLabel-marginTop;
  499. margin-bottom: $spacing-input_group_withTopLabel-marginBottom;
  500. .#{$prefix}-input-group {
  501. display: flex;
  502. }
  503. .#{$prefix}-input-group {
  504. .#{$prefix}-form-field {
  505. margin-top: 0;
  506. margin-bottom: 0;
  507. }
  508. }
  509. }
  510. }
  511. }
  512. @import "./rtl.scss";