1111 <input v-if =" name" type =" hidden" :name =" name" :value =" modelValue" :disabled =" effectiveDisabled" :required =" required" >
1212 <div class =" input-group" >
1313 <label v-if =" withCheckbox" class =" input-group-addon" >
14- <input v-model =" checked" type =" checkbox" :name =" typeof withCheckbox === 'string' ? withCheckbox : null " value =" 1" >
14+ <input v-model =" checked" type =" checkbox" :name =" typeof withCheckbox === 'string' ? withCheckbox : undefined " value =" 1" >
1515 </label >
1616
1717 <input
5151 </li >
5252 </ul >
5353
54- <slot name =" dropdownTrigger" :disabled =" effectiveDisabled" :clickHandler =" dropdownClick" >
54+ <slot name =" dropdownTrigger" :disabled =" effectiveDisabled" :click-handler =" dropdownClick" >
5555 <a href =" javascript:void(0)" role =" button" class =" input-group-addon dropdown-toggle" :class =" {disabled: effectiveDisabled}" data-dropdown =" dropdown" :disabled =" effectiveDisabled" @click.prevent =" dropdownClick" >
5656 <span class =" caret" />
5757 <pf-icon name =" glyphicon-remove" />
@@ -82,7 +82,7 @@ export default defineComponent({
8282 default: null ,
8383 },
8484 modelValue: {
85- type: [String , Number ],
85+ type: [String , Number ] as PropType < string | number | null > ,
8686 default: null ,
8787 },
8888 placeholder: {
@@ -108,11 +108,11 @@ export default defineComponent({
108108 default: ' id' ,
109109 },
110110 match: {
111- type: Function ,
111+ type: Function as PropType <( o : NormalizedOption , q : string ) => boolean > ,
112112 default : (o : NormalizedOption , q : string ) => o .label .toString ().toLowerCase ().includes (q .toLowerCase ()),
113113 },
114114 highlight: {
115- type: Function ,
115+ type: Function as PropType <( o : NormalizedOption , q : string ) => string > ,
116116 default : (o : NormalizedOption , q : string ) => o .label .replace (new RegExp (q .replace (/ [-[\] {}()*+?. ,\\ ^$|#\s ] / g , ' \\ $&' ), ' ig' ), ' <strong>$&</strong>' ),
117117 },
118118 withCheckbox: {
@@ -123,8 +123,8 @@ export default defineComponent({
123123 },
124124
125125 emits: {
126- update : (value : string | number ) => value !== undefined ,
127- ' update:modelValue' : (value : string | number ) => value !== undefined ,
126+ update : (value : string | number | null ) => value !== undefined ,
127+ ' update:modelValue' : (value : string | number | null ) => value !== undefined ,
128128 },
129129
130130 setup(props ) {
@@ -133,10 +133,10 @@ export default defineComponent({
133133
134134 data(this : void ) {
135135 return {
136- blurTimeout: null as ReturnType <typeof setTimeout > | null ,
136+ blurTimeout: undefined as ReturnType <typeof setTimeout > | undefined ,
137137 showOptions: false ,
138- filter: null as string ,
139- active: null as string | number ,
138+ filter: null as string | null ,
139+ active: null as string | number | null ,
140140 hasError: false ,
141141 checked: false ,
142142 };
@@ -148,7 +148,7 @@ export default defineComponent({
148148 },
149149
150150 label() {
151- if (! this .hasValue || typeof this .optionsMap [this .modelValue ] === ' undefined' ) {
151+ if (this .modelValue === null || typeof this .optionsMap [this .modelValue ] === ' undefined' ) {
152152 return ' ' ;
153153 }
154154 return this .optionsMap [this .modelValue ].label ;
@@ -173,15 +173,17 @@ export default defineComponent({
173173 if (this .filter === null ) {
174174 return [];
175175 }
176- return Object .values (this .optionsMap ).reduce ((options , o ) => {
176+
177+ const options = [];
178+ for (const o of Object .values (this .optionsMap )) {
177179 if (this .match (o , this .filter )) {
178180 options .push ({
179181 ... o ,
180182 highlighted: this .highlight (o , this .filter ),
181183 });
182184 }
183- return options ;
184- }, []) ;
185+ }
186+ return options ;
185187 },
186188
187189 text: {
@@ -198,7 +200,7 @@ export default defineComponent({
198200 },
199201
200202 effectiveDisabled() {
201- return this .disabled || (this .withCheckbox && ! this .checked );
203+ return this .disabled || Boolean (this .withCheckbox && ! this .checked );
202204 },
203205 },
204206
@@ -220,7 +222,7 @@ export default defineComponent({
220222 },
221223
222224 methods: {
223- setValue(value : string | number ) {
225+ setValue(value : string | number | null ) {
224226 this .showOptions = false ;
225227 this .filter = null ;
226228 if (value !== this .modelValue ) {
0 commit comments