├── .babelrc ├── .gitignore ├── CHANGELOG.md ├── README.md ├── dist ├── vue-simple-search-dropdown.js └── vue-simple-search-dropdown.min.js ├── docs └── index.html ├── package.json ├── src ├── Dropdown.vue └── plugin.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-2"], 3 | "plugins": ["transform-runtime"], 4 | "comments": false 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## :scroll: Changelog 2 | 3 | ### :passenger_ship: 1.0.1 4 | - `Fix` Dropdown was was not showing after hitting tab 5 | - `New` Scrolling over options, max number of items, and name 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-simple-search-dropdown 2 | 3 | A Vue component for a simple searchable dropdown. 4 | 5 | No external library is used in this dropdown. 6 | 7 | ### Demo 8 | 9 | Demo here: [https://romainsimon.github.io/vue-simple-search-dropdown/](https://romainsimon.github.io/vue-simple-search-dropdown/) 10 | 11 | ## Installation 12 | 13 | ```js 14 | npm install vue-simple-search-dropdown 15 | ``` 16 | 17 | ### Browser 18 | 19 | Include the script file, then install the component with `Vue.use(Dropdown);` e.g.: 20 | 21 | ```html 22 | 23 | 24 | 27 | ``` 28 | 29 | ### Module 30 | 31 | ```js 32 | import Dropdown from 'vue-simple-search-dropdown'; 33 | ``` 34 | 35 | ## Usage 36 | 37 | Once installed, it can be used in a template as simply as: 38 | 39 | ```html 40 | 48 | 49 | ``` 50 | 51 | ### Options 52 | 53 | - `options` (required): An array of options with `id` and `name` 54 | - `placeholder` (optional): A placeholder 55 | - `disabled` (optional): true/false 56 | - `name` (optional): An input name | default: `dropdown` 57 | - `maxItem` (optional): Max item to show | default: `6` 58 | 59 | ### Events 60 | 61 | These events are returned from the dropdown and can be catch with `v-on` 62 | - `selected`: An option is selected by click in the dropdown 63 | - `filter`: A filter has been applied by typing in the input field 64 | 65 | Tips: Using `v-on:filter`, you can repopulate the dropdown with new `options` corresponding to the search by making an API call 66 | -------------------------------------------------------------------------------- /dist/vue-simple-search-dropdown.js: -------------------------------------------------------------------------------- 1 | (function t(e,r){if(typeof exports==="object"&&typeof module==="object")module.exports=r();else if(typeof define==="function"&&define.amd)define("vue-simple-search-dropdown",[],r);else if(typeof exports==="object")exports["vue-simple-search-dropdown"]=r();else e["vue-simple-search-dropdown"]=r()})(window,function(){return function(t){var e={};function r(n){if(e[n]){return e[n].exports}var o=e[n]={i:n,l:false,exports:{}};t[n].call(o.exports,o,o.exports,r);o.l=true;return o.exports}r.m=t;r.c=e;r.d=function(t,e,n){if(!r.o(t,e)){Object.defineProperty(t,e,{enumerable:true,get:n})}};r.r=function(t){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})};r.t=function(t,e){if(e&1)t=r(t);if(e&8)return t;if(e&4&&typeof t==="object"&&t&&t.__esModule)return t;var n=Object.create(null);r.r(n);Object.defineProperty(n,"default",{enumerable:true,value:t});if(e&2&&typeof t!="string")for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n};r.n=function(t){var e=t&&t.__esModule?function e(){return t["default"]}:function e(){return t};r.d(e,"a",e);return e};r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};r.p="";return r(r.s=62)}([function(t,e,r){var n=r(21)("wks");var o=r(20);var i=r(1).Symbol;var a=typeof i=="function";var u=t.exports=function(t){return n[t]||(n[t]=a&&i[t]||(a?i:o)("Symbol."+t))};u.store=n},function(t,e){var r=t.exports=typeof window!="undefined"&&window.Math==Math?window:typeof self!="undefined"&&self.Math==Math?self:Function("return this")();if(typeof __g=="number")__g=r},function(t,e,r){var n=r(14);var o=r(22);t.exports=r(4)?function(t,e,r){return n.f(t,e,o(1,r))}:function(t,e,r){t[e]=r;return t}},function(t,e){var r={}.hasOwnProperty;t.exports=function(t,e){return r.call(t,e)}},function(t,e,r){t.exports=!r(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(t,e,r){var n=r(13);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e){var r=t.exports={version:"2.5.7"};if(typeof __e=="number")__e=r},function(t,e){t.exports={}},function(t,e,r){var n=r(31);if(typeof n==="string")n=[[t.i,n,""]];if(n.locals)t.exports=n.locals;var o=r(29).default;var i=o("0bcda724",n,false,{});if(false){}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:true});var n=r(61);var o=i(n);function i(t){return t&&t.__esModule?t:{default:t}}e.default={name:"Dropdown",template:"Dropdown",props:{options:{type:Array,required:true,default:[],note:"Options of dropdown. An array of options with id and name"},placeholder:{type:String,required:false,default:"Please select an option",note:"Placeholder of dropdown"},disabled:{type:Boolean,required:false,default:false,note:"Disable the dropdown"}},data:function t(){return{selected:{},optionsShown:false,searchFilter:""}},created:function t(){this.$emit("selected",this.selected)},computed:{filteredOptions:function t(){var e=[];var r=new RegExp(this.searchFilter,"ig");var n=true;var i=false;var a=undefined;try{for(var u=(0,o.default)(this.options),s;!(n=(s=u.next()).done);n=true){var f=s.value;if(this.searchFilter.length<1||f.name.match(r)){if(e.length<6)e.push(f)}}}catch(t){i=true;a=t}finally{try{if(!n&&u.return){u.return()}}finally{if(i){throw a}}}return e}},methods:{selectOption:function t(e){this.selected=e;this.optionsShown=false;this.searchFilter=this.selected.name;this.$emit("selected",this.selected)},showOptions:function t(){if(!this.disabled){this.searchFilter="";this.optionsShown=true}},exit:function t(){if(!this.selected.id){this.selected={};this.searchFilter=""}else{this.searchFilter=this.selected.name}this.$emit("selected",this.selected);this.optionsShown=false},keyMonitor:function t(e){if(e.key==="Enter"&&this.filteredOptions[0])this.selectOption(this.filteredOptions[0])}},watch:{searchFilter:function t(){if(this.filteredOptions.length===0){this.selected={}}else{this.selected=this.filteredOptions[0]}this.$emit("filter",this.searchFilter)}}}},function(t,e,r){"use strict";r.r(e);var n=r(9);var o=r.n(n);for(var i in n)if(i!=="default")(function(t){r.d(e,t,function(){return n[t]})})(i);e["default"]=o.a},function(t,e,r){var n=r(21)("keys");var o=r(20);t.exports=function(t){return n[t]||(n[t]=o(t))}},function(t,e){var r=Math.ceil;var n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:r)(t)}},function(t,e){t.exports=function(t){return typeof t==="object"?t!==null:typeof t==="function"}},function(t,e,r){var n=r(5);var o=r(51);var i=r(50);var a=Object.defineProperty;e.f=r(4)?Object.defineProperty:function t(e,r,u){n(e);r=i(r,true);n(u);if(o)try{return a(e,r,u)}catch(t){}if("get"in u||"set"in u)throw TypeError("Accessors not supported!");if("value"in u)e[r]=u.value;return e}},function(t,e){t.exports=function(t){if(t==undefined)throw TypeError("Can't call method on "+t);return t}},function(t,e,r){var n=r(55);var o=r(15);t.exports=function(t){return n(o(t))}},function(t,e,r){"use strict";var n=function(){var t=this;var e=t.$createElement;var r=t._self._c||e;return t.options?r("div",{staticClass:"dropdown"},[r("input",{directives:[{name:"model",rawName:"v-model",value:t.searchFilter,expression:"searchFilter"}],staticClass:"dropdown-input",attrs:{disabled:t.disabled,placeholder:t.placeholder},domProps:{value:t.searchFilter},on:{click:function(e){t.showOptions()},blur:function(e){t.exit()},keyup:t.keyMonitor,input:function(e){if(e.target.composing){return}t.searchFilter=e.target.value}}}),t._v(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:t.optionsShown,expression:"optionsShown"}],staticClass:"dropdown-content"},t._l(t.filteredOptions,function(e){return r("div",{staticClass:"dropdown-item",on:{mousedown:function(r){t.selectOption(e)}}},[t._v("\n "+t._s(e.name||e.id||"-")+"\n ")])}))]):t._e()};var o=[];n._withStripped=true;r.d(e,"a",function(){return n});r.d(e,"b",function(){return o})},function(t,e,r){var n=r(14).f;var o=r(3);var i=r(0)("toStringTag");t.exports=function(t,e,r){if(t&&!o(t=r?t:t.prototype,i))n(t,i,{configurable:true,value:e})}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e){var r=0;var n=Math.random();t.exports=function(t){return"Symbol(".concat(t===undefined?"":t,")_",(++r+n).toString(36))}},function(t,e,r){var n=r(6);var o=r(1);var i="__core-js_shared__";var a=o[i]||(o[i]={});(t.exports=function(t,e){return a[t]||(a[t]=e!==undefined?e:{})})("versions",[]).push({version:n.version,mode:r(25)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,e){t.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}},function(t,e,r){var n=r(13);var o=r(1).document;var i=n(o)&&n(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return true}}},function(t,e){t.exports=true},function(t,e,r){"use strict";var n=r(25);var o=r(54);var i=r(49);var a=r(2);var u=r(7);var s=r(48);var f=r(18);var c=r(39);var l=r(0)("iterator");var v=!([].keys&&"next"in[].keys());var d="@@iterator";var p="keys";var h="values";var y=function(){return this};t.exports=function(t,e,r,m,g,x,b){s(r,e,m);var w=function(t){if(!v&&t in j)return j[t];switch(t){case p:return function e(){return new r(this,t)};case h:return function e(){return new r(this,t)}}return function e(){return new r(this,t)}};var _=e+" Iterator";var S=g==h;var O=false;var j=t.prototype;var C=j[l]||j[d]||g&&j[g];var M=C||w(g);var T=g?!S?M:w("entries"):undefined;var L=e=="Array"?j.entries||C:C;var k,P,E;if(L){E=c(L.call(new t));if(E!==Object.prototype&&E.next){f(E,_,true);if(!n&&typeof E[l]!="function")a(E,l,y)}}if(S&&C&&C.name!==h){O=true;M=function t(){return C.call(this)}}if((!n||b)&&(v||O||!j[l])){a(j,l,M)}u[e]=M;u[_]=y;if(g){k={values:S?M:w(h),keys:x?M:w(p),entries:T};if(b)for(P in k){if(!(P in j))i(j,P,k[P])}else o(o.P+o.F*(v||O),e,k)}return k}},function(t,e){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,e,r){"use strict";r.d(e,"a",function(){return n});function n(t,e,r,n,o,i,a,u){var s=typeof t==="function"?t.options:t;if(e){s.render=e;s.staticRenderFns=r;s._compiled=true}if(n){s.functional=true}if(i){s._scopeId="data-v-"+i}var f;if(a){f=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext;if(!t&&typeof __VUE_SSR_CONTEXT__!=="undefined"){t=__VUE_SSR_CONTEXT__}if(o){o.call(this,t)}if(t&&t._registeredComponents){t._registeredComponents.add(a)}};s._ssrRegister=f}else if(o){f=u?function(){o.call(this,this.$root.$options.shadowRoot)}:o}if(f){if(s.functional){s._injectStyles=f;var c=s.render;s.render=function t(e,r){f.call(r);return c(e,r)}}else{var l=s.beforeCreate;s.beforeCreate=l?[].concat(l,f):[f]}}return{exports:t,options:s}}},function(t,e,r){"use strict";r.r(e);function n(t,e){var r=[];var n={};for(var o=0;or.parts.length){n.parts.length=r.parts.length}}else{var a=[];for(var o=0;o=u)return t?"":undefined;s=i.charCodeAt(a);return s<55296||s>56319||a+1===u||(f=i.charCodeAt(a+1))<56320||f>57343?t?i.charAt(a):s:t?i.slice(a,a+2):(s-55296<<10)+(f-56320)+65536}}},function(t,e,r){"use strict";var n=r(36)(true);r(26)(String,"String",function(t){this._t=String(t);this._i=0},function(){var t=this._t;var e=this._i;var r;if(e>=t.length)return{value:undefined,done:true};r=n(t,e);this._i+=r.length;return{value:r,done:false}})},function(t,e,r){var n=r(15);t.exports=function(t){return Object(n(t))}},function(t,e,r){var n=r(3);var o=r(38);var i=r(11)("IE_PROTO");var a=Object.prototype;t.exports=Object.getPrototypeOf||function(t){t=o(t);if(n(t,i))return t[i];if(typeof t.constructor=="function"&&t instanceof t.constructor){return t.constructor.prototype}return t instanceof Object?a:null}},function(t,e,r){var n=r(1).document;t.exports=n&&n.documentElement},function(t,e,r){var n=r(12);var o=Math.max;var i=Math.min;t.exports=function(t,e){t=n(t);return t<0?o(t+e,0):i(t,e)}},function(t,e,r){var n=r(12);var o=Math.min;t.exports=function(t){return t>0?o(n(t),9007199254740991):0}},function(t,e,r){var n=r(16);var o=r(42);var i=r(41);t.exports=function(t){return function(e,r,a){var u=n(e);var s=o(u.length);var f=i(a,s);var c;if(t&&r!=r)while(s>f){c=u[f++];if(c!=c)return true}else for(;s>f;f++)if(t||f in u){if(u[f]===r)return t||f||0}return!t&&-1}}},function(t,e,r){var n=r(3);var o=r(16);var i=r(43)(false);var a=r(11)("IE_PROTO");t.exports=function(t,e){var r=o(t);var u=0;var s=[];var f;for(f in r)if(f!=a)n(r,f)&&s.push(f);while(e.length>u)if(n(r,f=e[u++])){~i(s,f)||s.push(f)}return s}},function(t,e,r){var n=r(44);var o=r(19);t.exports=Object.keys||function t(e){return n(e,o)}},function(t,e,r){var n=r(14);var o=r(5);var i=r(45);t.exports=r(4)?Object.defineProperties:function t(e,r){o(e);var a=i(r);var u=a.length;var s=0;var f;while(u>s)n.f(e,f=a[s++],r[f]);return e}},function(t,e,r){var n=r(5);var o=r(46);var i=r(19);var a=r(11)("IE_PROTO");var u=function(){};var s="prototype";var f=function(){var t=r(23)("iframe");var e=i.length;var n="<";var o=">";var a;t.style.display="none";r(40).appendChild(t);t.src="javascript:";a=t.contentWindow.document;a.open();a.write(n+"script"+o+"document.F=Object"+n+"/script"+o);a.close();f=a.F;while(e--)delete f[s][i[e]];return f()};t.exports=Object.create||function t(e,r){var i;if(e!==null){u[s]=n(e);i=new u;u[s]=null;i[a]=e}else i=f();return r===undefined?i:o(i,r)}},function(t,e,r){"use strict";var n=r(47);var o=r(22);var i=r(18);var a={};r(2)(a,r(0)("iterator"),function(){return this});t.exports=function(t,e,r){t.prototype=n(a,{next:o(1,r)});i(t,e+" Iterator")}},function(t,e,r){t.exports=r(2)},function(t,e,r){var n=r(13);t.exports=function(t,e){if(!n(t))return t;var r,o;if(e&&typeof(r=t.toString)=="function"&&!n(o=r.call(t)))return o;if(typeof(r=t.valueOf)=="function"&&!n(o=r.call(t)))return o;if(!e&&typeof(r=t.toString)=="function"&&!n(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e,r){t.exports=!r(4)&&!r(24)(function(){return Object.defineProperty(r(23)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,e){t.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(t,e,r){var n=r(52);t.exports=function(t,e,r){n(t);if(e===undefined)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},function(t,e,r){var n=r(1);var o=r(6);var i=r(53);var a=r(2);var u=r(3);var s="prototype";var f=function(t,e,r){var c=t&f.F;var l=t&f.G;var v=t&f.S;var d=t&f.P;var p=t&f.B;var h=t&f.W;var y=l?o:o[e]||(o[e]={});var m=y[s];var g=l?n:v?n[e]:(n[e]||{})[s];var x,b,w;if(l)r=e;for(x in r){b=!c&&g&&g[x]!==undefined;if(b&&u(y,x))continue;w=b?g[x]:r[x];y[x]=l&&typeof g[x]!="function"?r[x]:p&&b?i(w,n):h&&g[x]==w?function(t){var e=function(e,r,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,r)}return new t(e,r,n)}return t.apply(this,arguments)};e[s]=t[s];return e}(w):d&&typeof w=="function"?i(Function.call,w):w;if(d){(y.virtual||(y.virtual={}))[x]=w;if(t&f.R&&m&&!m[x])a(m,x,w)}}};f.F=1;f.G=2;f.S=4;f.P=8;f.B=16;f.W=32;f.U=64;f.R=128;t.exports=f},function(t,e,r){var n=r(27);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return n(t)=="String"?t.split(""):Object(t)}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e){t.exports=function(){}},function(t,e,r){"use strict";var n=r(57);var o=r(56);var i=r(7);var a=r(16);t.exports=r(26)(Array,"Array",function(t,e){this._t=a(t);this._i=0;this._k=e},function(){var t=this._t;var e=this._k;var r=this._i++;if(!t||r>=t.length){this._t=undefined;return o(1)}if(e=="keys")return o(0,r);if(e=="values")return o(0,t[r]);return o(0,[r,t[r]])},"values");i.Arguments=i.Array;n("keys");n("values");n("entries")},function(t,e,r){r(58);var n=r(1);var o=r(2);var i=r(7);var a=r(0)("toStringTag");var u=("CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,"+"DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,"+"MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,"+"SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,"+"TextTrackList,TouchList").split(",");for(var s=0;s0?n:r)(t)}},function(t,e){t.exports=function(t){return typeof t==="object"?t!==null:typeof t==="function"}},function(t,e,r){var n=r(5);var o=r(51);var i=r(50);var a=Object.defineProperty;e.f=r(4)?Object.defineProperty:function t(e,r,u){n(e);r=i(r,true);n(u);if(o)try{return a(e,r,u)}catch(t){}if("get"in u||"set"in u)throw TypeError("Accessors not supported!");if("value"in u)e[r]=u.value;return e}},function(t,e){t.exports=function(t){if(t==undefined)throw TypeError("Can't call method on "+t);return t}},function(t,e,r){var n=r(55);var o=r(15);t.exports=function(t){return n(o(t))}},function(t,e,r){"use strict";var n=function(){var t=this;var e=t.$createElement;var r=t._self._c||e;return t.options?r("div",{staticClass:"dropdown"},[r("input",{directives:[{name:"model",rawName:"v-model",value:t.searchFilter,expression:"searchFilter"}],staticClass:"dropdown-input",attrs:{disabled:t.disabled,placeholder:t.placeholder},domProps:{value:t.searchFilter},on:{click:function(e){t.showOptions()},blur:function(e){t.exit()},keyup:t.keyMonitor,input:function(e){if(e.target.composing){return}t.searchFilter=e.target.value}}}),t._v(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:t.optionsShown,expression:"optionsShown"}],staticClass:"dropdown-content"},t._l(t.filteredOptions,function(e){return r("div",{staticClass:"dropdown-item",on:{mousedown:function(r){t.selectOption(e)}}},[t._v("\n "+t._s(e.name||e.id||"-")+"\n ")])}))]):t._e()};var o=[];n._withStripped=true;r.d(e,"a",function(){return n});r.d(e,"b",function(){return o})},function(t,e,r){var n=r(14).f;var o=r(3);var i=r(0)("toStringTag");t.exports=function(t,e,r){if(t&&!o(t=r?t:t.prototype,i))n(t,i,{configurable:true,value:e})}},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e){var r=0;var n=Math.random();t.exports=function(t){return"Symbol(".concat(t===undefined?"":t,")_",(++r+n).toString(36))}},function(t,e,r){var n=r(6);var o=r(1);var i="__core-js_shared__";var a=o[i]||(o[i]={});(t.exports=function(t,e){return a[t]||(a[t]=e!==undefined?e:{})})("versions",[]).push({version:n.version,mode:r(25)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,e){t.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}},function(t,e,r){var n=r(13);var o=r(1).document;var i=n(o)&&n(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return true}}},function(t,e){t.exports=true},function(t,e,r){"use strict";var n=r(25);var o=r(54);var i=r(49);var a=r(2);var u=r(7);var s=r(48);var f=r(18);var c=r(39);var l=r(0)("iterator");var v=!([].keys&&"next"in[].keys());var d="@@iterator";var p="keys";var h="values";var y=function(){return this};t.exports=function(t,e,r,m,g,x,w){s(r,e,m);var b=function(t){if(!v&&t in j)return j[t];switch(t){case p:return function e(){return new r(this,t)};case h:return function e(){return new r(this,t)}}return function e(){return new r(this,t)}};var _=e+" Iterator";var S=g==h;var O=false;var j=t.prototype;var M=j[l]||j[d]||g&&j[g];var C=M||b(g);var T=g?!S?C:b("entries"):undefined;var L=e=="Array"?j.entries||M:M;var k,P,E;if(L){E=c(L.call(new t));if(E!==Object.prototype&&E.next){f(E,_,true);if(!n&&typeof E[l]!="function")a(E,l,y)}}if(S&&M&&M.name!==h){O=true;C=function t(){return M.call(this)}}if((!n||w)&&(v||O||!j[l])){a(j,l,C)}u[e]=C;u[_]=y;if(g){k={values:S?C:b(h),keys:x?C:b(p),entries:T};if(w)for(P in k){if(!(P in j))i(j,P,k[P])}else o(o.P+o.F*(v||O),e,k)}return k}},function(t,e){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,e,r){"use strict";r.d(e,"a",function(){return n});function n(t,e,r,n,o,i,a,u){var s=typeof t==="function"?t.options:t;if(e){s.render=e;s.staticRenderFns=r;s._compiled=true}if(n){s.functional=true}if(i){s._scopeId="data-v-"+i}var f;if(a){f=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext;if(!t&&typeof __VUE_SSR_CONTEXT__!=="undefined"){t=__VUE_SSR_CONTEXT__}if(o){o.call(this,t)}if(t&&t._registeredComponents){t._registeredComponents.add(a)}};s._ssrRegister=f}else if(o){f=u?function(){o.call(this,this.$root.$options.shadowRoot)}:o}if(f){if(s.functional){s._injectStyles=f;var c=s.render;s.render=function t(e,r){f.call(r);return c(e,r)}}else{var l=s.beforeCreate;s.beforeCreate=l?[].concat(l,f):[f]}}return{exports:t,options:s}}},function(t,e,r){"use strict";r.r(e);function n(t,e){var r=[];var n={};for(var o=0;or.parts.length){n.parts.length=r.parts.length}}else{var a=[];for(var o=0;o=u)return t?"":undefined;s=i.charCodeAt(a);return s<55296||s>56319||a+1===u||(f=i.charCodeAt(a+1))<56320||f>57343?t?i.charAt(a):s:t?i.slice(a,a+2):(s-55296<<10)+(f-56320)+65536}}},function(t,e,r){"use strict";var n=r(36)(true);r(26)(String,"String",function(t){this._t=String(t);this._i=0},function(){var t=this._t;var e=this._i;var r;if(e>=t.length)return{value:undefined,done:true};r=n(t,e);this._i+=r.length;return{value:r,done:false}})},function(t,e,r){var n=r(15);t.exports=function(t){return Object(n(t))}},function(t,e,r){var n=r(3);var o=r(38);var i=r(11)("IE_PROTO");var a=Object.prototype;t.exports=Object.getPrototypeOf||function(t){t=o(t);if(n(t,i))return t[i];if(typeof t.constructor=="function"&&t instanceof t.constructor){return t.constructor.prototype}return t instanceof Object?a:null}},function(t,e,r){var n=r(1).document;t.exports=n&&n.documentElement},function(t,e,r){var n=r(12);var o=Math.max;var i=Math.min;t.exports=function(t,e){t=n(t);return t<0?o(t+e,0):i(t,e)}},function(t,e,r){var n=r(12);var o=Math.min;t.exports=function(t){return t>0?o(n(t),9007199254740991):0}},function(t,e,r){var n=r(16);var o=r(42);var i=r(41);t.exports=function(t){return function(e,r,a){var u=n(e);var s=o(u.length);var f=i(a,s);var c;if(t&&r!=r)while(s>f){c=u[f++];if(c!=c)return true}else for(;s>f;f++)if(t||f in u){if(u[f]===r)return t||f||0}return!t&&-1}}},function(t,e,r){var n=r(3);var o=r(16);var i=r(43)(false);var a=r(11)("IE_PROTO");t.exports=function(t,e){var r=o(t);var u=0;var s=[];var f;for(f in r)if(f!=a)n(r,f)&&s.push(f);while(e.length>u)if(n(r,f=e[u++])){~i(s,f)||s.push(f)}return s}},function(t,e,r){var n=r(44);var o=r(19);t.exports=Object.keys||function t(e){return n(e,o)}},function(t,e,r){var n=r(14);var o=r(5);var i=r(45);t.exports=r(4)?Object.defineProperties:function t(e,r){o(e);var a=i(r);var u=a.length;var s=0;var f;while(u>s)n.f(e,f=a[s++],r[f]);return e}},function(t,e,r){var n=r(5);var o=r(46);var i=r(19);var a=r(11)("IE_PROTO");var u=function(){};var s="prototype";var f=function(){var t=r(23)("iframe");var e=i.length;var n="<";var o=">";var a;t.style.display="none";r(40).appendChild(t);t.src="javascript:";a=t.contentWindow.document;a.open();a.write(n+"script"+o+"document.F=Object"+n+"/script"+o);a.close();f=a.F;while(e--)delete f[s][i[e]];return f()};t.exports=Object.create||function t(e,r){var i;if(e!==null){u[s]=n(e);i=new u;u[s]=null;i[a]=e}else i=f();return r===undefined?i:o(i,r)}},function(t,e,r){"use strict";var n=r(47);var o=r(22);var i=r(18);var a={};r(2)(a,r(0)("iterator"),function(){return this});t.exports=function(t,e,r){t.prototype=n(a,{next:o(1,r)});i(t,e+" Iterator")}},function(t,e,r){t.exports=r(2)},function(t,e,r){var n=r(13);t.exports=function(t,e){if(!n(t))return t;var r,o;if(e&&typeof(r=t.toString)=="function"&&!n(o=r.call(t)))return o;if(typeof(r=t.valueOf)=="function"&&!n(o=r.call(t)))return o;if(!e&&typeof(r=t.toString)=="function"&&!n(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e,r){t.exports=!r(4)&&!r(24)(function(){return Object.defineProperty(r(23)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,e){t.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(t,e,r){var n=r(52);t.exports=function(t,e,r){n(t);if(e===undefined)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},function(t,e,r){var n=r(1);var o=r(6);var i=r(53);var a=r(2);var u=r(3);var s="prototype";var f=function(t,e,r){var c=t&f.F;var l=t&f.G;var v=t&f.S;var d=t&f.P;var p=t&f.B;var h=t&f.W;var y=l?o:o[e]||(o[e]={});var m=y[s];var g=l?n:v?n[e]:(n[e]||{})[s];var x,w,b;if(l)r=e;for(x in r){w=!c&&g&&g[x]!==undefined;if(w&&u(y,x))continue;b=w?g[x]:r[x];y[x]=l&&typeof g[x]!="function"?r[x]:p&&w?i(b,n):h&&g[x]==b?function(t){var e=function(e,r,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,r)}return new t(e,r,n)}return t.apply(this,arguments)};e[s]=t[s];return e}(b):d&&typeof b=="function"?i(Function.call,b):b;if(d){(y.virtual||(y.virtual={}))[x]=b;if(t&f.R&&m&&!m[x])a(m,x,b)}}};f.F=1;f.G=2;f.S=4;f.P=8;f.B=16;f.W=32;f.U=64;f.R=128;t.exports=f},function(t,e,r){var n=r(27);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return n(t)=="String"?t.split(""):Object(t)}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e){t.exports=function(){}},function(t,e,r){"use strict";var n=r(57);var o=r(56);var i=r(7);var a=r(16);t.exports=r(26)(Array,"Array",function(t,e){this._t=a(t);this._i=0;this._k=e},function(){var t=this._t;var e=this._k;var r=this._i++;if(!t||r>=t.length){this._t=undefined;return o(1)}if(e=="keys")return o(0,r);if(e=="values")return o(0,t[r]);return o(0,[r,t[r]])},"values");i.Arguments=i.Array;n("keys");n("values");n("entries")},function(t,e,r){r(58);var n=r(1);var o=r(2);var i=r(7);var a=r(0)("toStringTag");var u=("CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,"+"DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,"+"MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,"+"SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,"+"TextTrackList,TouchList").split(",");for(var s=0;s 2 | 3 | Vue.js search dropdown component - example 4 | 5 | 6 | 20 | 21 | 22 |
23 |

Vue.js search dropdown component - example

24 |

Type "Unicorn" and press enter :

25 | 31 | 32 |

Selected animal: {{ selected.name || 'none' }}

33 |
34 |

Please see documentation here: https://github.com/romainsimon/vue-simple-search-dropdown

35 |
36 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-simple-search-dropdown", 3 | "version": "1.0.1", 4 | "description": "A Vue.js simple dropdown component with search", 5 | "main": "dist/vue-simple-search-dropdown.js", 6 | "scripts": { 7 | "build": "rimraf ./dist && webpack --config ./webpack.config.js" 8 | }, 9 | "author": "Romain Simon ", 10 | "license": "MIT", 11 | "dependencies": {}, 12 | "keywords": [ 13 | "vue", 14 | "vuejs", 15 | "dropdown" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/romainsimon/vue-simple-search-dropdown" 20 | }, 21 | "devDependencies": { 22 | "babel-core": "^6.26.3", 23 | "babel-loader": "^7.1.4", 24 | "babel-plugin-transform-runtime": "^6.23.0", 25 | "babel-preset-es2015": "^6.24.1", 26 | "babel-preset-stage-2": "^6.24.1", 27 | "babel-runtime": "^6.26.0", 28 | "css-loader": "^0.28.11", 29 | "extract-text-webpack-plugin": "^3.0.2", 30 | "node-sass": "^4.9.0", 31 | "rimraf": "^2.6.2", 32 | "sass-loader": "^7.0.3", 33 | "uglifyjs-webpack-plugin": "^1.2.5", 34 | "vue": "^2.5.16", 35 | "vue-html-loader": "^1.2.4", 36 | "vue-loader": "^15.2.4", 37 | "vue-style-loader": "^4.1.0", 38 | "vue-template-compiler": "^2.5.16", 39 | "webpack": "^4.11.1", 40 | "webpack-cli": "^3.0.3", 41 | "webpack-merge": "^4.1.2" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Dropdown.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 127 | 128 | 129 | 177 | -------------------------------------------------------------------------------- /src/plugin.js: -------------------------------------------------------------------------------- 1 | import Dropdown from './Dropdown.vue'; 2 | 3 | module.exports = { 4 | install: function (Vue, options) { 5 | Vue.component('Dropdown', Dropdown); 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); 3 | const UglifyJSPlugin = require('uglifyjs-webpack-plugin') 4 | const VueLoader = require('vue-loader'); 5 | const merge = require('webpack-merge'); 6 | const path = require('path'); 7 | 8 | const config = { 9 | output: { 10 | path: path.resolve(__dirname + '/dist/'), 11 | }, 12 | module: { 13 | rules: [ 14 | { 15 | test: /\.js$/, 16 | loader: 'babel-loader', 17 | include: __dirname, 18 | exclude: /node_modules/ 19 | }, 20 | { 21 | test: /\.vue$/, 22 | loader: 'vue-loader', 23 | options: { 24 | rules: { 25 | scss: ExtractTextPlugin.extract({ 26 | use: 'css-loader!sass-loader', 27 | fallback: 'vue-style-loader' 28 | }), 29 | sass: ExtractTextPlugin.extract({ 30 | use: 'sass-loader', 31 | fallback: 'vue-style-loader' 32 | }) 33 | } 34 | }, 35 | }, 36 | { 37 | test: /\.scss$/, 38 | use: [ 39 | 'vue-style-loader', 40 | 'css-loader', 41 | 'sass-loader' 42 | ] 43 | } 44 | ] 45 | }, 46 | optimization: { 47 | minimizer: [ 48 | new UglifyJSPlugin({ 49 | uglifyOptions: { 50 | compress: false, 51 | ecma: 6, 52 | mangle: true 53 | }, 54 | sourceMap: true 55 | }) 56 | ] 57 | }, 58 | plugins: [ 59 | new VueLoader.VueLoaderPlugin() 60 | ] 61 | }; 62 | 63 | module.exports = [ 64 | merge(config, { 65 | entry: path.resolve(__dirname + '/src/plugin.js'), 66 | output: { 67 | filename: 'vue-simple-search-dropdown.min.js', 68 | libraryTarget: 'window', 69 | library: 'Dropdown', 70 | } 71 | }), 72 | merge(config, { 73 | entry: path.resolve(__dirname + '/src/Dropdown.vue'), 74 | output: { 75 | filename: 'vue-simple-search-dropdown.js', 76 | libraryTarget: 'umd', 77 | library: 'vue-simple-search-dropdown', 78 | umdNamedDefine: true 79 | } 80 | }) 81 | ]; 82 | --------------------------------------------------------------------------------