Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-simple-suggest

Package Overview
Dependencies
Maintainers
4
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-simple-suggest - npm Package Compare versions

Comparing version 1.11.0 to 1.11.1

41

dist/cjs.js

@@ -65,4 +65,3 @@ 'use strict';

}function _invokeIgnored(body) {
var result = body();
if (result && result.then) {
var result = body();if (result && result.then) {
return result.then(_empty);

@@ -79,3 +78,2 @@ }

}function _finally(body, finalizer) {
try {

@@ -285,10 +283,12 @@ var result = body();

_this3.inputElement = _this3.$refs['inputSlot'].querySelector('input');
_this3.$nextTick(function () {
_this3.inputElement = _this3.$refs['inputSlot'].querySelector('input');
if (_this3.inputElement) {
_this3.setInputAriaAttributes();
_this3.prepareEventHandlers(true);
} else {
console.error('No input element found');
}
if (_this3.inputElement) {
_this3.setInputAriaAttributes();
_this3.prepareEventHandlers(true);
} else {
console.error('No input element found');
}
});
});

@@ -534,2 +534,4 @@ } catch (e) {

suggestionClick: function suggestionClick(suggestion, e) {
var _this8 = this;
this.$emit('suggestion-click', suggestion, e);

@@ -540,8 +542,12 @@ this.select(suggestion);

/// Ensure, that all needed flags are off before finishing the click.
this.isClicking = false;
if (this.isClicking) {
setTimeout(function () {
_this8.inputElement.focus();
/// Ensure, that all needed flags are off before finishing the click.
_this8.isClicking = false;
}, 0);
}
},
onBlur: function onBlur(e) {
var _this8 = this;
if (this.isInFocus) {

@@ -560,5 +566,2 @@

this.isFalseFocus = true;
setTimeout(function () {
_this8.inputElement.focus();
}, 0);
}

@@ -604,3 +607,5 @@ } else {

return;
}if (this.debounce) {
}
if (this.debounce) {
clearTimeout(this.timeoutInstance);

@@ -607,0 +612,0 @@ this.timeoutInstance = setTimeout(this.research, this.debounce);

@@ -59,4 +59,3 @@ const defaultControls = {

}function _invokeIgnored(body) {
var result = body();
if (result && result.then) {
var result = body();if (result && result.then) {
return result.then(_empty);

@@ -73,3 +72,2 @@ }

}function _finally(body, finalizer) {
try {

@@ -265,10 +263,12 @@ var result = body();

_this.inputElement = _this.$refs['inputSlot'].querySelector('input');
_this.$nextTick(() => {
_this.inputElement = _this.$refs['inputSlot'].querySelector('input');
if (_this.inputElement) {
_this.setInputAriaAttributes();
_this.prepareEventHandlers(true);
} else {
console.error('No input element found');
}
if (_this.inputElement) {
_this.setInputAriaAttributes();
_this.prepareEventHandlers(true);
} else {
console.error('No input element found');
}
});
});

@@ -505,4 +505,10 @@ }),

/// Ensure, that all needed flags are off before finishing the click.
this.isClicking = false;
if (this.isClicking) {
setTimeout(() => {
this.inputElement.focus();
/// Ensure, that all needed flags are off before finishing the click.
this.isClicking = false;
}, 0);
}
},

@@ -523,5 +529,2 @@ onBlur(e) {

this.isFalseFocus = true;
setTimeout(() => {
this.inputElement.focus();
}, 0);
}

@@ -572,3 +575,5 @@ } else {

return;
}if (this.debounce) {
}
if (this.debounce) {
clearTimeout(this.timeoutInstance);

@@ -575,0 +580,0 @@ this.timeoutInstance = setTimeout(this.research, this.debounce);

@@ -215,10 +215,12 @@ const defaultControls = {

this.inputElement = this.$refs['inputSlot'].querySelector('input');
this.$nextTick(() => {
this.inputElement = this.$refs['inputSlot'].querySelector('input');
if (this.inputElement) {
this.setInputAriaAttributes();
this.prepareEventHandlers(true);
} else {
console.error('No input element found');
}
if (this.inputElement) {
this.setInputAriaAttributes();
this.prepareEventHandlers(true);
} else {
console.error('No input element found');
}
});
},

@@ -447,4 +449,10 @@ beforeDestroy() {

/// Ensure, that all needed flags are off before finishing the click.
this.isClicking = false;
if (this.isClicking) {
setTimeout(() => {
this.inputElement.focus();
/// Ensure, that all needed flags are off before finishing the click.
this.isClicking = false;
}, 0);
}
},

@@ -465,5 +473,2 @@ onBlur(e) {

this.isFalseFocus = true;
setTimeout(() => {
this.inputElement.focus();
}, 0);
}

@@ -470,0 +475,0 @@ } else {

@@ -1,1 +0,1 @@

var VueSimpleSuggest=function(){"use strict";var t={selectionUp:[38],selectionDown:[40],select:[13],hideList:[27],showList:[40],autocomplete:[32,13]},e={input:String,select:Object};function r(t,e){return s(t,e.keyCode)}function s(t,e){if(t.length<=0)return!1;function i(t){return t.some(function(t){return t===e})}return Array.isArray(t[0])?t.some(function(t){return i(t)}):i(t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t};function o(t,e,i){return i?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function l(){}function h(t,e){var i=t();return i&&i.then?i.then(e):e(i)}function c(t,e){try{var i=t()}catch(t){return e(t)}return i&&i.then?i.then(void 0,e):i}function a(t,e){try{var i=t()}catch(t){return e()}return i&&i.then?i.then(e,e):e()}var i={render:function(){var i=this,t=i.$createElement,s=i._self._c||t;return s("div",{staticClass:"vue-simple-suggest",class:[i.styles.vueSimpleSuggest,{designed:!i.destyled,focus:i.isInFocus}],on:{keydown:function(t){if(!t.type.indexOf("key")&&i._k(t.keyCode,"tab",9,t.key,"Tab"))return null;i.isTabbed=!0}}},[s("div",{ref:"inputSlot",staticClass:"input-wrapper",class:i.styles.inputWrapper,attrs:{role:"combobox","aria-haspopup":"listbox","aria-owns":i.listId,"aria-expanded":i.listShown&&!i.removeList?"true":"false"}},[i._t("default",[s("input",i._b({staticClass:"default-input",class:i.styles.defaultInput,domProps:{value:i.text||""}},"input",i.$attrs,!1))])],2),i._v(" "),s("transition",{attrs:{name:"vue-simple-suggest"}},[i.listShown&&!i.removeList?s("ul",{staticClass:"suggestions",class:i.styles.suggestions,attrs:{id:i.listId,role:"listbox","aria-labelledby":i.listId}},[this.$scopedSlots["misc-item-above"]?s("li",[i._t("misc-item-above",null,{suggestions:i.suggestions,query:i.text})],2):i._e(),i._v(" "),i._l(i.suggestions,function(e,t){return s("li",{key:i.getId(e,t),staticClass:"suggest-item",class:[i.styles.suggestItem,{selected:i.isSelected(e),hover:i.isHovered(e)}],attrs:{role:"option","aria-selected":i.isHovered(e)||i.isSelected(e)?"true":"false",id:i.getId(e,t)},on:{mouseenter:function(t){return i.hover(e,t.target)},mouseleave:function(){return i.hover(void 0)},click:function(t){return i.suggestionClick(e,t)}}},[i._t("suggestion-item",[s("span",[i._v(i._s(i.displayProperty(e)))])],{autocomplete:function(){return i.autocompleteText(e)},suggestion:e,query:i.text})],2)}),i._v(" "),this.$scopedSlots["misc-item-below"]?s("li",[i._t("misc-item-below",null,{suggestions:i.suggestions,query:i.text})],2):i._e()],2):i._e()])],1)},staticRenderFns:[],name:"vue-simple-suggest",inheritAttrs:!1,model:{prop:"value",event:"input"},props:{styles:{type:Object,default:function(){return{}}},controls:{type:Object,default:function(){return t}},minLength:{type:Number,default:1},maxSuggestions:{type:Number,default:10},displayAttribute:{type:String,default:"title"},valueAttribute:{type:String,default:"id"},list:{type:[Function,Array],default:function(){return[]}},removeList:{type:Boolean,default:!1},destyled:{type:Boolean,default:!1},filterByQuery:{type:Boolean,default:!1},filter:{type:Function,default:function(t,e){return!e||~this.displayProperty(t).toLowerCase().indexOf(e.toLowerCase())}},debounce:{type:Number,default:0},nullableSelect:{type:Boolean,default:!1},value:{},mode:{type:String,default:"input",validator:function(t){return!!~Object.keys(e).indexOf(t.toLowerCase())}},preventHide:{type:Boolean,default:!1}},watch:{mode:{handler:function(t){var e=this;this.constructor.options.model.event=t,this.$parent&&this.$parent.$forceUpdate(),this.$nextTick(function(){"input"===t?e.$emit("input",e.text):e.$emit("select",e.selected)})},immediate:!0},value:{handler:function(t){"string"!=typeof t&&(t=this.displayProperty(t)),this.updateTextOutside(t)},immediate:!0}},data:function(){return{selected:null,hovered:null,suggestions:[],listShown:!1,inputElement:null,canSend:!0,timeoutInstance:null,text:this.value,isPlainSuggestion:!1,isClicking:!1,isInFocus:!1,isFalseFocus:!1,isTabbed:!1,controlScheme:{},listId:this._uid+"-suggestions"}},computed:{listIsRequest:function(){return"function"==typeof this.list},inputIsComponent:function(){return this.$slots.default&&0<this.$slots.default.length&&!!this.$slots.default[0].componentInstance},input:function(){return this.inputIsComponent?this.$slots.default[0].componentInstance:this.inputElement},on:function(){return this.inputIsComponent?"$on":"addEventListener"},off:function(){return this.inputIsComponent?"$off":"removeEventListener"},hoveredIndex:function(){for(var t=0;t<this.suggestions.length;t++){var e=this.suggestions[t];if(this.hovered&&this.valueProperty(this.hovered)==this.valueProperty(e))return t}return-1},textLength:function(){return this.text&&this.text.length||this.inputElement.value.length||0},isSelectedUpToDate:function(){return!!this.selected&&this.displayProperty(this.selected)===this.text}},created:function(){this.controlScheme=u({},t,this.controls)},mounted:function(){try{var t=this;return o(t.$slots.default,function(){t.inputElement=t.$refs.inputSlot.querySelector("input"),t.inputElement?(t.setInputAriaAttributes(),t.prepareEventHandlers(!0)):console.error("No input element found")})}catch(t){return Promise.reject(t)}},beforeDestroy:function(){this.prepareEventHandlers(!1)},methods:{isEqual:function(t,e){return e&&this.valueProperty(t)==this.valueProperty(e)},isSelected:function(t){return this.isEqual(t,this.selected)},isHovered:function(t){return this.isEqual(t,this.hovered)},setInputAriaAttributes:function(){this.inputElement.setAttribute("aria-activedescendant",""),this.inputElement.setAttribute("aria-autocomplete","list"),this.inputElement.setAttribute("aria-controls",this.listId)},prepareEventHandlers:function(t){var e=this[t?"on":"off"],i={click:this.showSuggestions,keydown:this.onKeyDown,keyup:this.onListKeyUp},s=u({blur:this.onBlur,focus:this.onFocus,input:this.onInput},i);for(var n in s)this.input[e](n,s[n]);var o=t?"addEventListener":"removeEventListener";for(var r in i)this.inputElement[o](r,i[r])},isScopedSlotEmpty:function(t){if(t){var e=t(this);return!(Array.isArray(e)||e&&(e.tag||e.context||e.text||e.children))}return!0},miscSlotsAreEmpty:function(){var e=this,t=["misc-item-above","misc-item-below"].map(function(t){return e.$scopedSlots[t]});if(t.every(function(t){return!!t}))return t.every(this.isScopedSlotEmpty.bind(this));var i=t.find(function(t){return!!t});return this.isScopedSlotEmpty.call(this,i)},getPropertyByAttribute:function(t,e){return this.isPlainSuggestion?t:void 0!==(void 0===t?"undefined":n(t))?(i=t,e.split(".").reduce(function(t,e){return t===Object(t)?t[e]:t},i)):t;var i},displayProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.displayAttribute);return void 0===e&&(e=JSON.stringify(t),process&&~process.env.NODE_ENV.indexOf("dev")&&console.warn("[vue-simple-suggest]: Please, provide `display-attribute` as a key or a dotted path for a property from your object.")),String(e||"")},valueProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.valueAttribute);return void 0===e&&console.error("[vue-simple-suggest]: Please, check if you passed 'value-attribute' (default is 'id') and 'display-attribute' (default is 'title') props correctly.\n Your list objects should always contain a unique identifier."),e},autocompleteText:function(t){this.setText(this.displayProperty(t))},setText:function(t){var e=this;this.$nextTick(function(){e.inputElement.value=t,e.text=t,e.$emit("input",t)})},select:function(t){(this.selected!==t||this.nullableSelect&&!t)&&(this.selected=t,this.$emit("select",t),t&&this.autocompleteText(t)),this.hover(null)},hover:function(t,e){var i=t?this.getId(t,this.hoveredIndex):"";this.inputElement.setAttribute("aria-activedescendant",i),t&&t!==this.hovered&&this.$emit("hover",t,e),this.hovered=t},hideList:function(){this.listShown&&(this.listShown=!1,this.hover(null),this.$emit("hide-list"))},showList:function(){this.listShown||this.textLength>=this.minLength&&(0<this.suggestions.length||!this.miscSlotsAreEmpty())&&(this.listShown=!0,this.$emit("show-list"))},showSuggestions:function(){try{var t=this;return h(function(){if(0===t.suggestions.length&&t.minLength<=t.textLength)return t.showList(),function(t,e){if(!e)return t&&t.then?t.then(l):Promise.resolve()}(t.research())},function(){t.showList()})}catch(t){return Promise.reject(t)}},onShowList:function(t){r(this.controlScheme.showList,t)&&this.showSuggestions()},moveSelection:function(t){if(this.listShown&&this.suggestions.length&&r([this.controlScheme.selectionUp,this.controlScheme.selectionDown],t)){t.preventDefault();var e=r(this.controlScheme.selectionDown,t),i=2*e-1,s=e?0:this.suggestions.length-1,n=e?this.hoveredIndex<this.suggestions.length-1:0<this.hoveredIndex,o=null;o=this.hovered?n?this.suggestions[this.hoveredIndex+i]:this.suggestions[s]:this.selected||this.suggestions[s],this.hover(o)}},onKeyDown:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;"Enter"===t.key&&this.listShown&&s([e,i],13)&&t.preventDefault(),"Tab"===t.key&&this.hovered&&this.select(this.hovered),this.onShowList(t),this.moveSelection(t),this.onAutocomplete(t)},onListKeyUp:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;this.listShown&&r([e,i],t)&&(t.preventDefault(),r(e,t)&&this.select(this.hovered),this.hideList())},onAutocomplete:function(t){r(this.controlScheme.autocomplete,t)&&(t.ctrlKey||t.shiftKey)&&0<this.suggestions.length&&this.suggestions[0]&&this.listShown&&(t.preventDefault(),this.hover(this.suggestions[0]),this.autocompleteText(this.suggestions[0]))},suggestionClick:function(t,e){this.$emit("suggestion-click",t,e),this.select(t),this.preventHide||this.hideList(),this.isClicking=!1},onBlur:function(t){var e=this;this.isInFocus?(this.isClicking=this.hovered&&!this.isTabbed,this.isClicking?t&&t.isTrusted&&!this.isTabbed&&(this.isFalseFocus=!0,setTimeout(function(){e.inputElement.focus()},0)):(this.isInFocus=!1,this.hideList(),this.$emit("blur",t))):(this.inputElement.blur(),console.error("This should never happen!\n If you encountered this error, please make sure that your input component emits 'focus' events properly.\n For more info see https://github.com/KazanExpress/vue-simple-suggest#custom-input.\n\n If your 'vue-simple-suggest' setup does not include a custom input component - please,\n report to https://github.com/KazanExpress/vue-simple-suggest/issues/new")),this.isTabbed=!1},onFocus:function(t){this.isInFocus=!0,t&&!this.isFalseFocus&&this.$emit("focus",t),this.isClicking||this.isFalseFocus||this.showSuggestions(),this.isFalseFocus=!1},onInput:function(t){var e=t.target?t.target.value:t;this.updateTextOutside(e),this.$emit("input",e)},updateTextOutside:function(t){this.text!==t&&(this.text=t,this.hovered&&this.hover(null),this.text.length<this.minLength?this.hideList():this.debounce?(clearTimeout(this.timeoutInstance),this.timeoutInstance=setTimeout(this.research,this.debounce)):this.research())},research:function(){try{var i=this;return a(function(){return c(function(){return function(t){var e=t();if(e&&e.then)return e.then(l)}(function(){if(i.canSend){i.canSend=!1;var e=i.text;return o(i.getSuggestions(i.text),function(t){e===i.text&&i.$set(i,"suggestions",t)})}})},function(t){throw i.clearSuggestions(),t})},function(){return i.canSend=!0,0===i.suggestions.length&&i.miscSlotsAreEmpty()?i.hideList():i.isInFocus&&i.showList(),i.suggestions})}catch(t){return Promise.reject(t)}},getSuggestions:function(e){try{var i=this;if((e=e||"").length<i.minLength)return[];i.selected=null,i.listIsRequest&&i.$emit("request-start",e);var t=!1,s=[];return a(function(){return c(function(){return h(function(){if(i.listIsRequest)return o(i.list(e),function(t){s=t||[]});s=i.list},function(){Array.isArray(s)||(s=[s]),t="object"!==n(s[0])&&void 0!==s[0]||Array.isArray(s[0]),i.filterByQuery&&(s=s.filter(function(t){return i.filter(t,e)})),i.listIsRequest&&i.$emit("request-done",s)})},function(t){if(!i.listIsRequest)throw t;i.$emit("request-failed",t)})},function(){return i.maxSuggestions&&s.splice(i.maxSuggestions),i.isPlainSuggestion=t,s})}catch(t){return Promise.reject(t)}},clearSuggestions:function(){this.suggestions.splice(0)},getId:function(t,e){return this.listId+"-suggestion-"+(this.isPlainSuggestion?e:this.valueProperty(t)||e)}}};return(Vue||window&&window.Vue)&&(Vue||window.Vue).component("vue-simple-suggest",i),i}();
var VueSimpleSuggest=function(){"use strict";var t={selectionUp:[38],selectionDown:[40],select:[13],hideList:[27],showList:[40],autocomplete:[32,13]},e={input:String,select:Object};function r(t,e){return s(t,e.keyCode)}function s(t,e){if(t.length<=0)return!1;function i(t){return t.some(function(t){return t===e})}return Array.isArray(t[0])?t.some(function(t){return i(t)}):i(t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t};function o(t,e,i){return i?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function l(){}function h(t,e){var i=t();return i&&i.then?i.then(e):e(i)}function c(t,e){try{var i=t()}catch(t){return e(t)}return i&&i.then?i.then(void 0,e):i}function a(t,e){try{var i=t()}catch(t){return e()}return i&&i.then?i.then(e,e):e()}var i={render:function(){var i=this,t=i.$createElement,s=i._self._c||t;return s("div",{staticClass:"vue-simple-suggest",class:[i.styles.vueSimpleSuggest,{designed:!i.destyled,focus:i.isInFocus}],on:{keydown:function(t){if(!t.type.indexOf("key")&&i._k(t.keyCode,"tab",9,t.key,"Tab"))return null;i.isTabbed=!0}}},[s("div",{ref:"inputSlot",staticClass:"input-wrapper",class:i.styles.inputWrapper,attrs:{role:"combobox","aria-haspopup":"listbox","aria-owns":i.listId,"aria-expanded":i.listShown&&!i.removeList?"true":"false"}},[i._t("default",[s("input",i._b({staticClass:"default-input",class:i.styles.defaultInput,domProps:{value:i.text||""}},"input",i.$attrs,!1))])],2),i._v(" "),s("transition",{attrs:{name:"vue-simple-suggest"}},[i.listShown&&!i.removeList?s("ul",{staticClass:"suggestions",class:i.styles.suggestions,attrs:{id:i.listId,role:"listbox","aria-labelledby":i.listId}},[this.$scopedSlots["misc-item-above"]?s("li",[i._t("misc-item-above",null,{suggestions:i.suggestions,query:i.text})],2):i._e(),i._v(" "),i._l(i.suggestions,function(e,t){return s("li",{key:i.getId(e,t),staticClass:"suggest-item",class:[i.styles.suggestItem,{selected:i.isSelected(e),hover:i.isHovered(e)}],attrs:{role:"option","aria-selected":i.isHovered(e)||i.isSelected(e)?"true":"false",id:i.getId(e,t)},on:{mouseenter:function(t){return i.hover(e,t.target)},mouseleave:function(){return i.hover(void 0)},click:function(t){return i.suggestionClick(e,t)}}},[i._t("suggestion-item",[s("span",[i._v(i._s(i.displayProperty(e)))])],{autocomplete:function(){return i.autocompleteText(e)},suggestion:e,query:i.text})],2)}),i._v(" "),this.$scopedSlots["misc-item-below"]?s("li",[i._t("misc-item-below",null,{suggestions:i.suggestions,query:i.text})],2):i._e()],2):i._e()])],1)},staticRenderFns:[],name:"vue-simple-suggest",inheritAttrs:!1,model:{prop:"value",event:"input"},props:{styles:{type:Object,default:function(){return{}}},controls:{type:Object,default:function(){return t}},minLength:{type:Number,default:1},maxSuggestions:{type:Number,default:10},displayAttribute:{type:String,default:"title"},valueAttribute:{type:String,default:"id"},list:{type:[Function,Array],default:function(){return[]}},removeList:{type:Boolean,default:!1},destyled:{type:Boolean,default:!1},filterByQuery:{type:Boolean,default:!1},filter:{type:Function,default:function(t,e){return!e||~this.displayProperty(t).toLowerCase().indexOf(e.toLowerCase())}},debounce:{type:Number,default:0},nullableSelect:{type:Boolean,default:!1},value:{},mode:{type:String,default:"input",validator:function(t){return!!~Object.keys(e).indexOf(t.toLowerCase())}},preventHide:{type:Boolean,default:!1}},watch:{mode:{handler:function(t){var e=this;this.constructor.options.model.event=t,this.$parent&&this.$parent.$forceUpdate(),this.$nextTick(function(){"input"===t?e.$emit("input",e.text):e.$emit("select",e.selected)})},immediate:!0},value:{handler:function(t){"string"!=typeof t&&(t=this.displayProperty(t)),this.updateTextOutside(t)},immediate:!0}},data:function(){return{selected:null,hovered:null,suggestions:[],listShown:!1,inputElement:null,canSend:!0,timeoutInstance:null,text:this.value,isPlainSuggestion:!1,isClicking:!1,isInFocus:!1,isFalseFocus:!1,isTabbed:!1,controlScheme:{},listId:this._uid+"-suggestions"}},computed:{listIsRequest:function(){return"function"==typeof this.list},inputIsComponent:function(){return this.$slots.default&&0<this.$slots.default.length&&!!this.$slots.default[0].componentInstance},input:function(){return this.inputIsComponent?this.$slots.default[0].componentInstance:this.inputElement},on:function(){return this.inputIsComponent?"$on":"addEventListener"},off:function(){return this.inputIsComponent?"$off":"removeEventListener"},hoveredIndex:function(){for(var t=0;t<this.suggestions.length;t++){var e=this.suggestions[t];if(this.hovered&&this.valueProperty(this.hovered)==this.valueProperty(e))return t}return-1},textLength:function(){return this.text&&this.text.length||this.inputElement.value.length||0},isSelectedUpToDate:function(){return!!this.selected&&this.displayProperty(this.selected)===this.text}},created:function(){this.controlScheme=u({},t,this.controls)},mounted:function(){try{var t=this;return o(t.$slots.default,function(){t.$nextTick(function(){t.inputElement=t.$refs.inputSlot.querySelector("input"),t.inputElement?(t.setInputAriaAttributes(),t.prepareEventHandlers(!0)):console.error("No input element found")})})}catch(t){return Promise.reject(t)}},beforeDestroy:function(){this.prepareEventHandlers(!1)},methods:{isEqual:function(t,e){return e&&this.valueProperty(t)==this.valueProperty(e)},isSelected:function(t){return this.isEqual(t,this.selected)},isHovered:function(t){return this.isEqual(t,this.hovered)},setInputAriaAttributes:function(){this.inputElement.setAttribute("aria-activedescendant",""),this.inputElement.setAttribute("aria-autocomplete","list"),this.inputElement.setAttribute("aria-controls",this.listId)},prepareEventHandlers:function(t){var e=this[t?"on":"off"],i={click:this.showSuggestions,keydown:this.onKeyDown,keyup:this.onListKeyUp},s=u({blur:this.onBlur,focus:this.onFocus,input:this.onInput},i);for(var n in s)this.input[e](n,s[n]);var o=t?"addEventListener":"removeEventListener";for(var r in i)this.inputElement[o](r,i[r])},isScopedSlotEmpty:function(t){if(t){var e=t(this);return!(Array.isArray(e)||e&&(e.tag||e.context||e.text||e.children))}return!0},miscSlotsAreEmpty:function(){var e=this,t=["misc-item-above","misc-item-below"].map(function(t){return e.$scopedSlots[t]});if(t.every(function(t){return!!t}))return t.every(this.isScopedSlotEmpty.bind(this));var i=t.find(function(t){return!!t});return this.isScopedSlotEmpty.call(this,i)},getPropertyByAttribute:function(t,e){return this.isPlainSuggestion?t:void 0!==(void 0===t?"undefined":n(t))?(i=t,e.split(".").reduce(function(t,e){return t===Object(t)?t[e]:t},i)):t;var i},displayProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.displayAttribute);return void 0===e&&(e=JSON.stringify(t),process&&~process.env.NODE_ENV.indexOf("dev")&&console.warn("[vue-simple-suggest]: Please, provide `display-attribute` as a key or a dotted path for a property from your object.")),String(e||"")},valueProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.valueAttribute);return void 0===e&&console.error("[vue-simple-suggest]: Please, check if you passed 'value-attribute' (default is 'id') and 'display-attribute' (default is 'title') props correctly.\n Your list objects should always contain a unique identifier."),e},autocompleteText:function(t){this.setText(this.displayProperty(t))},setText:function(t){var e=this;this.$nextTick(function(){e.inputElement.value=t,e.text=t,e.$emit("input",t)})},select:function(t){(this.selected!==t||this.nullableSelect&&!t)&&(this.selected=t,this.$emit("select",t),t&&this.autocompleteText(t)),this.hover(null)},hover:function(t,e){var i=t?this.getId(t,this.hoveredIndex):"";this.inputElement.setAttribute("aria-activedescendant",i),t&&t!==this.hovered&&this.$emit("hover",t,e),this.hovered=t},hideList:function(){this.listShown&&(this.listShown=!1,this.hover(null),this.$emit("hide-list"))},showList:function(){this.listShown||this.textLength>=this.minLength&&(0<this.suggestions.length||!this.miscSlotsAreEmpty())&&(this.listShown=!0,this.$emit("show-list"))},showSuggestions:function(){try{var t=this;return h(function(){if(0===t.suggestions.length&&t.minLength<=t.textLength)return t.showList(),function(t,e){if(!e)return t&&t.then?t.then(l):Promise.resolve()}(t.research())},function(){t.showList()})}catch(t){return Promise.reject(t)}},onShowList:function(t){r(this.controlScheme.showList,t)&&this.showSuggestions()},moveSelection:function(t){if(this.listShown&&this.suggestions.length&&r([this.controlScheme.selectionUp,this.controlScheme.selectionDown],t)){t.preventDefault();var e=r(this.controlScheme.selectionDown,t),i=2*e-1,s=e?0:this.suggestions.length-1,n=e?this.hoveredIndex<this.suggestions.length-1:0<this.hoveredIndex,o=null;o=this.hovered?n?this.suggestions[this.hoveredIndex+i]:this.suggestions[s]:this.selected||this.suggestions[s],this.hover(o)}},onKeyDown:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;"Enter"===t.key&&this.listShown&&s([e,i],13)&&t.preventDefault(),"Tab"===t.key&&this.hovered&&this.select(this.hovered),this.onShowList(t),this.moveSelection(t),this.onAutocomplete(t)},onListKeyUp:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;this.listShown&&r([e,i],t)&&(t.preventDefault(),r(e,t)&&this.select(this.hovered),this.hideList())},onAutocomplete:function(t){r(this.controlScheme.autocomplete,t)&&(t.ctrlKey||t.shiftKey)&&0<this.suggestions.length&&this.suggestions[0]&&this.listShown&&(t.preventDefault(),this.hover(this.suggestions[0]),this.autocompleteText(this.suggestions[0]))},suggestionClick:function(t,e){var i=this;this.$emit("suggestion-click",t,e),this.select(t),this.preventHide||this.hideList(),this.isClicking&&setTimeout(function(){i.inputElement.focus(),i.isClicking=!1},0)},onBlur:function(t){this.isInFocus?(this.isClicking=this.hovered&&!this.isTabbed,this.isClicking?t&&t.isTrusted&&!this.isTabbed&&(this.isFalseFocus=!0):(this.isInFocus=!1,this.hideList(),this.$emit("blur",t))):(this.inputElement.blur(),console.error("This should never happen!\n If you encountered this error, please make sure that your input component emits 'focus' events properly.\n For more info see https://github.com/KazanExpress/vue-simple-suggest#custom-input.\n\n If your 'vue-simple-suggest' setup does not include a custom input component - please,\n report to https://github.com/KazanExpress/vue-simple-suggest/issues/new")),this.isTabbed=!1},onFocus:function(t){this.isInFocus=!0,t&&!this.isFalseFocus&&this.$emit("focus",t),this.isClicking||this.isFalseFocus||this.showSuggestions(),this.isFalseFocus=!1},onInput:function(t){var e=t.target?t.target.value:t;this.updateTextOutside(e),this.$emit("input",e)},updateTextOutside:function(t){this.text!==t&&(this.text=t,this.hovered&&this.hover(null),this.text.length<this.minLength?this.hideList():this.debounce?(clearTimeout(this.timeoutInstance),this.timeoutInstance=setTimeout(this.research,this.debounce)):this.research())},research:function(){try{var i=this;return a(function(){return c(function(){return function(t){var e=t();if(e&&e.then)return e.then(l)}(function(){if(i.canSend){i.canSend=!1;var e=i.text;return o(i.getSuggestions(i.text),function(t){e===i.text&&i.$set(i,"suggestions",t)})}})},function(t){throw i.clearSuggestions(),t})},function(){return i.canSend=!0,0===i.suggestions.length&&i.miscSlotsAreEmpty()?i.hideList():i.isInFocus&&i.showList(),i.suggestions})}catch(t){return Promise.reject(t)}},getSuggestions:function(e){try{var i=this;if((e=e||"").length<i.minLength)return[];i.selected=null,i.listIsRequest&&i.$emit("request-start",e);var t=!1,s=[];return a(function(){return c(function(){return h(function(){if(i.listIsRequest)return o(i.list(e),function(t){s=t||[]});s=i.list},function(){Array.isArray(s)||(s=[s]),t="object"!==n(s[0])&&void 0!==s[0]||Array.isArray(s[0]),i.filterByQuery&&(s=s.filter(function(t){return i.filter(t,e)})),i.listIsRequest&&i.$emit("request-done",s)})},function(t){if(!i.listIsRequest)throw t;i.$emit("request-failed",t)})},function(){return i.maxSuggestions&&s.splice(i.maxSuggestions),i.isPlainSuggestion=t,s})}catch(t){return Promise.reject(t)}},clearSuggestions:function(){this.suggestions.splice(0)},getId:function(t,e){return this.listId+"-suggestion-"+(this.isPlainSuggestion?e:this.valueProperty(t)||e)}}};return(Vue||window&&window.Vue)&&(Vue||window.Vue).component("vue-simple-suggest",i),i}();

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).VueSimpleSuggest=e()}(this,function(){"use strict";var t={selectionUp:[38],selectionDown:[40],select:[13],hideList:[27],showList:[40],autocomplete:[32,13]},e={input:String,select:Object};function r(t,e){return s(t,e.keyCode)}function s(t,e){if(t.length<=0)return!1;function i(t){return t.some(function(t){return t===e})}return Array.isArray(t[0])?t.some(function(t){return i(t)}):i(t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function o(t,e,i){return i?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function u(){}function l(t,e){var i=t();return i&&i.then?i.then(e):e(i)}function h(t,e){try{var i=t()}catch(t){return e(t)}return i&&i.then?i.then(void 0,e):i}function c(t,e){try{var i=t()}catch(t){return e()}return i&&i.then?i.then(e,e):e()}var i={render:function(){var i=this,t=i.$createElement,s=i._self._c||t;return s("div",{staticClass:"vue-simple-suggest",class:[i.styles.vueSimpleSuggest,{designed:!i.destyled,focus:i.isInFocus}],on:{keydown:function(t){if(!t.type.indexOf("key")&&i._k(t.keyCode,"tab",9,t.key,"Tab"))return null;i.isTabbed=!0}}},[s("div",{ref:"inputSlot",staticClass:"input-wrapper",class:i.styles.inputWrapper,attrs:{role:"combobox","aria-haspopup":"listbox","aria-owns":i.listId,"aria-expanded":i.listShown&&!i.removeList?"true":"false"}},[i._t("default",[s("input",i._b({staticClass:"default-input",class:i.styles.defaultInput,domProps:{value:i.text||""}},"input",i.$attrs,!1))])],2),i._v(" "),s("transition",{attrs:{name:"vue-simple-suggest"}},[i.listShown&&!i.removeList?s("ul",{staticClass:"suggestions",class:i.styles.suggestions,attrs:{id:i.listId,role:"listbox","aria-labelledby":i.listId}},[this.$scopedSlots["misc-item-above"]?s("li",[i._t("misc-item-above",null,{suggestions:i.suggestions,query:i.text})],2):i._e(),i._v(" "),i._l(i.suggestions,function(e,t){return s("li",{key:i.getId(e,t),staticClass:"suggest-item",class:[i.styles.suggestItem,{selected:i.isSelected(e),hover:i.isHovered(e)}],attrs:{role:"option","aria-selected":i.isHovered(e)||i.isSelected(e)?"true":"false",id:i.getId(e,t)},on:{mouseenter:function(t){return i.hover(e,t.target)},mouseleave:function(){return i.hover(void 0)},click:function(t){return i.suggestionClick(e,t)}}},[i._t("suggestion-item",[s("span",[i._v(i._s(i.displayProperty(e)))])],{autocomplete:function(){return i.autocompleteText(e)},suggestion:e,query:i.text})],2)}),i._v(" "),this.$scopedSlots["misc-item-below"]?s("li",[i._t("misc-item-below",null,{suggestions:i.suggestions,query:i.text})],2):i._e()],2):i._e()])],1)},staticRenderFns:[],name:"vue-simple-suggest",inheritAttrs:!1,model:{prop:"value",event:"input"},props:{styles:{type:Object,default:function(){return{}}},controls:{type:Object,default:function(){return t}},minLength:{type:Number,default:1},maxSuggestions:{type:Number,default:10},displayAttribute:{type:String,default:"title"},valueAttribute:{type:String,default:"id"},list:{type:[Function,Array],default:function(){return[]}},removeList:{type:Boolean,default:!1},destyled:{type:Boolean,default:!1},filterByQuery:{type:Boolean,default:!1},filter:{type:Function,default:function(t,e){return!e||~this.displayProperty(t).toLowerCase().indexOf(e.toLowerCase())}},debounce:{type:Number,default:0},nullableSelect:{type:Boolean,default:!1},value:{},mode:{type:String,default:"input",validator:function(t){return!!~Object.keys(e).indexOf(t.toLowerCase())}},preventHide:{type:Boolean,default:!1}},watch:{mode:{handler:function(t){var e=this;this.constructor.options.model.event=t,this.$parent&&this.$parent.$forceUpdate(),this.$nextTick(function(){"input"===t?e.$emit("input",e.text):e.$emit("select",e.selected)})},immediate:!0},value:{handler:function(t){"string"!=typeof t&&(t=this.displayProperty(t)),this.updateTextOutside(t)},immediate:!0}},data:function(){return{selected:null,hovered:null,suggestions:[],listShown:!1,inputElement:null,canSend:!0,timeoutInstance:null,text:this.value,isPlainSuggestion:!1,isClicking:!1,isInFocus:!1,isFalseFocus:!1,isTabbed:!1,controlScheme:{},listId:this._uid+"-suggestions"}},computed:{listIsRequest:function(){return"function"==typeof this.list},inputIsComponent:function(){return this.$slots.default&&0<this.$slots.default.length&&!!this.$slots.default[0].componentInstance},input:function(){return this.inputIsComponent?this.$slots.default[0].componentInstance:this.inputElement},on:function(){return this.inputIsComponent?"$on":"addEventListener"},off:function(){return this.inputIsComponent?"$off":"removeEventListener"},hoveredIndex:function(){for(var t=0;t<this.suggestions.length;t++){var e=this.suggestions[t];if(this.hovered&&this.valueProperty(this.hovered)==this.valueProperty(e))return t}return-1},textLength:function(){return this.text&&this.text.length||this.inputElement.value.length||0},isSelectedUpToDate:function(){return!!this.selected&&this.displayProperty(this.selected)===this.text}},created:function(){this.controlScheme=Object.assign({},t,this.controls)},mounted:function(){try{var t=this;return o(t.$slots.default,function(){t.inputElement=t.$refs.inputSlot.querySelector("input"),t.inputElement?(t.setInputAriaAttributes(),t.prepareEventHandlers(!0)):console.error("No input element found")})}catch(t){return Promise.reject(t)}},beforeDestroy:function(){this.prepareEventHandlers(!1)},methods:{isEqual:function(t,e){return e&&this.valueProperty(t)==this.valueProperty(e)},isSelected:function(t){return this.isEqual(t,this.selected)},isHovered:function(t){return this.isEqual(t,this.hovered)},setInputAriaAttributes:function(){this.inputElement.setAttribute("aria-activedescendant",""),this.inputElement.setAttribute("aria-autocomplete","list"),this.inputElement.setAttribute("aria-controls",this.listId)},prepareEventHandlers:function(t){var e=this[t?"on":"off"],i={click:this.showSuggestions,keydown:this.onKeyDown,keyup:this.onListKeyUp},s=Object.assign({blur:this.onBlur,focus:this.onFocus,input:this.onInput},i);for(var n in s)this.input[e](n,s[n]);var o=t?"addEventListener":"removeEventListener";for(var r in i)this.inputElement[o](r,i[r])},isScopedSlotEmpty:function(t){if(t){var e=t(this);return!(Array.isArray(e)||e&&(e.tag||e.context||e.text||e.children))}return!0},miscSlotsAreEmpty:function(){var e=this,t=["misc-item-above","misc-item-below"].map(function(t){return e.$scopedSlots[t]});if(t.every(function(t){return!!t}))return t.every(this.isScopedSlotEmpty.bind(this));var i=t.find(function(t){return!!t});return this.isScopedSlotEmpty.call(this,i)},getPropertyByAttribute:function(t,e){return this.isPlainSuggestion?t:void 0!==(void 0===t?"undefined":n(t))?(i=t,e.split(".").reduce(function(t,e){return t===Object(t)?t[e]:t},i)):t;var i},displayProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.displayAttribute);return void 0===e&&(e=JSON.stringify(t),process&&~process.env.NODE_ENV.indexOf("dev")&&console.warn("[vue-simple-suggest]: Please, provide `display-attribute` as a key or a dotted path for a property from your object.")),String(e||"")},valueProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.valueAttribute);return void 0===e&&console.error("[vue-simple-suggest]: Please, check if you passed 'value-attribute' (default is 'id') and 'display-attribute' (default is 'title') props correctly.\n Your list objects should always contain a unique identifier."),e},autocompleteText:function(t){this.setText(this.displayProperty(t))},setText:function(t){var e=this;this.$nextTick(function(){e.inputElement.value=t,e.text=t,e.$emit("input",t)})},select:function(t){(this.selected!==t||this.nullableSelect&&!t)&&(this.selected=t,this.$emit("select",t),t&&this.autocompleteText(t)),this.hover(null)},hover:function(t,e){var i=t?this.getId(t,this.hoveredIndex):"";this.inputElement.setAttribute("aria-activedescendant",i),t&&t!==this.hovered&&this.$emit("hover",t,e),this.hovered=t},hideList:function(){this.listShown&&(this.listShown=!1,this.hover(null),this.$emit("hide-list"))},showList:function(){this.listShown||this.textLength>=this.minLength&&(0<this.suggestions.length||!this.miscSlotsAreEmpty())&&(this.listShown=!0,this.$emit("show-list"))},showSuggestions:function(){try{var t=this;return l(function(){if(0===t.suggestions.length&&t.minLength<=t.textLength)return t.showList(),function(t,e){if(!e)return t&&t.then?t.then(u):Promise.resolve()}(t.research())},function(){t.showList()})}catch(t){return Promise.reject(t)}},onShowList:function(t){r(this.controlScheme.showList,t)&&this.showSuggestions()},moveSelection:function(t){if(this.listShown&&this.suggestions.length&&r([this.controlScheme.selectionUp,this.controlScheme.selectionDown],t)){t.preventDefault();var e=r(this.controlScheme.selectionDown,t),i=2*e-1,s=e?0:this.suggestions.length-1,n=e?this.hoveredIndex<this.suggestions.length-1:0<this.hoveredIndex,o=null;o=this.hovered?n?this.suggestions[this.hoveredIndex+i]:this.suggestions[s]:this.selected||this.suggestions[s],this.hover(o)}},onKeyDown:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;"Enter"===t.key&&this.listShown&&s([e,i],13)&&t.preventDefault(),"Tab"===t.key&&this.hovered&&this.select(this.hovered),this.onShowList(t),this.moveSelection(t),this.onAutocomplete(t)},onListKeyUp:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;this.listShown&&r([e,i],t)&&(t.preventDefault(),r(e,t)&&this.select(this.hovered),this.hideList())},onAutocomplete:function(t){r(this.controlScheme.autocomplete,t)&&(t.ctrlKey||t.shiftKey)&&0<this.suggestions.length&&this.suggestions[0]&&this.listShown&&(t.preventDefault(),this.hover(this.suggestions[0]),this.autocompleteText(this.suggestions[0]))},suggestionClick:function(t,e){this.$emit("suggestion-click",t,e),this.select(t),this.preventHide||this.hideList(),this.isClicking=!1},onBlur:function(t){var e=this;this.isInFocus?(this.isClicking=this.hovered&&!this.isTabbed,this.isClicking?t&&t.isTrusted&&!this.isTabbed&&(this.isFalseFocus=!0,setTimeout(function(){e.inputElement.focus()},0)):(this.isInFocus=!1,this.hideList(),this.$emit("blur",t))):(this.inputElement.blur(),console.error("This should never happen!\n If you encountered this error, please make sure that your input component emits 'focus' events properly.\n For more info see https://github.com/KazanExpress/vue-simple-suggest#custom-input.\n\n If your 'vue-simple-suggest' setup does not include a custom input component - please,\n report to https://github.com/KazanExpress/vue-simple-suggest/issues/new")),this.isTabbed=!1},onFocus:function(t){this.isInFocus=!0,t&&!this.isFalseFocus&&this.$emit("focus",t),this.isClicking||this.isFalseFocus||this.showSuggestions(),this.isFalseFocus=!1},onInput:function(t){var e=t.target?t.target.value:t;this.updateTextOutside(e),this.$emit("input",e)},updateTextOutside:function(t){this.text!==t&&(this.text=t,this.hovered&&this.hover(null),this.text.length<this.minLength?this.hideList():this.debounce?(clearTimeout(this.timeoutInstance),this.timeoutInstance=setTimeout(this.research,this.debounce)):this.research())},research:function(){try{var i=this;return c(function(){return h(function(){return function(t){var e=t();if(e&&e.then)return e.then(u)}(function(){if(i.canSend){i.canSend=!1;var e=i.text;return o(i.getSuggestions(i.text),function(t){e===i.text&&i.$set(i,"suggestions",t)})}})},function(t){throw i.clearSuggestions(),t})},function(){return i.canSend=!0,0===i.suggestions.length&&i.miscSlotsAreEmpty()?i.hideList():i.isInFocus&&i.showList(),i.suggestions})}catch(t){return Promise.reject(t)}},getSuggestions:function(e){try{var i=this;if((e=e||"").length<i.minLength)return[];i.selected=null,i.listIsRequest&&i.$emit("request-start",e);var t=!1,s=[];return c(function(){return h(function(){return l(function(){if(i.listIsRequest)return o(i.list(e),function(t){s=t||[]});s=i.list},function(){Array.isArray(s)||(s=[s]),t="object"!==n(s[0])&&void 0!==s[0]||Array.isArray(s[0]),i.filterByQuery&&(s=s.filter(function(t){return i.filter(t,e)})),i.listIsRequest&&i.$emit("request-done",s)})},function(t){if(!i.listIsRequest)throw t;i.$emit("request-failed",t)})},function(){return i.maxSuggestions&&s.splice(i.maxSuggestions),i.isPlainSuggestion=t,s})}catch(t){return Promise.reject(t)}},clearSuggestions:function(){this.suggestions.splice(0)},getId:function(t,e){return this.listId+"-suggestion-"+(this.isPlainSuggestion?e:this.valueProperty(t)||e)}}};return(Vue||window&&window.Vue)&&(Vue||window.Vue).component("vue-simple-suggest",i),i});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).VueSimpleSuggest=e()}(this,function(){"use strict";var t={selectionUp:[38],selectionDown:[40],select:[13],hideList:[27],showList:[40],autocomplete:[32,13]},e={input:String,select:Object};function r(t,e){return s(t,e.keyCode)}function s(t,e){if(t.length<=0)return!1;function i(t){return t.some(function(t){return t===e})}return Array.isArray(t[0])?t.some(function(t){return i(t)}):i(t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function o(t,e,i){return i?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function u(){}function l(t,e){var i=t();return i&&i.then?i.then(e):e(i)}function c(t,e){try{var i=t()}catch(t){return e(t)}return i&&i.then?i.then(void 0,e):i}function h(t,e){try{var i=t()}catch(t){return e()}return i&&i.then?i.then(e,e):e()}var i={render:function(){var i=this,t=i.$createElement,s=i._self._c||t;return s("div",{staticClass:"vue-simple-suggest",class:[i.styles.vueSimpleSuggest,{designed:!i.destyled,focus:i.isInFocus}],on:{keydown:function(t){if(!t.type.indexOf("key")&&i._k(t.keyCode,"tab",9,t.key,"Tab"))return null;i.isTabbed=!0}}},[s("div",{ref:"inputSlot",staticClass:"input-wrapper",class:i.styles.inputWrapper,attrs:{role:"combobox","aria-haspopup":"listbox","aria-owns":i.listId,"aria-expanded":i.listShown&&!i.removeList?"true":"false"}},[i._t("default",[s("input",i._b({staticClass:"default-input",class:i.styles.defaultInput,domProps:{value:i.text||""}},"input",i.$attrs,!1))])],2),i._v(" "),s("transition",{attrs:{name:"vue-simple-suggest"}},[i.listShown&&!i.removeList?s("ul",{staticClass:"suggestions",class:i.styles.suggestions,attrs:{id:i.listId,role:"listbox","aria-labelledby":i.listId}},[this.$scopedSlots["misc-item-above"]?s("li",[i._t("misc-item-above",null,{suggestions:i.suggestions,query:i.text})],2):i._e(),i._v(" "),i._l(i.suggestions,function(e,t){return s("li",{key:i.getId(e,t),staticClass:"suggest-item",class:[i.styles.suggestItem,{selected:i.isSelected(e),hover:i.isHovered(e)}],attrs:{role:"option","aria-selected":i.isHovered(e)||i.isSelected(e)?"true":"false",id:i.getId(e,t)},on:{mouseenter:function(t){return i.hover(e,t.target)},mouseleave:function(){return i.hover(void 0)},click:function(t){return i.suggestionClick(e,t)}}},[i._t("suggestion-item",[s("span",[i._v(i._s(i.displayProperty(e)))])],{autocomplete:function(){return i.autocompleteText(e)},suggestion:e,query:i.text})],2)}),i._v(" "),this.$scopedSlots["misc-item-below"]?s("li",[i._t("misc-item-below",null,{suggestions:i.suggestions,query:i.text})],2):i._e()],2):i._e()])],1)},staticRenderFns:[],name:"vue-simple-suggest",inheritAttrs:!1,model:{prop:"value",event:"input"},props:{styles:{type:Object,default:function(){return{}}},controls:{type:Object,default:function(){return t}},minLength:{type:Number,default:1},maxSuggestions:{type:Number,default:10},displayAttribute:{type:String,default:"title"},valueAttribute:{type:String,default:"id"},list:{type:[Function,Array],default:function(){return[]}},removeList:{type:Boolean,default:!1},destyled:{type:Boolean,default:!1},filterByQuery:{type:Boolean,default:!1},filter:{type:Function,default:function(t,e){return!e||~this.displayProperty(t).toLowerCase().indexOf(e.toLowerCase())}},debounce:{type:Number,default:0},nullableSelect:{type:Boolean,default:!1},value:{},mode:{type:String,default:"input",validator:function(t){return!!~Object.keys(e).indexOf(t.toLowerCase())}},preventHide:{type:Boolean,default:!1}},watch:{mode:{handler:function(t){var e=this;this.constructor.options.model.event=t,this.$parent&&this.$parent.$forceUpdate(),this.$nextTick(function(){"input"===t?e.$emit("input",e.text):e.$emit("select",e.selected)})},immediate:!0},value:{handler:function(t){"string"!=typeof t&&(t=this.displayProperty(t)),this.updateTextOutside(t)},immediate:!0}},data:function(){return{selected:null,hovered:null,suggestions:[],listShown:!1,inputElement:null,canSend:!0,timeoutInstance:null,text:this.value,isPlainSuggestion:!1,isClicking:!1,isInFocus:!1,isFalseFocus:!1,isTabbed:!1,controlScheme:{},listId:this._uid+"-suggestions"}},computed:{listIsRequest:function(){return"function"==typeof this.list},inputIsComponent:function(){return this.$slots.default&&0<this.$slots.default.length&&!!this.$slots.default[0].componentInstance},input:function(){return this.inputIsComponent?this.$slots.default[0].componentInstance:this.inputElement},on:function(){return this.inputIsComponent?"$on":"addEventListener"},off:function(){return this.inputIsComponent?"$off":"removeEventListener"},hoveredIndex:function(){for(var t=0;t<this.suggestions.length;t++){var e=this.suggestions[t];if(this.hovered&&this.valueProperty(this.hovered)==this.valueProperty(e))return t}return-1},textLength:function(){return this.text&&this.text.length||this.inputElement.value.length||0},isSelectedUpToDate:function(){return!!this.selected&&this.displayProperty(this.selected)===this.text}},created:function(){this.controlScheme=Object.assign({},t,this.controls)},mounted:function(){try{var t=this;return o(t.$slots.default,function(){t.$nextTick(function(){t.inputElement=t.$refs.inputSlot.querySelector("input"),t.inputElement?(t.setInputAriaAttributes(),t.prepareEventHandlers(!0)):console.error("No input element found")})})}catch(t){return Promise.reject(t)}},beforeDestroy:function(){this.prepareEventHandlers(!1)},methods:{isEqual:function(t,e){return e&&this.valueProperty(t)==this.valueProperty(e)},isSelected:function(t){return this.isEqual(t,this.selected)},isHovered:function(t){return this.isEqual(t,this.hovered)},setInputAriaAttributes:function(){this.inputElement.setAttribute("aria-activedescendant",""),this.inputElement.setAttribute("aria-autocomplete","list"),this.inputElement.setAttribute("aria-controls",this.listId)},prepareEventHandlers:function(t){var e=this[t?"on":"off"],i={click:this.showSuggestions,keydown:this.onKeyDown,keyup:this.onListKeyUp},s=Object.assign({blur:this.onBlur,focus:this.onFocus,input:this.onInput},i);for(var n in s)this.input[e](n,s[n]);var o=t?"addEventListener":"removeEventListener";for(var r in i)this.inputElement[o](r,i[r])},isScopedSlotEmpty:function(t){if(t){var e=t(this);return!(Array.isArray(e)||e&&(e.tag||e.context||e.text||e.children))}return!0},miscSlotsAreEmpty:function(){var e=this,t=["misc-item-above","misc-item-below"].map(function(t){return e.$scopedSlots[t]});if(t.every(function(t){return!!t}))return t.every(this.isScopedSlotEmpty.bind(this));var i=t.find(function(t){return!!t});return this.isScopedSlotEmpty.call(this,i)},getPropertyByAttribute:function(t,e){return this.isPlainSuggestion?t:void 0!==(void 0===t?"undefined":n(t))?(i=t,e.split(".").reduce(function(t,e){return t===Object(t)?t[e]:t},i)):t;var i},displayProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.displayAttribute);return void 0===e&&(e=JSON.stringify(t),process&&~process.env.NODE_ENV.indexOf("dev")&&console.warn("[vue-simple-suggest]: Please, provide `display-attribute` as a key or a dotted path for a property from your object.")),String(e||"")},valueProperty:function(t){if(this.isPlainSuggestion)return t;var e=this.getPropertyByAttribute(t,this.valueAttribute);return void 0===e&&console.error("[vue-simple-suggest]: Please, check if you passed 'value-attribute' (default is 'id') and 'display-attribute' (default is 'title') props correctly.\n Your list objects should always contain a unique identifier."),e},autocompleteText:function(t){this.setText(this.displayProperty(t))},setText:function(t){var e=this;this.$nextTick(function(){e.inputElement.value=t,e.text=t,e.$emit("input",t)})},select:function(t){(this.selected!==t||this.nullableSelect&&!t)&&(this.selected=t,this.$emit("select",t),t&&this.autocompleteText(t)),this.hover(null)},hover:function(t,e){var i=t?this.getId(t,this.hoveredIndex):"";this.inputElement.setAttribute("aria-activedescendant",i),t&&t!==this.hovered&&this.$emit("hover",t,e),this.hovered=t},hideList:function(){this.listShown&&(this.listShown=!1,this.hover(null),this.$emit("hide-list"))},showList:function(){this.listShown||this.textLength>=this.minLength&&(0<this.suggestions.length||!this.miscSlotsAreEmpty())&&(this.listShown=!0,this.$emit("show-list"))},showSuggestions:function(){try{var t=this;return l(function(){if(0===t.suggestions.length&&t.minLength<=t.textLength)return t.showList(),function(t,e){if(!e)return t&&t.then?t.then(u):Promise.resolve()}(t.research())},function(){t.showList()})}catch(t){return Promise.reject(t)}},onShowList:function(t){r(this.controlScheme.showList,t)&&this.showSuggestions()},moveSelection:function(t){if(this.listShown&&this.suggestions.length&&r([this.controlScheme.selectionUp,this.controlScheme.selectionDown],t)){t.preventDefault();var e=r(this.controlScheme.selectionDown,t),i=2*e-1,s=e?0:this.suggestions.length-1,n=e?this.hoveredIndex<this.suggestions.length-1:0<this.hoveredIndex,o=null;o=this.hovered?n?this.suggestions[this.hoveredIndex+i]:this.suggestions[s]:this.selected||this.suggestions[s],this.hover(o)}},onKeyDown:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;"Enter"===t.key&&this.listShown&&s([e,i],13)&&t.preventDefault(),"Tab"===t.key&&this.hovered&&this.select(this.hovered),this.onShowList(t),this.moveSelection(t),this.onAutocomplete(t)},onListKeyUp:function(t){var e=this.controlScheme.select,i=this.controlScheme.hideList;this.listShown&&r([e,i],t)&&(t.preventDefault(),r(e,t)&&this.select(this.hovered),this.hideList())},onAutocomplete:function(t){r(this.controlScheme.autocomplete,t)&&(t.ctrlKey||t.shiftKey)&&0<this.suggestions.length&&this.suggestions[0]&&this.listShown&&(t.preventDefault(),this.hover(this.suggestions[0]),this.autocompleteText(this.suggestions[0]))},suggestionClick:function(t,e){var i=this;this.$emit("suggestion-click",t,e),this.select(t),this.preventHide||this.hideList(),this.isClicking&&setTimeout(function(){i.inputElement.focus(),i.isClicking=!1},0)},onBlur:function(t){this.isInFocus?(this.isClicking=this.hovered&&!this.isTabbed,this.isClicking?t&&t.isTrusted&&!this.isTabbed&&(this.isFalseFocus=!0):(this.isInFocus=!1,this.hideList(),this.$emit("blur",t))):(this.inputElement.blur(),console.error("This should never happen!\n If you encountered this error, please make sure that your input component emits 'focus' events properly.\n For more info see https://github.com/KazanExpress/vue-simple-suggest#custom-input.\n\n If your 'vue-simple-suggest' setup does not include a custom input component - please,\n report to https://github.com/KazanExpress/vue-simple-suggest/issues/new")),this.isTabbed=!1},onFocus:function(t){this.isInFocus=!0,t&&!this.isFalseFocus&&this.$emit("focus",t),this.isClicking||this.isFalseFocus||this.showSuggestions(),this.isFalseFocus=!1},onInput:function(t){var e=t.target?t.target.value:t;this.updateTextOutside(e),this.$emit("input",e)},updateTextOutside:function(t){this.text!==t&&(this.text=t,this.hovered&&this.hover(null),this.text.length<this.minLength?this.hideList():this.debounce?(clearTimeout(this.timeoutInstance),this.timeoutInstance=setTimeout(this.research,this.debounce)):this.research())},research:function(){try{var i=this;return h(function(){return c(function(){return function(t){var e=t();if(e&&e.then)return e.then(u)}(function(){if(i.canSend){i.canSend=!1;var e=i.text;return o(i.getSuggestions(i.text),function(t){e===i.text&&i.$set(i,"suggestions",t)})}})},function(t){throw i.clearSuggestions(),t})},function(){return i.canSend=!0,0===i.suggestions.length&&i.miscSlotsAreEmpty()?i.hideList():i.isInFocus&&i.showList(),i.suggestions})}catch(t){return Promise.reject(t)}},getSuggestions:function(e){try{var i=this;if((e=e||"").length<i.minLength)return[];i.selected=null,i.listIsRequest&&i.$emit("request-start",e);var t=!1,s=[];return h(function(){return c(function(){return l(function(){if(i.listIsRequest)return o(i.list(e),function(t){s=t||[]});s=i.list},function(){Array.isArray(s)||(s=[s]),t="object"!==n(s[0])&&void 0!==s[0]||Array.isArray(s[0]),i.filterByQuery&&(s=s.filter(function(t){return i.filter(t,e)})),i.listIsRequest&&i.$emit("request-done",s)})},function(t){if(!i.listIsRequest)throw t;i.$emit("request-failed",t)})},function(){return i.maxSuggestions&&s.splice(i.maxSuggestions),i.isPlainSuggestion=t,s})}catch(t){return Promise.reject(t)}},clearSuggestions:function(){this.suggestions.splice(0)},getId:function(t,e){return this.listId+"-suggestion-"+(this.isPlainSuggestion?e:this.valueProperty(t)||e)}}};return(Vue||window&&window.Vue)&&(Vue||window.Vue).component("vue-simple-suggest",i),i});
{
"name": "vue-simple-suggest",
"description": "Feature-rich autocomplete component for Vue.js",
"version": "1.11.0",
"version": "1.11.1",
"author": "KazanExpress",

@@ -6,0 +6,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc