input.scss 17 KB

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