11import  {  defineComponent ,  watch ,  inject ,  toRefs ,  shallowRef ,  ref ,  computed ,  getCurrentInstance  }  from  'vue' ; 
22import  type  {  SetupContext  }  from  'vue' ; 
33import  Icon  from  '../../icon/src/icon' ; 
4+ import  {  AutoFocus  }  from  '../../auto-focus' ; 
45import  {  inputProps ,  InputProps  }  from  './input-types' ; 
56import  {  FORM_ITEM_TOKEN ,  FormItemContext  }  from  '../../form/src/components/form-item/form-item-types' ; 
6- import  {  useNamespace  }  from  '../../ shared/hooks/use-namespace ' ; 
7+ import  {  useNamespace  }  from  '@devui/ shared/utils ' ; 
78import  {  useInputRender  }  from  './composables/use-input-render' ; 
89import  {  useInputEvent  }  from  './composables/use-input-event' ; 
910import  {  useInputFunction  }  from  './composables/use-input-function' ; 
@@ -12,6 +13,9 @@ import { createI18nTranslate } from '../../locale/create';
1213
1314export  default  defineComponent ( { 
1415 name : 'DInput' , 
16+  directives : { 
17+  dAutoFocus : AutoFocus , 
18+  } , 
1519 inheritAttrs : false , 
1620 props : inputProps , 
1721 emits : [ 'update:modelValue' ,  'focus' ,  'blur' ,  'input' ,  'change' ,  'keydown' ,  'clear' ] , 
@@ -20,15 +24,16 @@ export default defineComponent({
2024 const  t  =  createI18nTranslate ( 'DInput' ,  app ) ; 
2125
2226 const  formItemContext  =  inject ( FORM_ITEM_TOKEN ,  undefined )  as  FormItemContext ; 
23-  const  {  modelValue }  =  toRefs ( props ) ; 
27+  const  {  modelValue,  placeholder ,  title ,  autofocus  }  =  toRefs ( props ) ; 
2428 const  ns  =  useNamespace ( 'input' ) ; 
2529 const  slotNs  =  useNamespace ( 'input-slot' ) ; 
2630 const  {  inputDisabled,  inputSize,  isFocus,  wrapClasses,  inputClasses,  customStyle,  otherAttrs }  =  useInputRender ( props ,  ctx ) ; 
2731
2832 const  input  =  shallowRef < HTMLInputElement > ( ) ; 
2933 const  {  select,  focus,  blur }  =  useInputFunction ( input ) ; 
3034
31-  const  {  onFocus,  onBlur,  onInput,  onChange,  onKeydown,  onClear }  =  useInputEvent ( isFocus ,  props ,  ctx ,  focus ) ; 
35+  const  {  onFocus,  onBlur,  onInput,  onChange,  onKeydown,  onClear,  onCompositionStart,  onCompositionUpdate,  onCompositionEnd }  = 
36+  useInputEvent ( isFocus ,  props ,  ctx ,  focus ) ; 
3237
3338 const  passwordVisible  =  ref ( false ) ; 
3439 const  clickPasswordIcon  =  ( )  =>  { 
@@ -67,17 +72,22 @@ export default defineComponent({
6772 ) } 
6873 < input 
6974 ref = { input } 
75+  v-dAutoFocus = { autofocus . value } 
7076 value = { modelValue . value } 
7177 disabled = { inputDisabled . value } 
7278 class = { ns . e ( 'inner' ) } 
73-  placeholder = { props . placeholder   ||  t ( 'placeholder' ) } 
79+  placeholder = { placeholder . value   ??  t ( 'placeholder' ) } 
7480 { ...otherAttrs } 
81+  title = { title . value } 
7582 type = { props . showPassword  ? ( passwordVisible . value  ? 'text'  : 'password' )  : 'text' } 
7683 onInput = { onInput } 
7784 onFocus = { onFocus } 
7885 onBlur = { onBlur } 
7986 onChange = { onChange } 
8087 onKeydown = { onKeydown } 
88+  onCompositionstart = { onCompositionStart } 
89+  onCompositionupdate = { onCompositionUpdate } 
90+  onCompositionend = { onCompositionEnd } 
8191 /> 
8292 { suffixVisible  &&  ( 
8393 < span  class = { slotNs . e ( 'suffix' ) } > 
@@ -92,7 +102,7 @@ export default defineComponent({
92102 /> 
93103 ) } 
94104 { showClearable . value  &&  ( 
95-  < Icon  size = { inputSize . value }  class = { ns . em ( 'clear' ,  'icon' ) }  name = "close "  onClick = { onClear }  /> 
105+  < Icon  size = { inputSize . value }  class = { ns . em ( 'clear' ,  'icon' ) }  name = "error-o"    color = "#adb0b8 "onClick = { onClear }  /> 
96106 ) } 
97107 </ span > 
98108 ) } 
0 commit comments