@@ -22,10 +22,11 @@ import type { VueClassType } from '../../utils/VueTypes.ts'
2222
2323import { mdiAlertCircleOutline , mdiCheck } from ' @mdi/js'
2424import { computed , useAttrs , useTemplateRef , warn } from ' vue'
25+ import NcButton from ' ../NcButton/NcButton.vue'
26+ import NcIconSvgWrapper from ' ../NcIconSvgWrapper/NcIconSvgWrapper.vue'
27+ import { useIsDarkTheme } from ' ../../composables/useIsDarkTheme/index.ts'
2528import { createElementId } from ' ../../utils/createElementId.ts'
2629import { isLegacy } from ' ../../utils/legacy.ts'
27- import NcButton from ' ../NcButton/index.ts'
28- import NcIconSvgWrapper from ' ../NcIconSvgWrapper/index.ts'
2930
3031export interface NcInputFieldProps {
3132 /**
@@ -161,6 +162,8 @@ const attrs = useAttrs()
161162
162163const inputElement = useTemplateRef (' input' )
163164
165+ const isDarkTheme = useIsDarkTheme ()
166+
164167const hasTrailingIcon = computed (() => props .showTrailingButton || props .success )
165168
166169const internalPlaceholder = computed (() => {
@@ -231,6 +234,7 @@ function handleInput(event: Event) {
231234 <div
232235 class =" input-field"
233236 :class =" [{
237+ 'input-field--dark': isDarkTheme,
234238 'input-field--disabled': disabled,
235239 'input-field--error': error,
236240 'input-field--label-outside': labelOutside || !isValidLabel,
@@ -308,12 +312,11 @@ function handleInput(event: Event) {
308312</template >
309313
310314<style lang="scss" scoped>
315+ @use ' ../../assets/input-border.scss' as border ;
311316
312317.input-field {
313318 --input-border-color : var (--color-border-maxcontrast );
314319 --input-border-radius : var (--border-radius-element );
315- // Used e.g. if border width differs between focused and unfocused we need to compensate to prevent jumping
316- --input-border-width-offset : calc (var (--border-width-input-focused , 2px ) - var (--border-width-input , 2px ));
317320 // The padding before the input can start (leading button or border)
318321 --input-padding-start : var (--border-radius-element );
319322 // The padding where the input has to end (trailing button or border)
@@ -347,23 +350,15 @@ function handleInput(event: Event) {
347350
348351 & __main-wrapper {
349352 height : var (--default-clickable-area );
350- padding : var (--border-width-input , 2px );
353+ padding : var (--border-width-input-focused , 2px );
351354 position : relative ;
352-
353- & :not (:has ([disabled ])):has (input :focus ),
354- & :not (:has ([disabled ])):has (input :active ) {
355- padding : 0 ;
356- }
357355 }
358356
359357 & __input {
358+ @include border .inputBorder (' .input-field--dark' , ' .input-field--legacy' , var (--input-border-color ));
360359 background-color : var (--color-main-background );
361360 color : var (--color-main-text );
362- border : none ;
363361 border-radius : var (--input-border-radius );
364- box-shadow :
365- 0 -1px var (--input-border-color ),
366- 0 0 0 1px color-mix (in srgb , var (--input-border-color ), 65% transparent );
367362
368363 cursor : pointer ;
369364 -webkit-appearance : textfield !important ;
@@ -373,11 +368,11 @@ function handleInput(event: Event) {
373368 font-size : var (--default-font-size );
374369 text-overflow : ellipsis ;
375370
371+ padding-block : 0 ;
372+ padding-inline : var (--input-padding-start ) var (--input-padding-end );
376373 height : 100% !important ;
377374 min-height : unset ;
378375 width : 100% ;
379- padding-block : var (--input-border-width-offset );
380- padding-inline : calc (var (--input-padding-start ) + var (--input-border-width-offset )) calc (var (--input-padding-end ) + var (--input-border-width-offset ));
381376
382377 & ::placeholder {
383378 color : var (--color-text-maxcontrast );
@@ -397,17 +392,9 @@ function handleInput(event: Event) {
397392 display : none ;
398393 }
399394
400- & :hover:not ([disabled ]) {
401- box-shadow : 0 0 0 1px var (--input-border-color );;
402- }
403-
404395 & :active:not ([disabled ]),
405396 & :focus:not ([disabled ]) {
406397 --input-border-color : var (--color-main-text );
407- // Reset padding offset when focused
408- --input-border-width-offset : 0px ;
409- border : var (--border-width-input-focused , 2px ) solid var (--input-border-color );
410- box-shadow : 0 0 0 2px var (--color-main-background ) !important ;
411398 }
412399
413400 & :focus + .input-field__label ,
@@ -543,23 +530,5 @@ function handleInput(event: Event) {
543530 color : var (--color-border-success , var (--color-success ));
544531 }
545532 }
546-
547- & --legacy {
548- .input-field__input {
549- box-shadow : 0 0 0 1px var (--input-border-color ) inset ;
550- }
551-
552- .input-field__main-wrapper :hover:not (:has ([disabled ])) {
553- padding : 0 ;
554-
555- .input-field__input {
556- --input-border-color : var (--color-main-text );
557- // Reset padding offset when focused
558- --input-border-width-offset : 0px ;
559- border : var (--border-width-input-focused , 2px ) solid var (--input-border-color );
560- box-shadow : 0 0 0 2px var (--color-main-background ) !important ;
561- }
562- }
563- }
564533}
565534 </style >
0 commit comments