1- import  {  defineComponent ,  provide ,  Transition , toRefs ,  ref ,  SetupContext ,  Teleport  }  from  'vue' 
2- import  {  autoCompleteProps ,  AutoCompleteProps ,  DropdownPropsKey  }  from  './auto-complete-types' 
3- import  useCustomTemplate  from  './composables/use-custom-template' 
4- import  useSearchFn  from  './composables/use-searchfn' 
5- import  useInputHandle  from  './composables/use-input-handle' 
6- import  useSelectHandle  from  './composables/use-select-handle' 
7- import  useLazyHandle  from  './composables/use-lazy-handle' 
8- import  useKeyBoardHandle  from  './composables/use-keyboard-select' 
9- import  './auto-complete.scss' 
10- import  DAutoCompleteDropdown  from  './components/dropdown' 
11- import  ClickOutside  from  '../../shared/devui-directive/clickoutside' 
12- import  { FlexibleOverlay }  from  '../../overlay/src/flexible-overlay' 
1+ import  {  defineComponent ,  provide ,  Transition ,   toRefs ,  ref ,  SetupContext ,  Teleport  }  from  'vue' ; 
2+ import  {  autoCompleteProps ,  AutoCompleteProps ,  DropdownPropsKey  }  from  './auto-complete-types' ; 
3+ import  useCustomTemplate  from  './composables/use-custom-template' ; 
4+ import  useSearchFn  from  './composables/use-searchfn' ; 
5+ import  useInputHandle  from  './composables/use-input-handle' ; 
6+ import  useSelectHandle  from  './composables/use-select-handle' ; 
7+ import  useLazyHandle  from  './composables/use-lazy-handle' ; 
8+ import  useKeyBoardHandle  from  './composables/use-keyboard-select' ; 
9+ import  './auto-complete.scss' ; 
10+ import  DAutoCompleteDropdown  from  './components/dropdown' ; 
11+ import  ClickOutside  from  '../../shared/devui-directive/clickoutside' ; 
12+ import  {   FlexibleOverlay   }  from  '../../overlay/src/flexible-overlay' ; 
1313
1414export  default  defineComponent ( { 
1515 name : 'DAutoComplete' , 
1616 directives : {  ClickOutside } , 
1717 props : autoCompleteProps , 
1818 emits : [ 'update:modelValue' ] , 
19-  setup ( props : AutoCompleteProps ,  ctx :SetupContext )  { 
19+  setup ( props : AutoCompleteProps ,  ctx :  SetupContext )  { 
2020 const  { 
2121 disabled, 
2222 modelValue, 
@@ -30,30 +30,17 @@ export default defineComponent({
3030 searchFn, 
3131 position, 
3232 latestSource, 
33-  showAnimation
34-  }  =  toRefs ( props ) 
33+  showAnimation, 
34+  }  =  toRefs ( props ) ; 
3535
36-  const  { 
37-  handleSearch, 
38-  searchList, 
39-  showNoResultItemTemplate, 
40-  recentlyFocus
41-  }  =  useSearchFn ( 
36+  const  {  handleSearch,  searchList,  showNoResultItemTemplate,  recentlyFocus }  =  useSearchFn ( 
4237 ctx , 
4338 allowEmptyValueSearch , 
4439 source , 
4540 searchFn , 
4641 formatter 
47-  ) 
48-  const  { 
49-  onInput, 
50-  onFocus, 
51-  inputRef, 
52-  visible, 
53-  searchStatus, 
54-  handleClose, 
55-  toggleMenu
56-  }  =  useInputHandle ( 
42+  ) ; 
43+  const  {  onInput,  onFocus,  inputRef,  visible,  searchStatus,  handleClose,  toggleMenu }  =  useInputHandle ( 
5744 ctx , 
5845 searchList , 
5946 showNoResultItemTemplate , 
@@ -64,37 +51,11 @@ export default defineComponent({
6451 transInputFocusEmit , 
6552 recentlyFocus , 
6653 latestSource 
67-  ) 
68-  const  { 
69-  selectedIndex, 
70-  selectOptionClick
71-  }  =  useSelectHandle ( 
72-  ctx , 
73-  searchList , 
74-  selectValue , 
75-  handleSearch , 
76-  formatter , 
77-  handleClose 
78-  ) 
79-  const  { 
80-  showLoading, 
81-  dropDownRef, 
82-  loadMore
83-  }  =  useLazyHandle ( 
84-  props , 
85-  ctx , 
86-  handleSearch 
87-  ) 
88-  const  { 
89-  customRenderSolts
90-  }  =  useCustomTemplate ( 
91-  ctx , 
92-  modelValue 
93-  ) 
94-  const  { 
95-  hoverIndex, 
96-  handlekeyDown
97-  }  =  useKeyBoardHandle ( 
54+  ) ; 
55+  const  {  selectedIndex,  selectOptionClick }  =  useSelectHandle ( ctx ,  searchList ,  selectValue ,  handleSearch ,  formatter ,  handleClose ) ; 
56+  const  {  showLoading,  dropDownRef,  loadMore }  =  useLazyHandle ( props ,  ctx ,  handleSearch ) ; 
57+  const  {  customRenderSolts }  =  useCustomTemplate ( ctx ,  modelValue ) ; 
58+  const  {  hoverIndex,  handlekeyDown }  =  useKeyBoardHandle ( 
9859 dropDownRef , 
9960 visible , 
10061 searchList , 
@@ -103,12 +64,12 @@ export default defineComponent({
10364 showNoResultItemTemplate , 
10465 selectOptionClick , 
10566 handleClose 
106-  ) 
67+  ) ; 
10768 provide ( DropdownPropsKey ,  { 
10869 props, 
10970 visible, 
11071 term : '' , 
111-  searchList :searchList , 
72+  searchList :  searchList , 
11273 selectedIndex, 
11374 searchStatus, 
11475 selectOptionClick, 
@@ -117,63 +78,54 @@ export default defineComponent({
11778 loadMore, 
11879 latestSource, 
11980 modelValue, 
120-  showNoResultItemTemplate :showNoResultItemTemplate , 
121-  hoverIndex :hoverIndex 
122-  } ) 
123-  const  origin  =  ref < HTMLElement > ( ) 
124-   
81+  showNoResultItemTemplate :  showNoResultItemTemplate , 
82+  hoverIndex :  hoverIndex , 
83+  } ) ; 
84+  const  origin  =  ref < HTMLElement > ( ) ; 
85+ 
12586 const  renderDropdown  =  ( )  =>  { 
12687 return  ( 
127-  < Teleport  to = 'body' > 
128-  < Transition  name = { showAnimation ?'fade' :'' } > 
129-  < FlexibleOverlay 
130-  origin = { origin . value } 
131-  position = { position . value } 
132-  v-model = { visible . value } 
133-  > 
88+  < Teleport  to = "body" > 
89+  < Transition  name = { showAnimation  ? 'fade'  : '' } > 
90+  < FlexibleOverlay  origin = { origin . value }  position = { position . value }  v-model = { visible . value } > 
13491 < div 
135-  class = ' devui-auto-complete-menu' 
92+  class = " devui-auto-complete-menu" 
13693 style = { { 
13794 width : ` 
138-  ${ width . value + 'px' }  
139-  ` 
140-  } } 
141-  > 
142-  < DAutoCompleteDropdown > 
143-  { customRenderSolts ( ) } 
144-  </ DAutoCompleteDropdown > 
95+  ${ width . value  +  'px' }  
96+  ` , 
97+  } } > 
98+  < DAutoCompleteDropdown > { customRenderSolts ( ) } </ DAutoCompleteDropdown > 
14599 </ div > 
146100 </ FlexibleOverlay > 
147101 </ Transition > 
148-  </ Teleport > 
149-  ) 
150- 
151-  } 
102+  </ Teleport > 
103+  ) ; 
104+  } ; 
152105 return  ( )  =>  { 
153106 return  ( 
154107 < div 
155-  class = { [ 'devui-auto-complete' , 'devui-form-group' , 'devui-has-feedback' , visible . value && 'devui-select-open' ] } 
108+  class = { [ 'devui-auto-complete' ,   'devui-form-group' ,   'devui-has-feedback' ,   visible . value   &&   'devui-select-open' ] } 
156109 ref = { origin } 
157110 v-click-outside = { handleClose } 
158111 style = { { 
159-  width : `${ width . value + 'px' }  
160-  } } 
161-  > 
112+  width : `${ width . value  +  'px' }  , 
113+  } } > 
162114 < input 
163115 disabled = { disabled . value } 
164116 type = "text" 
165117 onClick = { toggleMenu } 
166-  class = { [ 'devui-form-control' , 'devui-dropdown-origin' , 'devui-dropdown-origin-open' , disabled . value && 'disabled' ] } 
118+  class = { [ 'devui-form-control' ,   'devui-dropdown-origin' ,   'devui-dropdown-origin-open' ,   disabled . value   &&   'disabled' ] } 
167119 placeholder = "Search" 
168120 onInput = { onInput } 
169121 onFocus = { onFocus } 
170122 value = { modelValue . value } 
171-  ref   =   { inputRef } 
123+  ref = { inputRef } 
172124 onKeydown = { handlekeyDown } 
173125 /> 
174126 { renderDropdown ( ) } 
175127 </ div > 
176-  ) 
177-  } 
178-  } 
179- } ) 
128+  ) ; 
129+  } ; 
130+  } , 
131+ } ) ; 
0 commit comments