searchpicker
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -14,2 +14,3 @@ import { IPickerItem } from "../pickeritems/IPickerItem"; | ||
resultRenderer?: (item: IPickerItem, query: string) => Node; | ||
resultFooterRenderer?: (query: string, results: IPickerItem[], data?: any) => Node; | ||
noResultsRenderer?: (query: string) => Node; | ||
@@ -16,0 +17,0 @@ choiceRenderer?: (item: IPickerItem, renderClose?: boolean) => Node; |
@@ -8,3 +8,3 @@ import { ISearcher } from "./ISearcher"; | ||
private tmrId; | ||
search(query: string, options: ISearchPickerOptions, onresults: (items: IPickerItem[]) => void, onerror?: (message: string) => void): void; | ||
search(query: string, options: ISearchPickerOptions, onresults: (items: IPickerItem[], data?: any) => void, onerror?: (message: string) => void): void; | ||
} |
@@ -11,3 +11,3 @@ import { IPickerItem } from "../pickeritems/IPickerItem"; | ||
*/ | ||
search(query: string, options: ISearchPickerOptions, onresults: (items: IPickerItem[]) => void, onerror?: (message: string) => void): any; | ||
search(query: string, options: ISearchPickerOptions, onresults: (items: IPickerItem[], data?: any) => void, onerror?: (message: string, data?: any) => void): any; | ||
} |
@@ -40,3 +40,4 @@ import { IPickerItem } from "./pickeritems/IPickerItem"; | ||
private bindEvents(); | ||
private $buildResult(item, query); | ||
private $buildResult(item, query, data?); | ||
private $buildResultsFooter(query, results?, data?); | ||
private clearHighlighted(); | ||
@@ -43,0 +44,0 @@ private $buildNoResults(query); |
@@ -172,3 +172,3 @@ "use strict"; | ||
this.setProcessSearchResponses(true); | ||
return this.options.searcher.search(query, this.options, function (items) { | ||
return this.options.searcher.search(query, this.options, function (items, data) { | ||
if (query !== _this.lastSearchQuery || !_this.processSearchResponses) { | ||
@@ -201,11 +201,15 @@ return; | ||
_this.hide(); | ||
return; | ||
} | ||
else { | ||
_this.resultsElm.appendChild(_this.$buildNoResults(query)); | ||
_this.show(); | ||
} | ||
} | ||
else { | ||
_this.show(); | ||
if (_this.options.resultFooterRenderer) { | ||
var footer = _this.$buildResultsFooter(query, items, data); | ||
if (footer != null) { | ||
_this.resultsElm.appendChild(footer); | ||
} | ||
} | ||
_this.show(); | ||
}, function (message) { | ||
@@ -242,3 +246,3 @@ _this.resultsElm.appendChild(_this.$buildErrorResult(message)); | ||
}; | ||
SearchPickerResults.prototype.$buildResult = function (item, query) { | ||
SearchPickerResults.prototype.$buildResult = function (item, query, data) { | ||
var result = document.createElement('li'); | ||
@@ -253,2 +257,16 @@ result.className = 'result'; | ||
}; | ||
SearchPickerResults.prototype.$buildResultsFooter = function (query, results, data) { | ||
var footer = document.createElement('div'); | ||
footer.className = 'result-footer'; | ||
if (this.options.resultFooterRenderer) { | ||
var footerContent = this.options.resultFooterRenderer(query, results, data); | ||
if (footerContent) { | ||
footer.appendChild(footerContent); | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
return footer; | ||
}; | ||
SearchPickerResults.prototype.clearHighlighted = function () { | ||
@@ -255,0 +273,0 @@ this.highlightedIndex = this.getDefaultHighlightedIndex(); |
{ | ||
"name": "searchpicker", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/Index.js", |
@@ -18,2 +18,3 @@ import {IPickerItem} from "../pickeritems/IPickerItem"; | ||
resultRenderer?: (item: IPickerItem, query: string) => Node; | ||
resultFooterRenderer?: (query: string, results: IPickerItem[], data?:any) => Node; | ||
noResultsRenderer?: (query: string) => Node; | ||
@@ -20,0 +21,0 @@ choiceRenderer?: (item: IPickerItem, renderClose?: boolean) => Node; |
@@ -15,3 +15,3 @@ import {ISearcher} from "./ISearcher"; | ||
, options: ISearchPickerOptions | ||
, onresults: (items: IPickerItem[]) => void | ||
, onresults: (items: IPickerItem[], data?:any) => void | ||
, onerror?: (message: string) => void) { | ||
@@ -18,0 +18,0 @@ |
@@ -14,5 +14,5 @@ import {IPickerItem} from "../pickeritems/IPickerItem"; | ||
, options: ISearchPickerOptions | ||
, onresults: (items: IPickerItem[]) => void | ||
, onerror?: (message: string) => void); | ||
, onresults: (items: IPickerItem[], data?:any) => void | ||
, onerror?: (message: string, data?:any) => void); | ||
} | ||
@@ -181,3 +181,3 @@ import {Utility} from "./Utils"; | ||
this.setProcessSearchResponses(true); | ||
return this.options.searcher.search(query, this.options, (items) => { | ||
return this.options.searcher.search(query, this.options, (items, data) => { | ||
@@ -217,10 +217,19 @@ if (query !== this.lastSearchQuery || !this.processSearchResponses) { | ||
this.hide(); | ||
return; | ||
} else { | ||
this.resultsElm.appendChild(this.$buildNoResults(query)); | ||
this.show(); | ||
} | ||
} else { | ||
this.show(); | ||
} | ||
if(this.options.resultFooterRenderer){ | ||
let footer = this.$buildResultsFooter(query, items, data); | ||
if (footer != null) { | ||
this.resultsElm.appendChild(footer); | ||
} | ||
} | ||
this.show(); | ||
}, (message) => { | ||
@@ -260,3 +269,3 @@ this.resultsElm.appendChild(this.$buildErrorResult(message)); | ||
private $buildResult(item: IPickerItem, query: string): Node { | ||
private $buildResult(item: IPickerItem, query: string, data?:any): Node { | ||
let result = document.createElement('li'); | ||
@@ -272,2 +281,16 @@ result.className = 'result'; | ||
private $buildResultsFooter(query: string, results?:IPickerItem[], data?:any): Node{ | ||
let footer = document.createElement('div'); | ||
footer.className = 'result-footer'; | ||
if(this.options.resultFooterRenderer) { | ||
let footerContent = this.options.resultFooterRenderer(query, results, data); | ||
if(footerContent){ | ||
footer.appendChild(footerContent); | ||
} else { | ||
return null; | ||
} | ||
} | ||
return footer; | ||
} | ||
private clearHighlighted() { | ||
@@ -274,0 +297,0 @@ this.highlightedIndex = this.getDefaultHighlightedIndex(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2947
0
211240