input.scss 17 KB

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