2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-12-22 02:48:56 +00:00

Format ts files using prettier, update dependencies

This commit is contained in:
Tomas Kirda 2023-10-10 18:34:26 -05:00
parent 16ad576b8c
commit abbdea0901
7 changed files with 123 additions and 3326 deletions

50
package-lock.json generated
View File

@ -8,20 +8,32 @@
"name": "devbridge-autocomplete",
"version": "1.4.11",
"license": "MIT",
"dependencies": {
"@types/jquery": "^2.0.32",
"jquery": ">=1.9"
},
"devDependencies": {
"@types/jquery": "^3.5.22",
"grunt": "^1.0.1",
"grunt-contrib-uglify": "^1.0.1",
"prettier": "^3.0.3"
"jquery-mockjax": "^2.6.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
"peerDependencies": {
"jquery": ">=1.9"
}
},
"node_modules/@types/jquery": {
"version": "2.0.62",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.62.tgz",
"integrity": "sha512-Vlx/LB+xegi1LIY9+G9M9iNG74u3z/KeX8SCGfTuhlVB9hqFlXxiIACjJ6/GiWnhGTG+DxpPEfU0mo3wxiRhpA=="
"version": "3.5.22",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.22.tgz",
"integrity": "sha512-ISQFeUK5GwRftLK4PVvKTWEVCxZ2BpaqBz0TWkIq5w4vGojxZP9+XkqgcPjxoqmPeew+HLyWthCBvK7GdF5NYA==",
"dev": true,
"dependencies": {
"@types/sizzle": "*"
}
},
"node_modules/@types/sizzle": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.4.tgz",
"integrity": "sha512-jA2llq2zNkg8HrALI7DtWzhALcVH0l7i89yhY3iBdOz6cBPeACoFq+fkQrjHA39t1hnSFOboZ7A/AY5MMZSlag==",
"dev": true
},
"node_modules/abbrev": {
"version": "1.1.1",
@ -1022,6 +1034,15 @@
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz",
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg=="
},
"node_modules/jquery-mockjax": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/jquery-mockjax/-/jquery-mockjax-2.6.0.tgz",
"integrity": "sha512-KNlIYbC5m+dr6t5ZQJSW+9cZf6wMiAc2XiJXAywBjvxnfRWTF+qaZLLk2mTc8NGXbPE0RQsfYu+mbS83ScALhg==",
"dev": true,
"dependencies": {
"jquery": ">=1.5.2"
}
},
"node_modules/js-yaml": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
@ -1823,6 +1844,19 @@
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
"dev": true
},
"node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/uglify-js": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz",

View File

@ -14,14 +14,16 @@
"type": "git",
"url": "git://github.com/devbridge/jQuery-Autocomplete.git"
},
"dependencies": {
"@types/jquery": "^2.0.32",
"peerDependencies": {
"jquery": ">=1.9"
},
"devDependencies": {
"@types/jquery": "^3.5.22",
"grunt": "^1.0.1",
"grunt-contrib-uglify": "^1.0.1",
"prettier": "^3.0.3"
"jquery-mockjax": "^2.6.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
"prettier": {
"printWidth": 100,

View File

@ -1,7 +1,3 @@
Devbridge Group accelerates software to market for enterprise clients through dedicated product teams, user experience and software engineering expertise.
[www.devbridge.com](http://www.devbridge.com/)
# Ajax Autocomplete for jQuery
Ajax Autocomplete for jQuery allows you to easily create

View File

@ -9,11 +9,8 @@
<script type="text/javascript" src="lib/jasmine-2.0.1/boot.js"></script>
<!-- jQuery -->
<script src="../scripts/jquery-2.1.1.js"></script>
<script src="../scripts/jquery.mockjax.js"></script>
<script type="text/javascript">
window.JSON || document.write('<scr' + 'ipt src="//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.min.js"><\/scr' + 'ipt>');
</script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="../node_modules/jquery-mockjax/dist/jquery.mockjax.js"></script>
<!-- Autocomplete -->
<script src="../src/jquery.autocomplete.js"></script>

View File

@ -1,10 +1,8 @@
///<reference path="../jquery/jquery.d.ts" />
///<reference path="../jquery-autocomplete/jquery.autocomplete.d.ts" />
// ----------------------------------------------------------------------------------------
// --------------------------------- WEBSITE EXAMPLE --------------------------------------
// ---------- https://www.devbridge.com/sourcery/components/jquery-autocomplete/ ----------
// --------------- https://devbridge.github.io/jQuery-Autocomplete/ -----------------------
// ----------------------------------------------------------------------------------------
var input = $('#autocomplete');
@ -21,33 +19,33 @@ input.autocomplete({
serviceUrl: '/autocomplete/countries',
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
}
},
});
// Local lookup (no ajax):
var countries = [
{ value: 'Andorra', data: 'AD' },
// ...
{ value: 'Zimbabwe', data: 'ZZ' }
{ value: 'Zimbabwe', data: 'ZZ' },
];
input.autocomplete({
lookup: countries,
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
}
},
});
// Non standard query/results
input.autocomplete({
paramName: 'searchString',
transformResult: function(response: any, originalQuery: string): AutocompleteResponse {
transformResult: function (response: any, originalQuery: string): AutocompleteResponse {
return {
suggestions: $.map(response.myData, function (dataItem) {
return {value: dataItem.valueField, data: dataItem.dataField};
})
return { value: dataItem.valueField, data: dataItem.dataField };
}),
};
}
},
});
// ----------------------------------------------------------------------------------------
@ -68,13 +66,11 @@ input.autocomplete().enable();
input.autocomplete().hide();
input.autocomplete().dispose();
// ----------------------------------------------------------------------------------------
// ------------------------------ TEST DEFAULT OPTIONS ------------------------------------
// ----------------------------------------------------------------------------------------
input.autocomplete({
//----------------o AJAX SETTINGS
serviceUrl: '/autocomplete/countries',
@ -88,69 +84,69 @@ input.autocomplete({
//----------------o CONFIG SETTINGS
noCache: false,
delimiter: "-",
delimiter: '-',
onSearchStart(query: string) {
console.log("query: ", query);
console.log('query: ', query);
},
onSearchComplete(query: string, suggestions: AutocompleteSuggestion[]) {
console.log("query: ", query);
console.log("suggestions: ", suggestions);
console.log('query: ', query);
console.log('suggestions: ', suggestions);
},
onSearchError(query: string, jqXHR: JQueryXHR, textStatus: string, errorThrown: any) {
console.log("query: ", query);
console.log("jqXHR: ", jqXHR);
console.log("textStatus: ", textStatus);
console.log("errorThrown: ", errorThrown);
console.log('query: ', query);
console.log('jqXHR: ', jqXHR);
console.log('textStatus: ', textStatus);
console.log('errorThrown: ', errorThrown);
},
transformResult(response: any, originalQuery: string): AutocompleteResponse {
return {
suggestions: [
{ value: 'Andorra', data: 'AD' },
// ...
{ value: 'Zimbabwe', data: 'ZZ' }
]
}
return {
suggestions: [
{ value: 'Andorra', data: 'AD' },
// ...
{ value: 'Zimbabwe', data: 'ZZ' },
],
};
},
onSelect(suggestion: AutocompleteSuggestion) {
console.log("suggestions: ", suggestion);
console.log('suggestions: ', suggestion);
},
minChars: 1,
lookupLimit: 1,
lookup: [
{ value: 'Andorra', data: 'AD' },
// ...
{ value: 'Zimbabwe', data: 'ZZ' }
{ value: 'Zimbabwe', data: 'ZZ' },
],
lookupFilter(suggestion: AutocompleteSuggestion, query: string, queryLowercase: string): any {
return query !== "query"
return query !== 'query';
},
triggerSelectOnValidInput: true,
preventBadQueries: true,
autoSelectFirst: false,
onHide(container: any) {
console.log("container: ", container);
console.log('container: ', container);
},
//----------------o PRESENTATION SETTINGS
beforeRender(container: any) {
console.log("container: ", container);
console.log('container: ', container);
},
formatResult(suggestion: AutocompleteSuggestion, currentValue: string): string {
return currentValue;
},
groupBy: "category",
groupBy: 'category',
maxHeight: 300,
width: "auto",
width: 'auto',
zIndex: 9999,
appendTo: document.body,
forceFixPosition: false,
orientation: "bottom",
orientation: 'bottom',
preserveInput: false,
showNoSuggestionNotice: false,
noSuggestionNotice: "No results",
noSuggestionNotice: 'No results',
onInvalidateSelection() {
console.log("onInvalidateSelection");
console.log('onInvalidateSelection');
},
tabDisabled: false
tabDisabled: false,
});

View File

@ -1,25 +1,20 @@
// Type definitions for jQuery-Autocomplete 1.2.25
// Project: https://www.devbridge.com/sourcery/components/jquery-autocomplete/
// Type definitions for jQuery-Autocomplete 1.4.11
// Project: https://github.com/devbridge/jQuery-Autocomplete
// Definitions by: John Gouigouix <https://github.com/orchestra-ts/DefinitelyTyped/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery"/>
interface AutocompleteSuggestion {
value: string;
data: any;
}
interface AutocompleteResponse {
suggestions: AutocompleteSuggestion[];
}
interface JQueryAutocompleteOptions {
//----------------o AJAX SETTINGS
/**
@ -38,7 +33,7 @@ interface JQueryAutocompleteOptions {
* You may return a json object in your callback when using jsonp.
* @default "text"
*/
dataType?: "text" | "json" | "jsonp";
dataType?: 'text' | 'json' | 'jsonp';
/**
* The name of the request parameter that contains the query.
@ -62,7 +57,6 @@ interface JQueryAutocompleteOptions {
*/
ajaxSettings?: JQueryAjaxSettings;
//----------------o CONFIG SETTINGS
/**
@ -81,7 +75,7 @@ interface JQueryAutocompleteOptions {
* Called before ajax request. this is bound to input element.
* @param query
*/
onSearchStart? (query: string): void;
onSearchStart?(query: string): void;
/**
* Called after ajax response is processed. this is bound to input element.
@ -89,7 +83,7 @@ interface JQueryAutocompleteOptions {
* @param query
* @param suggestions
*/
onSearchComplete? (query: string, suggestions: AutocompleteSuggestion[]): void;
onSearchComplete?(query: string, suggestions: AutocompleteSuggestion[]): void;
/**
* Called if ajax request fails. this is bound to input element.
@ -98,21 +92,21 @@ interface JQueryAutocompleteOptions {
* @param textStatus
* @param errorThrown
*/
onSearchError? (query: string, jqXHR: JQueryXHR, textStatus: string, errorThrown: any): void;
onSearchError?(query: string, jqXHR: JQueryXHR, textStatus: string, errorThrown: any): void;
/**
* Called after the result of the query is ready. Converts the result into response.suggestions format.
* @param response
* @param originalQuery
*/
transformResult? (response: any, originalQuery: string): AutocompleteResponse;
transformResult?(response: any, originalQuery: string): AutocompleteResponse;
/**
* Callback function invoked when user selects suggestion from the list.
* This inside callback refers to input HtmlElement.
* @param suggestion
*/
onSelect? (suggestion: AutocompleteSuggestion): void;
onSelect?(suggestion: AutocompleteSuggestion): void;
/**
* Minimum number of characters required to trigger autosuggest.
@ -130,7 +124,10 @@ interface JQueryAutocompleteOptions {
* Callback function or lookup array for the suggestions. It may be array of strings or suggestion object literals.
* -> suggestion: An object literal with the following format: { value: 'string', data: any }.
*/
lookup?: { (query: string, done: { (results: AutocompleteResponse): void }): void } | string[] | AutocompleteSuggestion[];
lookup?:
| { (query: string, done: { (results: AutocompleteResponse): void }): void }
| string[]
| AutocompleteSuggestion[];
/**
* Filter function for local lookups. By default it does partial string match (case insensitive).
@ -138,7 +135,7 @@ interface JQueryAutocompleteOptions {
* @param query
* @param queryLowercase
*/
lookupFilter? (suggestion: AutocompleteSuggestion, query: string, queryLowercase: string): any;
lookupFilter?(suggestion: AutocompleteSuggestion, query: string, queryLowercase: string): any;
/**
* Boolean value indicating if select should be triggered if it matches suggestion.
@ -163,8 +160,7 @@ interface JQueryAutocompleteOptions {
* Called before container will be hidden
* @param container
*/
onHide? (container: any): void;
onHide?(container: any): void;
//----------------o PRESENTATION SETTINGS
@ -172,14 +168,14 @@ interface JQueryAutocompleteOptions {
* Called before displaying the suggestions. You may manipulate suggestions DOM before it is displayed.
* @param container
*/
beforeRender? (container: any): void;
beforeRender?(container: any): void;
/**
* Custom function to format suggestion entry inside suggestions container, optional.
* @param suggestion
* @param currentValue
*/
formatResult? (suggestion: AutocompleteSuggestion, currentValue: string): string;
formatResult?(suggestion: AutocompleteSuggestion, currentValue: string): string;
/**
* Property name of the suggestion data object, by which results should be grouped.
@ -224,7 +220,7 @@ interface JQueryAutocompleteOptions {
* If set to auto, the suggestions will be orientated it the way that place them closer to middle of the view port.
* @default "bottom"
*/
orientation?: "bottom" | "auto" | "top"
orientation?: 'bottom' | 'auto' | 'top';
/**
* If true, input value stays the same when navigating over suggestions.
@ -247,27 +243,23 @@ interface JQueryAutocompleteOptions {
/**
* Called when input is altered after selection has been made. this is bound to input element.
*/
onInvalidateSelection? (): void;
onInvalidateSelection?(): void;
/**
* Set to true to leave the cursor in the input field after the user tabs to select a suggestion.
* @default false
*/
tabDisabled?: boolean;
}
interface AutocompleteStatic {
/**
* Default options for all instances.
*/
defaults: JQueryAutocompleteOptions
defaults: JQueryAutocompleteOptions;
}
interface AutocompleteInstance {
/**
* you may update any option at any time. Options are listed above.
* @param options
@ -303,17 +295,13 @@ interface AutocompleteInstance {
* destroys autocomplete instance. All events are detached and suggestion containers removed.
*/
dispose(): void;
}
interface JQueryStatic {
Autocomplete: AutocompleteStatic
Autocomplete: AutocompleteStatic;
}
interface JQuery {
/**
* Create Autocomplete component
*/
@ -331,43 +319,46 @@ interface JQuery {
* @param methodName The name of the method
* @param options
*/
autocomplete(methodName: "setOptions", options: JQueryAutocompleteOptions): AutocompleteInstance;
autocomplete(
methodName: 'setOptions',
options: JQueryAutocompleteOptions,
): AutocompleteInstance;
/**
* Clears suggestion cache and current suggestions suggestions.
* @param methodName The name of the method
*/
autocomplete(methodName: "clear"): AutocompleteInstance;
autocomplete(methodName: 'clear'): AutocompleteInstance;
/**
* Clears suggestion cache.
* @param methodName The name of the method
*/
autocomplete(methodName: "clearCache"): AutocompleteInstance;
autocomplete(methodName: 'clearCache'): AutocompleteInstance;
/**
* Deactivate autocomplete.
* @param methodName The name of the method
*/
autocomplete(methodName: "disable"): AutocompleteInstance;
autocomplete(methodName: 'disable'): AutocompleteInstance;
/**
* Activates autocomplete if it was deactivated before.
* @param methodName The name of the method
*/
autocomplete(methodName: "enable"): AutocompleteInstance;
autocomplete(methodName: 'enable'): AutocompleteInstance;
/**
* Hides suggestions.
* @param methodName The name of the method
*/
autocomplete(methodName: "hide"): AutocompleteInstance;
autocomplete(methodName: 'hide'): AutocompleteInstance;
/**
* Destroys autocomplete instance. All events are detached and suggestion containers removed.
* @param methodName The name of the method
*/
autocomplete(methodName: "dispose"): AutocompleteInstance;
autocomplete(methodName: 'dispose'): AutocompleteInstance;
/**
* Create Autocomplete component via plugin alias
@ -386,42 +377,44 @@ interface JQuery {
* @param methodName The name of the method
* @param options
*/
devbridgeAutocomplete(methodName: "setOptions", options: JQueryAutocompleteOptions): AutocompleteInstance;
devbridgeAutocomplete(
methodName: 'setOptions',
options: JQueryAutocompleteOptions,
): AutocompleteInstance;
/**
* Clears suggestion cache and current suggestions suggestions.
* @param methodName The name of the method
*/
devbridgeAutocomplete(methodName: "clear"): AutocompleteInstance;
devbridgeAutocomplete(methodName: 'clear'): AutocompleteInstance;
/**
* Clears suggestion cache.
* @param methodName The name of the method
*/
devbridgeAutocomplete(methodName: "clearCache"): AutocompleteInstance;
devbridgeAutocomplete(methodName: 'clearCache'): AutocompleteInstance;
/**
* Deactivate autocomplete.
* @param methodName The name of the method
*/
devbridgeAutocomplete(methodName: "disable"): AutocompleteInstance;
devbridgeAutocomplete(methodName: 'disable'): AutocompleteInstance;
/**
* Activates autocomplete if it was deactivated before.
* @param methodName The name of the method
*/
devbridgeAutocomplete(methodName: "enable"): AutocompleteInstance;
devbridgeAutocomplete(methodName: 'enable'): AutocompleteInstance;
/**
* Hides suggestions.
* @param methodName The name of the method
*/
devbridgeAutocomplete(methodName: "hide"): AutocompleteInstance;
devbridgeAutocomplete(methodName: 'hide'): AutocompleteInstance;
/**
* Destroys autocomplete instance. All events are detached and suggestion containers removed.
* @param methodName The name of the method
*/
devbridgeAutocomplete(methodName: "dispose"): AutocompleteInstance;
devbridgeAutocomplete(methodName: 'dispose'): AutocompleteInstance;
}

File diff suppressed because it is too large Load Diff