vue-single-select
Advanced tools
Comparing version 1.0.27 to 1.0.28
@@ -21,3 +21,3 @@ // flow scored from vue select thanks Jeff! | ||
*/ | ||
maybeAdjustScroll() { | ||
maybeAdjustScroll () { | ||
let pixelsToPointerTop = this.pixelsToPointerTop() | ||
@@ -89,2 +89,2 @@ let pixelsToPointerBottom = this.pixelsToPointerBottom() | ||
} | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){var i=n(5);"string"==typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);(0,n(7).default)("77c24ab8",i,!0,{})},function(e,t,n){"use strict";var i={props:{value:{required:!0},name:{type:String,required:!1,default:()=>""},options:{type:Array,required:!1,default:()=>[]},optionLabel:{type:String,required:!1,default:()=>null},optionKey:{type:String,required:!1,default:()=>null},placeholder:{type:String,required:!1,default:()=>"Search Here"},maxHeight:{type:String,default:()=>"220px",required:!1},inputId:{type:String,default:()=>"single-select",required:!1},classes:{type:Object,required:!1,default:()=>({pointer:-1,wrapper:"single-select-wrapper",input:"search-input",icons:"icons",required:"required",activeClass:"active",dropdown:"dropdown"})},initial:{type:String,required:!1,default:()=>null},required:{type:Boolean,required:!1,default:()=>!1},maxResults:{type:Number,required:!1,default:()=>30},tabindex:{type:String,required:!1,default:()=>""},getOptionDescription:{type:Function,default(e){return this.optionKey&&this.optionLabel?e[this.optionKey]+" "+e[this.optionLabel]:this.optionLabel?e[this.optionLabel]:this.optionKey?e[this.optionKey]:e}},getOptionValue:{type:Function,default(e){return this.optionKey?e[this.optionKey]:this.optionLabel?e[this.optionLabel]:e}}},mixins:[{watch:{pointer(){this.maybeAdjustScroll()}},data:()=>({pointer:-1}),methods:{maybeAdjustScroll(){let 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(){let e=0;if(!this.$refs.options)return 0;for(let t=0;t<this.pointer;t++)e+=this.$refs.options.children[t].offsetHeight;return e},pixelsToPointerBottom(){return this.pixelsToPointerTop()+this.pointerHeight()},pointerHeight(){let e=!!this.$refs.options&&this.$refs.options.children[this.pointer];return e?e.offsetHeight:0},viewport(){return{top:this.$refs.options?this.$refs.options.scrollTop:0,bottom:this.$refs.options?this.$refs.options.offsetHeight+this.$refs.options.scrollTop:0}},scrollTo(e){return this.$refs.options?this.$refs.options.scrollTop=e:null}}}],mounted(){document.addEventListener("click",this.handleClickOutside),document.addEventListener("keyup",this.handleClickOutside),this.value&&this.options.includes(this.value)?this.selectedOption=this.value:this.searchText=this.initial},destroyed(){document.removeEventListener("keyup",this.handleClickOutside),document.removeEventListener("click",this.handleClickOutside)},data:()=>({searchText:null,selectedOption:null,dropdownOpen:!1,closed:!1}),watch:{value(e,t){e!==t&&(this.selectedOption=e)},searchText(e,t){e!==t&&(this.pointer=-1),e&&(this.closed=!1)},selectedOption(e,t){e!==t&&(this.$emit("input",e),this.closed||e||this.$nextTick().then(()=>{this.$refs.search.focus()}))},dropdownOpen(e,t){e!==t&&(this.selectedOption?this.searchText=this.getOptionDescription(this.selectedOption):e?(this.searchText||(this.searchText=""),this.$nextTick().then(()=>{this.$refs.search.focus()})):this.searchText=null)}},computed:{isRequired(){return this.required&&this.closed?this.selectedOption?"":"required":""},matchingOptions(){return null===this.searchText?null:this.searchText.length?this.optionLabel&&this.optionKey?this.options.filter(e=>e[this.optionLabel].toString().toLowerCase().includes(this.searchText.toString().toLowerCase())||e[this.optionKey].toString().toLowerCase().includes(this.searchText.toString().toLowerCase())).slice(0,this.maxResults):this.optionLabel?this.options.filter(e=>e[this.optionLabel].toString().toLowerCase().includes(this.searchText.toString().toLowerCase())).slice(0,this.maxResults):this.optionKey?this.options.filter(e=>e[this.optionKey].toString().toLowerCase().includes(this.searchText.toString().toLowerCase())).slice(0,this.maxResults):this.options.filter(e=>e.toString().toLowerCase().includes(this.searchText.toString().toLowerCase())).slice(0,this.maxResults):[...this.options].slice(0,this.maxResults)}},methods:{setPointerIdx(e){this.pointer=e},seedSearchText(){null===this.searchText&&(this.searchText="",this.closed&&(this.closed=!1))},switchToSearch(e){this.$refs.selectedValue.value=null,this.searchText=e.target.value,this.selectedOption=null,this.$nextTick().then(()=>{this.$refs.search.focus()})},toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},closeOut(){this.selectedOption=null,this.dropdownOpen=!1,this.searchText=null,this.closed=!0},movePointerDown(){this.matchingOptions&&(this.pointer>=this.matchingOptions.length-1||this.pointer++)},movePointerUp(){this.pointer>0&&this.pointer--},setOption(){this.matchingOptions&&this.matchingOptions.length&&(-1===this.pointer&&this.pointer++,this.selectedOption=this.matchingOptions[this.pointer],this.searchText=null,this.dropdownOpen=!1,this.pointer=-1,this.$nextTick().then(()=>{this.$refs.match.focus()}))},handleClickOutside(e){this.$el.contains(e.target)||(this.dropdownOpen=!1,this.searchText=null,this.closed=!0)}}};n(4);var o=function(e,t,n,i,o,r,s,a){var c,d="function"==typeof e?e.options:e;if(t&&(d.render=t,d.staticRenderFns=n,d._compiled=!0),i&&(d.functional=!0),r&&(d._scopeId="data-v-"+r),s?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},d._ssrRegister=c):o&&(c=a?function(){o.call(this,this.$root.$options.shadowRoot)}:o),c)if(d.functional){d._injectStyles=c;var l=d.render;d.render=function(e,t){return c.call(t),l(e,t)}}else{var u=d.beforeCreate;d.beforeCreate=u?[].concat(u,c):[c]}return{exports:e,options:d}}(i,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"vuesingleselect"},[e.selectedOption?e._e():n("div",{class:e.classes.wrapper},[n("div",{staticClass:"relative inline-block w-full"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.searchText,expression:"searchText"}],ref:"search",class:[e.classes.input,e.isRequired],attrs:{id:e.inputId,placeholder:e.placeholder,autocomplete:"off",required:e.required},domProps:{value:e.searchText},on:{click:e.seedSearchText,focus:e.seedSearchText,keyup:[function(t){return"button"in t||!e._k(t.keyCode,"enter",13,t.key,"Enter")?e.setOption(t):null},function(t){return"button"in t||!e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?e.movePointerDown(t):null},function(t){return"button"in t||!e._k(t.keyCode,"tab",9,t.key,"Tab")?(t.stopPropagation(),e.closeOut(t)):null},function(t){return"button"in t||!e._k(t.keyCode,"esc",27,t.key,"Escape")?(t.stopPropagation(),e.closeOut(t)):null},function(t){return"button"in t||!e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?e.movePointerUp(t):null}],input:function(t){t.target.composing||(e.searchText=t.target.value)}}}),e._v(" "),n("div",{staticClass:"cursor-pointer absolute flex items-center",class:[e.classes.icons],on:{click:e.toggleDropdown}},[e.dropdownOpen?n("svg",{attrs:{"aria-hidden":"true",viewBox:"0 0 448 512"}},[n("path",{attrs:{d:"M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z"}})]):n("svg",{attrs:{"aria-hidden":"true",viewBox:"0 0 448 512"}},[n("path",{attrs:{d:"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"}})])]),e._v(" "),e.matchingOptions?n("ul",{ref:"options",staticClass:"absolute w-full overflow-auto appearance-none mt-px list-reset",class:[e.classes.dropdown],staticStyle:{"z-index":"100"},style:{"max-height":e.maxHeight},attrs:{tabindex:"-1"}},e._l(e.matchingOptions,function(t,i){return n("li",{key:i,staticClass:"cursor-pointer outline-none",class:i===e.pointer?e.classes.activeClass:"",attrs:{tabindex:"-1"},on:{blur:function(t){e.handleClickOutside(t)},mouseover:function(t){e.setPointerIdx(i)},keyup:[function(t){if(!("button"in t)&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;e.setOption()},function(t){if(!("button"in t)&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"]))return null;e.movePointerUp()},function(t){if(!("button"in t)&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"]))return null;e.movePointerDown()}],click:function(t){t.preventDefault(),e.setOption()}}},[e._t("option",[e._v("\n "+e._s(e.getOptionDescription(t))+"\n\t ")],null,{option:t,idx:i})],2)})):e._e()])]),e._v(" "),e.selectedOption?n("div",{class:e.classes.wrapper},[n("input",{ref:"match",class:[e.classes.input],attrs:{id:"inputId",required:e.required},domProps:{value:e.getOptionDescription(e.selectedOption)},on:{input:function(t){e.switchToSearch(t)},click:function(t){e.switchToSearch(t)}}}),e._v(" "),n("input",{ref:"selectedValue",attrs:{type:"hidden",name:e.name},domProps:{value:e.getOptionValue(e.selectedOption)}}),e._v(" "),n("div",{staticClass:"flex absolute items-center",class:e.classes.icons},[n("svg",{staticClass:"cursor-pointer",attrs:{"aria-hidden":"true",viewBox:"0 0 512 512"},on:{click:e.closeOut}},[n("path",{attrs:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"}})])])]):e._e()])},[],!1,null,"2ade5cc6",null);o.options.__file="VueSingleSelect.vue";t.a=o.exports},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"install",function(){return o});var i=n(1);function o(e){o.installed||(o.installed=!0,e.component("vue-single-select",i.a))}const r={install:o};let s=null;"undefined"!=typeof window?s=window.Vue:void 0!==e&&(s=e.Vue),s&&s.use(r)}.call(this,n(3))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var i=n(0);n.n(i).a},function(e,t,n){(e.exports=n(6)(!1)).push([e.i,"\n.w-full[data-v-2ade5cc6] {\n width: 100%;\n}\n.inline-block[data-v-2ade5cc6] {\n display: inline-block;\n}\n.block[data-v-2ade5cc6] {\n display: block;\n}\n.flex[data-v-2ade5cc6] {\n display: flex;\n}\n.border[data-v-2ade5cc6] {\n border-width: thin;\n border-style: solid;\n}\n.rounded[data-v-2ade5cc6] {\n border-radius: 0.25em;\n}\n.text-black[data-v-2ade5cc6] {\n color: #22292f;\n}\n.border-grey-lighter[data-v-2ade5cc6] {\n border-color: #ced4da;\n}\n.bg-grey-lighter[data-v-2ade5cc6] {\n background-color: #606f7b;\n}\n.bg-grey-light[data-v-2ade5cc6] {\n background-color: #dae1e7;\n}\n.bg-grey-dark[data-v-2ade5cc6] {\n background-color: #8795a1;\n}\n.bg-white[data-v-2ade5cc6] {\n background-color: #fff;\n}\n.pin-r[data-v-2ade5cc6] {\n right: 0;\n}\n.pin-y[data-v-2ade5cc6] {\n top: 0;\n bottom: 0;\n}\n.absolute[data-v-2ade5cc6] {\n position: absolute;\n}\n.relative[data-v-2ade5cc6] {\n position: relative;\n}\n.items-center[data-v-2ade5cc6] {\n align-items: center;\n}\n.p-0[data-v-2ade5cc6] {\n padding: 0;\n}\n.p-1[data-v-2ade5cc6] {\n padding: 0.25em;\n}\n.px-1[data-v-2ade5cc6] {\n padding-left: 0.25em;\n padding-right: 0.25em;\n}\n.py-2[data-v-2ade5cc6] {\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n}\n.px-2[data-v-2ade5cc6] {\n padding-left: 0.5em;\n padding-right: 0.5em;\n}\n.mt-px[data-v-2ade5cc6] {\n margin-top: 1px;\n}\n.leading-tight[data-v-2ade5cc6] {\n line-height: 1.25;\n}\n.leading-normal[data-v-2ade5cc6] {\n line-height: 1.5;\n}\n.text-left[data-v-2ade5cc6] {\n text-align: left;\n}\n.w-full[data-v-2ade5cc6] {\n width: 100%;\n}\n.shadow[data-v-2ade5cc6] {\n box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);\n}\n.list-reset[data-v-2ade5cc6] {\n list-style: none;\n padding: 0;\n}\n.overflow-auto[data-v-2ade5cc6] {\n overflow: auto;\n}\n.appearance-none[data-v-2ade5cc6] {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.w-1[data-v-2ade5cc6] {\n width: 0.25em;\n}\n.w-2[data-v-2ade5cc6] {\n width: 0.5em;\n}\n.w-3[data-v-2ade5cc6] {\n width: 0.75em;\n}\n.w-4[data-v-2ade5cc6] {\n width: 1em;\n}\n.h-4[data-v-2ade5cc6] {\n height: 1em;\n}\n.h-1[data-v-2ade5cc6] {\n height: 0.25em;\n}\n.h-2[data-v-2ade5cc6] {\n height: 0.5em;\n}\n.h-3[data-v-2ade5cc6] {\n height: 0.75em;\n}\n.fill-current[data-v-2ade5cc6] {\n fill: currentColor;\n}\n.no-underline[data-v-2ade5cc6] {\n text-decoration: none;\n}\n.hover\\:no-underline[data-v-2ade5cc6]:hover {\n text-decoration: none;\n}\n.outline-none[data-v-2ade5cc6] {\n outline: 0;\n}\n.hover\\:outline-none[data-v-2ade5cc6] {\n outline: 0;\n}\n.hover\\:bg-grey-light[data-v-2ade5cc6]:hover {\n background-color: #dae1e7;\n}\n.shadow-md[data-v-2ade5cc6] {\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);\n}\n.search-input[data-v-2ade5cc6] {\n display: block;\n width: 100%;\n padding: 0.375em 0.75em;\n font-size: 1em;\n line-height: 1.5;\n color: #495057;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid #ced4da;\n border-radius: 0.25em;\n transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;\n box-sizing: border-box;\n}\n.icons[data-v-2ade5cc6] {\n padding: 0 1em;\n right: 0;\n top: 0;\n bottom: 0;\n fill: #606f7b;\n}\n.icons svg[data-v-2ade5cc6] {\n width: 0.75em;\n height: 0.75em;\n}\n.single-select-wrapper[data-v-2ade5cc6] {\n position: relative;\n margin-bottom: 0.5em;\n}\n.required[data-v-2ade5cc6] {\n _color: #721c24;\n _background-color: #f8d7da;\n border-color: #f5c6cb;\n}\n.cursor-pointer[data-v-2ade5cc6] {\n cursor: pointer;\n}\n.dropdown[data-v-2ade5cc6] {\n -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12),\n 0 2px 4px 0 rgba(0, 0, 0, 0.08);\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);\n background-color: #fff;\n color: #606f7b;\n border-radius: 0.25em;\n line-height: 1.25;\n text-align: left;\n}\n.dropdown > li[data-v-2ade5cc6] {\n padding: 0.5em 0.75em;\n}\n.active[data-v-2ade5cc6] {\n background: #dae1e7;\n}\n",""])},function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var o=function(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}(i),r=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[n].concat(r).concat([o]).join("\n")}return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},o=0;o<this.length;o++){var r=this[o][0];"number"==typeof r&&(i[r]=!0)}for(o=0;o<e.length;o++){var s=e[o];"number"==typeof s[0]&&i[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){"use strict";function i(e,t){for(var n=[],i={},o=0;o<t.length;o++){var r=t[o],s=r[0],a={id:e+":"+o,css:r[1],media:r[2],sourceMap:r[3]};i[s]?i[s].parts.push(a):n.push(i[s]={id:s,parts:[a]})}return n}n.r(t),n.d(t,"default",function(){return f});var o="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var r={},s=o&&(document.head||document.getElementsByTagName("head")[0]),a=null,c=0,d=!1,l=function(){},u=null,p="data-vue-ssr-id",h="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function f(e,t,n,o){d=n,u=o||{};var s=i(e,t);return v(s),function(t){for(var n=[],o=0;o<s.length;o++){var a=s[o];(c=r[a.id]).refs--,n.push(c)}t?v(s=i(e,t)):s=[];for(o=0;o<n.length;o++){var c;if(0===(c=n[o]).refs){for(var d=0;d<c.parts.length;d++)c.parts[d]();delete r[c.id]}}}}function v(e){for(var t=0;t<e.length;t++){var n=e[t],i=r[n.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](n.parts[o]);for(;o<n.parts.length;o++)i.parts.push(m(n.parts[o]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var s=[];for(o=0;o<n.parts.length;o++)s.push(m(n.parts[o]));r[n.id]={id:n.id,refs:1,parts:s}}}}function g(){var e=document.createElement("style");return e.type="text/css",s.appendChild(e),e}function m(e){var t,n,i=document.querySelector("style["+p+'~="'+e.id+'"]');if(i){if(d)return l;i.parentNode.removeChild(i)}if(h){var o=c++;i=a||(a=g()),t=x.bind(null,i,o,!1),n=x.bind(null,i,o,!0)}else i=g(),t=function(e,t){var n=t.css,i=t.media,o=t.sourceMap;i&&e.setAttribute("media",i);u.ssrId&&e.setAttribute(p,t.id);o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,i),n=function(){i.parentNode.removeChild(i)};return t(e),function(i){if(i){if(i.css===e.css&&i.media===e.media&&i.sourceMap===e.sourceMap)return;t(e=i)}else n()}}var b=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}();function x(e,t,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=b(t,o);else{var r=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}}])); | ||
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){var i=n(5);"string"==typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);(0,n(7).default)("4eae14fd",i,!0,{})},function(e,t,n){"use strict";var i={props:{value:{required:!0},name:{type:String,required:!1,default:()=>""},options:{type:Array,required:!1,default:()=>[]},optionLabel:{type:String,required:!1,default:()=>null},optionKey:{type:String,required:!1,default:()=>null},placeholder:{type:String,required:!1,default:()=>"Search Here"},maxHeight:{type:String,default:()=>"220px",required:!1},inputId:{type:String,default:()=>"single-select",required:!1},classes:{type:Object,required:!1,default:()=>({pointer:-1,wrapper:"single-select-wrapper",input:"search-input",icons:"icons",required:"required",activeClass:"active",dropdown:"dropdown"})},initial:{type:String,required:!1,default:()=>null},required:{type:Boolean,required:!1,default:()=>!1},maxResults:{type:Number,required:!1,default:()=>30},tabindex:{type:String,required:!1,default:()=>""},getOptionDescription:{type:Function,default:function(e){return this.optionKey&&this.optionLabel?e[this.optionKey]+" "+e[this.optionLabel]:this.optionLabel?e[this.optionLabel]:this.optionKey?e[this.optionKey]:e}},getOptionValue:{type:Function,default:function(e){return this.optionKey?e[this.optionKey]:this.optionLabel?e[this.optionLabel]:e}},filterBy:{type:Function,default:function(e){return this.optionLabel&&this.optionKey?e[this.optionLabel].toString().toLowerCase().includes(this.searchText.toString().toLowerCase())||e[this.optionKey].toString().toLowerCase().includes(this.searchText.toString().toLowerCase()):this.optionLabel?e[this.optionLabel].toString().toLowerCase().includes(this.searchText.toString().toLowerCase()):(this.optionKey&&e[this.optionKey].toString().toLowerCase().includes(this.searchText.toString().toLowerCase()),e.toString().toLowerCase().includes(this.searchText.toString().toLowerCase()))}}},mixins:[{watch:{pointer(){this.maybeAdjustScroll()}},data:()=>({pointer:-1}),methods:{maybeAdjustScroll(){let 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(){let e=0;if(!this.$refs.options)return 0;for(let t=0;t<this.pointer;t++)e+=this.$refs.options.children[t].offsetHeight;return e},pixelsToPointerBottom(){return this.pixelsToPointerTop()+this.pointerHeight()},pointerHeight(){let e=!!this.$refs.options&&this.$refs.options.children[this.pointer];return e?e.offsetHeight:0},viewport(){return{top:this.$refs.options?this.$refs.options.scrollTop:0,bottom:this.$refs.options?this.$refs.options.offsetHeight+this.$refs.options.scrollTop:0}},scrollTo(e){return this.$refs.options?this.$refs.options.scrollTop=e:null}}}],mounted(){document.addEventListener("click",this.handleClickOutside),document.addEventListener("keyup",this.handleClickOutside),this.value&&this.options.includes(this.value)?this.selectedOption=this.value:this.searchText=this.initial},destroyed(){document.removeEventListener("keyup",this.handleClickOutside),document.removeEventListener("click",this.handleClickOutside)},data:()=>({searchText:null,selectedOption:null,dropdownOpen:!1}),watch:{value(e,t){this.selectedOption=e},searchText(e,t){e!==t&&(this.pointer=-1)},selectedOption(e,t){this.$emit("input",e)},dropdownOpen(e,t){e!==t&&(e?(this.searchText||(this.searchText=""),this.$nextTick().then(()=>{this.$refs.search.focus()})):this.searchText=null)}},computed:{isRequired(){return this.required?this.selectedOption?"":"required":""},matchingOptions(){return null===this.searchText?null:this.searchText.length?this.options.filter(e=>this.filterBy(e)).slice(0,this.maxResults):[...this.options].slice(0,this.maxResults)}},methods:{setPointerIdx(e){this.pointer=e},seedSearchText(){null===this.searchText&&(this.searchText="")},switchToSearch(e){this.$refs.selectedValue.value=null,this.searchText=e.target.value,this.selectedOption=null,this.dropdownOpen=!0},toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},closeOut(){this.selectedOption=null,this.dropdownOpen=!1,this.searchText=null},movePointerDown(){this.matchingOptions&&(this.pointer>=this.matchingOptions.length-1||this.pointer++)},movePointerUp(){this.pointer>0&&this.pointer--},setOption(){this.matchingOptions&&this.matchingOptions.length&&(-1===this.pointer&&this.pointer++,this.selectedOption=this.matchingOptions[this.pointer],this.searchText=null,this.dropdownOpen=!1,this.pointer=-1,this.$nextTick().then(()=>{this.$refs.match.focus()}))},handleClickOutside(e){this.$el.contains(e.target)||(this.dropdownOpen=!1,this.searchText=null)}}};n(4);var o=function(e,t,n,i,o,r,s,a){var l,d="function"==typeof e?e.options:e;if(t&&(d.render=t,d.staticRenderFns=n,d._compiled=!0),i&&(d.functional=!0),r&&(d._scopeId="data-v-"+r),s?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},d._ssrRegister=l):o&&(l=a?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(d.functional){d._injectStyles=l;var u=d.render;d.render=function(e,t){return l.call(t),u(e,t)}}else{var c=d.beforeCreate;d.beforeCreate=c?[].concat(c,l):[l]}return{exports:e,options:d}}(i,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"vuesingleselect"},[e.selectedOption?e._e():n("div",{class:e.classes.wrapper},[n("div",{staticClass:"relative inline-block w-full"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.searchText,expression:"searchText"}],ref:"search",class:[e.classes.input,e.isRequired],attrs:{id:e.inputId,placeholder:e.placeholder,autocomplete:"off",required:e.required},domProps:{value:e.searchText},on:{click:e.seedSearchText,focus:e.seedSearchText,keyup:[function(t){return"button"in t||!e._k(t.keyCode,"enter",13,t.key,"Enter")?e.setOption(t):null},function(t){return"button"in t||!e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?e.movePointerDown(t):null},function(t){return"button"in t||!e._k(t.keyCode,"tab",9,t.key,"Tab")?(t.stopPropagation(),e.closeOut(t)):null},function(t){return"button"in t||!e._k(t.keyCode,"esc",27,t.key,"Escape")?(t.stopPropagation(),e.closeOut(t)):null},function(t){return"button"in t||!e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?e.movePointerUp(t):null}],input:function(t){t.target.composing||(e.searchText=t.target.value)}}}),e._v(" "),n("div",{staticClass:"cursor-pointer absolute flex items-center",class:[e.classes.icons],on:{click:e.toggleDropdown}},[e.dropdownOpen?n("svg",{attrs:{"aria-hidden":"true",viewBox:"0 0 448 512"}},[n("path",{attrs:{d:"M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z"}})]):n("svg",{attrs:{"aria-hidden":"true",viewBox:"0 0 448 512"}},[n("path",{attrs:{d:"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"}})])]),e._v(" "),e.matchingOptions?n("ul",{ref:"options",staticClass:"absolute w-full overflow-auto appearance-none mt-px list-reset",class:[e.classes.dropdown],staticStyle:{"z-index":"100"},style:{"max-height":e.maxHeight},attrs:{tabindex:"-1"}},e._l(e.matchingOptions,function(t,i){return n("li",{key:i,staticClass:"cursor-pointer outline-none",class:i===e.pointer?e.classes.activeClass:"",attrs:{tabindex:"-1"},on:{blur:function(t){e.handleClickOutside(t)},mouseover:function(t){e.setPointerIdx(i)},keyup:[function(t){if(!("button"in t)&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;e.setOption()},function(t){if(!("button"in t)&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"]))return null;e.movePointerUp()},function(t){if(!("button"in t)&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"]))return null;e.movePointerDown()}],click:function(t){t.preventDefault(),e.setOption()}}},[e._t("option",[e._v("\n "+e._s(e.getOptionDescription(t))+"\n ")],null,{option:t,idx:i})],2)})):e._e()])]),e._v(" "),e.selectedOption?n("div",{class:e.classes.wrapper},[n("input",{ref:"match",class:[e.classes.input],attrs:{id:e.inputId,required:e.required},domProps:{value:e.getOptionDescription(e.selectedOption)},on:{input:function(t){e.switchToSearch(t)},click:function(t){e.switchToSearch(t)}}}),e._v(" "),n("input",{ref:"selectedValue",attrs:{type:"hidden",name:e.name},domProps:{value:e.getOptionValue(e.selectedOption)}}),e._v(" "),n("div",{staticClass:"flex absolute items-center",class:e.classes.icons},[n("svg",{staticClass:"cursor-pointer",attrs:{"aria-hidden":"true",viewBox:"0 0 512 512"},on:{click:e.closeOut}},[n("path",{attrs:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"}})])])]):e._e()])},[],!1,null,"51051e89",null);o.options.__file="VueSingleSelect.vue";t.a=o.exports},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"install",function(){return o});var i=n(1);function o(e){o.installed||(o.installed=!0,e.component("vue-single-select",i.a))}const r={install:o};let s=null;"undefined"!=typeof window?s=window.Vue:void 0!==e&&(s=e.Vue),s&&s.use(r)}.call(this,n(3))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var i=n(0);n.n(i).a},function(e,t,n){(e.exports=n(6)(!1)).push([e.i,"\n.w-full[data-v-51051e89] {\n width: 100%;\n}\n.inline-block[data-v-51051e89] {\n display: inline-block;\n}\n.block[data-v-51051e89] {\n display: block;\n}\n.flex[data-v-51051e89] {\n display: flex;\n}\n.border[data-v-51051e89] {\n border-width: thin;\n border-style: solid;\n}\n.rounded[data-v-51051e89] {\n border-radius: 0.25em;\n}\n.text-black[data-v-51051e89] {\n color: #22292f;\n}\n.border-grey-lighter[data-v-51051e89] {\n border-color: #ced4da;\n}\n.bg-grey-lighter[data-v-51051e89] {\n background-color: #606f7b;\n}\n.bg-grey-light[data-v-51051e89] {\n background-color: #dae1e7;\n}\n.bg-grey-dark[data-v-51051e89] {\n background-color: #8795a1;\n}\n.bg-white[data-v-51051e89] {\n background-color: #fff;\n}\n.pin-r[data-v-51051e89] {\n right: 0;\n}\n.pin-y[data-v-51051e89] {\n top: 0;\n bottom: 0;\n}\n.absolute[data-v-51051e89] {\n position: absolute;\n}\n.relative[data-v-51051e89] {\n position: relative;\n}\n.items-center[data-v-51051e89] {\n align-items: center;\n}\n.p-0[data-v-51051e89] {\n padding: 0;\n}\n.p-1[data-v-51051e89] {\n padding: 0.25em;\n}\n.px-1[data-v-51051e89] {\n padding-left: 0.25em;\n padding-right: 0.25em;\n}\n.py-2[data-v-51051e89] {\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n}\n.px-2[data-v-51051e89] {\n padding-left: 0.5em;\n padding-right: 0.5em;\n}\n.mt-px[data-v-51051e89] {\n margin-top: 1px;\n}\n.leading-tight[data-v-51051e89] {\n line-height: 1.25;\n}\n.leading-normal[data-v-51051e89] {\n line-height: 1.5;\n}\n.text-left[data-v-51051e89] {\n text-align: left;\n}\n.w-full[data-v-51051e89] {\n width: 100%;\n}\n.shadow[data-v-51051e89] {\n box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);\n}\n.list-reset[data-v-51051e89] {\n list-style: none;\n padding: 0;\n}\n.overflow-auto[data-v-51051e89] {\n overflow: auto;\n}\n.appearance-none[data-v-51051e89] {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.w-1[data-v-51051e89] {\n width: 0.25em;\n}\n.w-2[data-v-51051e89] {\n width: 0.5em;\n}\n.w-3[data-v-51051e89] {\n width: 0.75em;\n}\n.w-4[data-v-51051e89] {\n width: 1em;\n}\n.h-4[data-v-51051e89] {\n height: 1em;\n}\n.h-1[data-v-51051e89] {\n height: 0.25em;\n}\n.h-2[data-v-51051e89] {\n height: 0.5em;\n}\n.h-3[data-v-51051e89] {\n height: 0.75em;\n}\n.fill-current[data-v-51051e89] {\n fill: currentColor;\n}\n.no-underline[data-v-51051e89] {\n text-decoration: none;\n}\n.hover\\:no-underline[data-v-51051e89]:hover {\n text-decoration: none;\n}\n.outline-none[data-v-51051e89] {\n outline: 0;\n}\n.hover\\:outline-none[data-v-51051e89] {\n outline: 0;\n}\n.hover\\:bg-grey-light[data-v-51051e89]:hover {\n background-color: #dae1e7;\n}\n.shadow-md[data-v-51051e89] {\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);\n}\n.search-input[data-v-51051e89] {\n display: block;\n width: 100%;\n padding: 0.375em 0.75em;\n font-size: 1em;\n line-height: 1.5;\n color: #495057;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid #ced4da;\n border-radius: 0.25em;\n transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;\n box-sizing: border-box;\n}\n.icons[data-v-51051e89] {\n padding: 0 1em;\n right: 0;\n top: 0;\n bottom: 0;\n fill: #606f7b;\n}\n.icons svg[data-v-51051e89] {\n width: 0.75em;\n height: 0.75em;\n}\n.single-select-wrapper[data-v-51051e89] {\n position: relative;\n margin-bottom: 0.5em;\n}\n.required[data-v-51051e89] {\n _color: #721c24;\n _background-color: #f8d7da;\n border-color: #f5c6cb;\n}\n.cursor-pointer[data-v-51051e89] {\n cursor: pointer;\n}\n.dropdown[data-v-51051e89] {\n -webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12),\n 0 2px 4px 0 rgba(0, 0, 0, 0.08);\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);\n background-color: #fff;\n color: #606f7b;\n border-radius: 0.25em;\n line-height: 1.25;\n text-align: left;\n}\n.dropdown > li[data-v-51051e89] {\n padding: 0.5em 0.75em;\n}\n.active[data-v-51051e89] {\n background: #dae1e7;\n}\n",""])},function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var o=function(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}(i),r=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[n].concat(r).concat([o]).join("\n")}return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},o=0;o<this.length;o++){var r=this[o][0];"number"==typeof r&&(i[r]=!0)}for(o=0;o<e.length;o++){var s=e[o];"number"==typeof s[0]&&i[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){"use strict";function i(e,t){for(var n=[],i={},o=0;o<t.length;o++){var r=t[o],s=r[0],a={id:e+":"+o,css:r[1],media:r[2],sourceMap:r[3]};i[s]?i[s].parts.push(a):n.push(i[s]={id:s,parts:[a]})}return n}n.r(t),n.d(t,"default",function(){return f});var o="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var r={},s=o&&(document.head||document.getElementsByTagName("head")[0]),a=null,l=0,d=!1,u=function(){},c=null,p="data-vue-ssr-id",h="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function f(e,t,n,o){d=n,c=o||{};var s=i(e,t);return v(s),function(t){for(var n=[],o=0;o<s.length;o++){var a=s[o];(l=r[a.id]).refs--,n.push(l)}t?v(s=i(e,t)):s=[];for(o=0;o<n.length;o++){var l;if(0===(l=n[o]).refs){for(var d=0;d<l.parts.length;d++)l.parts[d]();delete r[l.id]}}}}function v(e){for(var t=0;t<e.length;t++){var n=e[t],i=r[n.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](n.parts[o]);for(;o<n.parts.length;o++)i.parts.push(m(n.parts[o]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var s=[];for(o=0;o<n.parts.length;o++)s.push(m(n.parts[o]));r[n.id]={id:n.id,refs:1,parts:s}}}}function g(){var e=document.createElement("style");return e.type="text/css",s.appendChild(e),e}function m(e){var t,n,i=document.querySelector("style["+p+'~="'+e.id+'"]');if(i){if(d)return u;i.parentNode.removeChild(i)}if(h){var o=l++;i=a||(a=g()),t=x.bind(null,i,o,!1),n=x.bind(null,i,o,!0)}else i=g(),t=function(e,t){var n=t.css,i=t.media,o=t.sourceMap;i&&e.setAttribute("media",i);c.ssrId&&e.setAttribute(p,t.id);o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,i),n=function(){i.parentNode.removeChild(i)};return t(e),function(i){if(i){if(i.css===e.css&&i.media===e.media&&i.sourceMap===e.sourceMap)return;t(e=i)}else n()}}var b=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}();function x(e,t,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=b(t,o);else{var r=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}}])); |
{ | ||
"name": "vue-single-select", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "serve": "vue-cli-service serve", |
Sorry, the diff of this file is not supported yet
57897
349