2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-07 07:12:23 +03:00
Files
vue-select/js/app.bdfb419f193ed57c8b3a.js
T
2018-01-15 15:29:21 -08:00

2 lines
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
webpackJsonp([2,0],{0:function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}var o=n(90),l=i(o),s=n(87),a=i(s);n(82),l.default.component("v-select",a.default),new l.default({el:"#app",data:function(){return{loading:!1,selected:null,options:[{title:"Read the Docs",icon:"octicon-book",url:"/docs/"},{title:"View on GitHub",icon:"octicon-mark-github",url:"https://github.com/sagalbot/vue-select"},{title:"View on NPM",icon:"octicon-database",url:"https://www.npmjs.com/package/vue-select"},{title:"View Code Climate Analysis",icon:"octicon-graph",url:"https://codeclimate.com/github/sagalbot/vue-select"},{title:"View Codepen Examples",icon:"octicon-pencil",url:"https://codepen.io/collection/nrkgxV/"}]}}})},38:function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(44),l=i(o),s=n(47),a=i(s),u=n(42),r=i(u),h=n(48),c=i(h),d=n(40),p=i(d),f=n(41),b=i(f),m=n(39),g=i(m);t.default={mixins:[p.default,b.default,g.default],props:{value:{default:null},options:{type:Array,default:function(){return[]}},disabled:{type:Boolean,default:!1},maxHeight:{type:String,default:"400px"},searchable:{type:Boolean,default:!0},multiple:{type:Boolean,default:!1},placeholder:{type:String,default:""},transition:{type:String,default:"fade"},clearSearchOnSelect:{type:Boolean,default:!0},closeOnSelect:{type:Boolean,default:!0},label:{type:String,default:"label"},getOptionLabel:{type:Function,default:function(e){if("object"===("undefined"==typeof e?"undefined":(0,c.default)(e))){if(!e.hasOwnProperty(this.label))return console.warn('[vue-select warn]: Label key "option.'+this.label+'" does not'+(" exist in options object "+(0,r.default)(e)+".\n")+"http://sagalbot.github.io/vue-select/#ex-labels");if(this.label&&e[this.label])return e[this.label]}return e}},filterFunction:{type:Function,default:function(e,t,n){return(t||"").toLowerCase().indexOf(n.toLowerCase())>-1}},onChange:{type:Function,default:function(e){this.$emit("input",e)}},taggable:{type:Boolean,default:!1},tabindex:{type:Number,default:null},pushTags:{type:Boolean,default:!1},filterable:{type:Boolean,default:!0},createOption:{type:Function,default:function(e){return"object"===(0,c.default)(this.mutableOptions[0])&&(e=(0,a.default)({},this.label,e)),this.$emit("option:created",e),e}},resetOnOptionsChange:{type:Boolean,default:!1},noDrop:{type:Boolean,default:!1},inputId:{type:String},dir:{type:String,default:"auto"}},data:function(){return{search:"",open:!1,mutableValue:null,mutableOptions:[]}},watch:{value:function(e){this.mutableValue=e},mutableValue:function(e,t){this.multiple?this.onChange?this.onChange(e):null:this.onChange&&e!==t?this.onChange(e):null},options:function(e){this.mutableOptions=e},mutableOptions:function(){!this.taggable&&this.resetOnOptionsChange&&(this.mutableValue=this.multiple?[]:null)},multiple:function(e){this.mutableValue=e?[]:null}},created:function(){this.mutableValue=this.value,this.mutableOptions=this.options.slice(0),this.mutableLoading=this.loading,this.$on("option:created",this.maybePushTag)},methods:{select:function(e){this.isOptionSelected(e)?this.deselect(e):(this.taggable&&!this.optionExists(e)&&(e=this.createOption(e)),this.multiple&&!this.mutableValue?this.mutableValue=[e]:this.multiple?this.mutableValue.push(e):this.mutableValue=e),this.onAfterSelect(e)},deselect:function(e){var t=this;if(this.multiple){var n=-1;this.mutableValue.forEach(function(i){(i===e||"object"===("undefined"==typeof i?"undefined":(0,c.default)(i))&&i[t.label]===e[t.label])&&(n=i)});var i=this.mutableValue.indexOf(n);this.mutableValue.splice(i,1)}else this.mutableValue=null},clearSelection:function(){this.mutableValue=this.multiple?[]:null},onAfterSelect:function(e){this.closeOnSelect&&(this.open=!this.open,this.$refs.search.blur()),this.clearSearchOnSelect&&(this.search="")},toggleDropdown:function(e){e.target!==this.$refs.openIndicator&&e.target!==this.$refs.search&&e.target!==this.$refs.toggle&&e.target!==this.$el||(this.open?this.$refs.search.blur():this.disabled||(this.open=!0,this.$refs.search.focus()))},isOptionSelected:function(e){var t=this;if(this.multiple&&this.mutableValue){var n=!1;return this.mutableValue.forEach(function(i){"object"===("undefined"==typeof i?"undefined":(0,c.default)(i))&&i[t.label]===e[t.label]?n=!0:"object"===("undefined"==typeof i?"undefined":(0,c.default)(i))&&i[t.label]===e?n=!0:i===e&&(n=!0)}),n}return this.mutableValue===e},onEscape:function(){this.search.length?this.search="":this.$refs.search.blur()},onSearchBlur:function(){this.clearSearchOnBlur&&(this.search=""),this.open=!1,this.$emit("search:blur")},onSearchFocus:function(){this.open=!0,this.$emit("search:focus")},maybeDeleteValue:function(){if(!this.$refs.search.value.length&&this.mutableValue)return this.multiple?this.mutableValue.pop():this.mutableValue=null},optionExists:function(e){var t=this,n=!1;return this.mutableOptions.forEach(function(i){"object"===("undefined"==typeof i?"undefined":(0,c.default)(i))&&i[t.label]===e?n=!0:i===e&&(n=!0)}),n},maybePushTag:function(e){this.pushTags&&this.mutableOptions.push(e)}},computed:{dropdownClasses:function(){return{open:this.dropdownOpen,single:!this.multiple,searching:this.searching,searchable:this.searchable,unsearchable:!this.searchable,loading:this.mutableLoading,rtl:"rtl"===this.dir,disabled:this.disabled}},clearSearchOnBlur:function(){return this.clearSearchOnSelect&&!this.multiple},searching:function(){return!!this.search},dropdownOpen:function(){return!this.noDrop&&(this.open&&!this.mutableLoading)},searchPlaceholder:function(){if(this.isValueEmpty&&this.placeholder)return this.placeholder},filteredOptions:function(){var e=this;if(!this.filterable&&!this.taggable)return this.mutableOptions.slice();var t=this.mutableOptions.filter(function(t){var n=e.getOptionLabel(t);return"number"==typeof n&&(n=n.toString()),e.filterFunction(t,n,e.search)});return this.taggable&&this.search.length&&!this.optionExists(this.search)&&t.unshift(this.search),t},isValueEmpty:function(){return!this.mutableValue||("object"===(0,c.default)(this.mutableValue)?!(0,l.default)(this.mutableValue).length:!this.mutableValue.length)},valueAsArray:function(){return this.multiple?this.mutableValue:this.mutableValue?[].concat(this.mutableValue):[]},showClearButton:function(){return!this.multiple&&!this.open&&null!=this.mutableValue}}}},39:function(e,t){"use strict";e.exports={props:{loading:{type:Boolean,default:!1},onSearch:{type:Function,default:function(e,t){}}},data:function(){return{mutableLoading:!1}},watch:{search:function(){this.search.length>0&&(this.onSearch(this.search,this.toggleLoading),this.$emit("search",this.search,this.toggleLoading))},loading:function(e){this.mutableLoading=e}},methods:{toggleLoading:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return null==e?this.mutableLoading=!this.mutableLoading:this.mutableLoading=e}}}},40:function(e,t){"use strict";e.exports={watch:{typeAheadPointer:function(){this.maybeAdjustScroll()}},methods:{maybeAdjustScroll:function(){var e=this.pixelsToPointerTop(),t=this.pixelsToPointerBottom();return e<=this.viewport().top?this.scrollTo(e):t>=this.viewport().bottom?this.scrollTo(this.viewport().top+this.pointerHeight()):void 0},pixelsToPointerTop:function e(){var e=0;if(this.$refs.dropdownMenu)for(var t=0;t<this.typeAheadPointer;t++)e+=this.$refs.dropdownMenu.children[t].offsetHeight;return e},pixelsToPointerBottom:function(){return this.pixelsToPointerTop()+this.pointerHeight()},pointerHeight:function(){var e=!!this.$refs.dropdownMenu&&this.$refs.dropdownMenu.children[this.typeAheadPointer];return e?e.offsetHeight:0},viewport:function(){return{top:this.$refs.dropdownMenu?this.$refs.dropdownMenu.scrollTop:0,bottom:this.$refs.dropdownMenu?this.$refs.dropdownMenu.offsetHeight+this.$refs.dropdownMenu.scrollTop:0}},scrollTo:function(e){return this.$refs.dropdownMenu?this.$refs.dropdownMenu.scrollTop=e:null}}}},41:function(e,t){"use strict";e.exports={data:function(){return{typeAheadPointer:-1}},watch:{filteredOptions:function(){this.typeAheadPointer=0}},methods:{typeAheadUp:function(){this.typeAheadPointer>0&&(this.typeAheadPointer--,this.maybeAdjustScroll&&this.maybeAdjustScroll())},typeAheadDown:function(){this.typeAheadPointer<this.filteredOptions.length-1&&(this.typeAheadPointer++,this.maybeAdjustScroll&&this.maybeAdjustScroll())},typeAheadSelect:function(){this.filteredOptions[this.typeAheadPointer]?this.select(this.filteredOptions[this.typeAheadPointer]):this.taggable&&this.search.length&&this.select(this.search),this.clearSearchOnSelect&&(this.search="")}}}},82:function(e,t){},83:function(e,t){},87:function(e,t,n){n(83);var i=n(88)(n(38),n(89),null,null);e.exports=i.exports},89:function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"dropdown v-select",class:e.dropdownClasses,attrs:{dir:e.dir}},[n("div",{ref:"toggle",class:["dropdown-toggle","clearfix"],on:{mousedown:function(t){t.preventDefault(),e.toggleDropdown(t)}}},[e._l(e.valueAsArray,function(t){return e._t("selected-option-container",[n("span",{key:t.index,staticClass:"selected-tag"},[e._t("selected-option",[e._v("\n "+e._s(e.getOptionLabel(t))+"\n ")],null,t),e._v(" "),e.multiple?n("button",{staticClass:"close",attrs:{disabled:e.disabled,type:"button","aria-label":"Remove option"},on:{click:function(n){e.deselect(t)}}},[n("span",{attrs:{"aria-hidden":"true"}},[e._v("×")])]):e._e()],2)],{option:t,deselect:e.deselect})}),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"search",staticClass:"form-control",style:{width:e.isValueEmpty?"100%":"auto"},attrs:{type:"search",autocomplete:"false",disabled:e.disabled,placeholder:e.searchPlaceholder,tabindex:e.tabindex,readonly:!e.searchable,id:e.inputId,"aria-label":"Search for option"},domProps:{value:e.search},on:{keydown:[function(t){return"button"in t||!e._k(t.keyCode,"delete",[8,46],t.key)?void e.maybeDeleteValue(t):null},function(t){return"button"in t||!e._k(t.keyCode,"up",38,t.key)?(t.preventDefault(),void e.typeAheadUp(t)):null},function(t){return"button"in t||!e._k(t.keyCode,"down",40,t.key)?(t.preventDefault(),void e.typeAheadDown(t)):null},function(t){return"button"in t||!e._k(t.keyCode,"enter",13,t.key)?(t.preventDefault(),void e.typeAheadSelect(t)):null}],keyup:function(t){return"button"in t||!e._k(t.keyCode,"esc",27,t.key)?void e.onEscape(t):null},blur:e.onSearchBlur,focus:e.onSearchFocus,input:function(t){t.target.composing||(e.search=t.target.value)}}}),e._v(" "),n("button",{directives:[{name:"show",rawName:"v-show",value:e.showClearButton,expression:"showClearButton"}],staticClass:"clear",attrs:{disabled:e.disabled,type:"button",title:"Clear selection"},on:{click:e.clearSelection}},[n("span",{attrs:{"aria-hidden":"true"}},[e._v("×")])]),e._v(" "),e.noDrop?e._e():n("i",{ref:"openIndicator",staticClass:"open-indicator",attrs:{role:"presentation"}}),e._v(" "),e._t("spinner",[n("div",{directives:[{name:"show",rawName:"v-show",value:e.mutableLoading,expression:"mutableLoading"}],staticClass:"spinner"},[e._v("Loading...")])])],2),e._v(" "),n("transition",{attrs:{name:e.transition}},[e.dropdownOpen?n("ul",{ref:"dropdownMenu",staticClass:"dropdown-menu",style:{"max-height":e.maxHeight}},[e._l(e.filteredOptions,function(t,i){return n("li",{key:i,class:{active:e.isOptionSelected(t),highlight:i===e.typeAheadPointer},on:{mouseover:function(t){e.typeAheadPointer=i}}},[n("a",{on:{mousedown:function(n){n.preventDefault(),e.select(t)}}},[e._t("option",[e._v("\n "+e._s(e.getOptionLabel(t))+"\n ")],null,t)],2)])}),e._v(" "),e.filteredOptions.length?e._e():n("li",{staticClass:"no-options"},[e._t("no-options",[e._v("Sorry, no matching options.")])],2)],2):e._e()])],1)},staticRenderFns:[]}}});
//# sourceMappingURL=app.bdfb419f193ed57c8b3a.js.map