@itrocks/autocomplete 0.1.7 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autocomplete.d.ts +1 -1
- package/autocomplete.js +14 -4
- package/package.json +1 -1
package/autocomplete.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class AutoComplete {
|
|
|
34
34
|
onInputValueChange(): void;
|
|
35
35
|
onKeyDown(event: KeyboardEvent): void;
|
|
36
36
|
onTouchStart(event: Event): void;
|
|
37
|
-
openSuggestions(event: Event): boolean;
|
|
37
|
+
openSuggestions(event: Event, force?: boolean): boolean;
|
|
38
38
|
select(): void;
|
|
39
39
|
suggest(value?: string): void;
|
|
40
40
|
updateSuggestions(items: Item[], startsWith?: string): void;
|
package/autocomplete.js
CHANGED
|
@@ -166,7 +166,7 @@ export class AutoComplete {
|
|
|
166
166
|
keyDown(event) {
|
|
167
167
|
if (DEBUG)
|
|
168
168
|
console.log('keyDown()');
|
|
169
|
-
if (this.openSuggestions(event))
|
|
169
|
+
if (this.openSuggestions(event, true))
|
|
170
170
|
return;
|
|
171
171
|
if (this.suggestions.isLastSelected())
|
|
172
172
|
return;
|
|
@@ -197,6 +197,8 @@ export class AutoComplete {
|
|
|
197
197
|
if (DEBUG)
|
|
198
198
|
console.log('input.value =');
|
|
199
199
|
this.input.value = '';
|
|
200
|
+
this.lastStart = '';
|
|
201
|
+
this.suggestions.removeList();
|
|
200
202
|
this.onInputValueChange();
|
|
201
203
|
this.autoIdInputValue();
|
|
202
204
|
}
|
|
@@ -217,8 +219,16 @@ export class AutoComplete {
|
|
|
217
219
|
onBlur(_event) {
|
|
218
220
|
if (DEBUG)
|
|
219
221
|
console.log('onBlur()');
|
|
222
|
+
const suggestion = this.suggestions.selected();
|
|
220
223
|
this.suggestions.removeList();
|
|
221
|
-
if (
|
|
224
|
+
if (suggestion
|
|
225
|
+
&& this.idInput?.value
|
|
226
|
+
&& (this.input.value !== suggestion.caption)
|
|
227
|
+
&& (toInsensitive(this.input.value) === toInsensitive(suggestion.caption))) {
|
|
228
|
+
this.input.value = suggestion.caption;
|
|
229
|
+
this.onInputValueChange();
|
|
230
|
+
}
|
|
231
|
+
else if (!this.options.allowNew && this.idInput && this.input.value && !this.idInput.value) {
|
|
222
232
|
this.input.value = '';
|
|
223
233
|
this.onInputValueChange();
|
|
224
234
|
this.autoIdInputValue();
|
|
@@ -267,7 +277,7 @@ export class AutoComplete {
|
|
|
267
277
|
onTouchStart(event) {
|
|
268
278
|
this.openSuggestions(event);
|
|
269
279
|
}
|
|
270
|
-
openSuggestions(event) {
|
|
280
|
+
openSuggestions(event, force = false) {
|
|
271
281
|
if (DEBUG)
|
|
272
282
|
console.log('openSuggestions()');
|
|
273
283
|
const suggestions = this.suggestions;
|
|
@@ -281,7 +291,7 @@ export class AutoComplete {
|
|
|
281
291
|
console.log('OS: isVisible is true => return');
|
|
282
292
|
return false;
|
|
283
293
|
}
|
|
284
|
-
if ((suggestions.length > 1) || (!this.input.value.length && suggestions.length)) {
|
|
294
|
+
if (force || (suggestions.length > 1) || (!this.input.value.length && suggestions.length)) {
|
|
285
295
|
if (DEBUG)
|
|
286
296
|
console.log('OS: has items => show');
|
|
287
297
|
event.preventDefault();
|
package/package.json
CHANGED