@wikimedia/wvui
Version:
Wikimedia Vue UI (WVUI) – Wikimedia Foundation's Vue.js shared user-interface components for Wikipedia, MediaWiki, and beyond.
2 lines • 30.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue"),require("@vue/composition-api")):"function"==typeof define&&define.amd?define(["vue","@vue/composition-api"],t):"object"==typeof exports?exports.wvui=t(require("vue"),require("@vue/composition-api")):e.wvui=t(e.vue,e["@vue/composition-api"])}(this,(function(e,t){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,n),s.l=!0,s.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 s in e)n.d(i,s,function(t){return e[t]}.bind(null,s));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=26)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){"use strict";var i=n(2);n.n(i).a},function(e,t,n){"use strict";var i=n(3);n.n(i).a},function(e,t,n){"use strict";var i=n(4);n.n(i).a},function(e,t,n){"use strict";var i=n(5);n.n(i).a},function(e,t,n){"use strict";var i=n(6);n.n(i).a},function(e,t,n){"use strict";var i=n(7);n.n(i).a},function(e,t,n){"use strict";var i=n(8);n.n(i).a},function(e,t,n){"use strict";var i=n(9);n.n(i).a},function(e,t,n){"use strict";var i=n(10);n.n(i).a},function(e,t,n){"use strict";var i=n(11);n.n(i).a},function(e,t,n){"use strict";var i=n(12);n.n(i).a},function(e,t,n){"use strict";var i=n(13);n.n(i).a},function(e,t,n){"use strict";n.r(t),n.d(t,"version",(function(){return R}));var i,s;!function(e){e.Normal="normal",e.Primary="primary",e.Quiet="quiet"}(i||(i={})),function(e){e.Default="default",e.Progressive="progressive",e.Destructive="destructive"}(s||(s={}));var o=n(0),u=n.n(o),a=u.a.extend({name:"WvuiButton",props:{action:{type:String,default:s.Default,validator:function(e){return t=e,Object.keys(s).some((function(e){return s[e]===t}));var t}},type:{type:String,default:i.Normal,validator:function(e){return t=e,Object.keys(i).some((function(e){return i[e]===t}));var t}}},computed:{rootClasses:function(){return{"wvui-button--action-default":this.action===s.Default,"wvui-button--action-progressive":this.action===s.Progressive,"wvui-button--action-destructive":this.action===s.Destructive,"wvui-button--type-primary":this.type===i.Primary,"wvui-button--type-normal":this.type===i.Normal,"wvui-button--type-quiet":this.type===i.Quiet,"wvui-button--framed":this.type!==i.Quiet}}},methods:{onClick:function(e){this.$emit("click",e)}}});n(14);function r(e,t,n,i,s,o,u,a){var r,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),o&&(l._scopeId="data-v-"+o),u?(r=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__),s&&s.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(u)},l._ssrRegister=r):s&&(r=a?function(){s.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:s),r)if(l.functional){l._injectStyles=r;var c=l.render;l.render=function(e,t){return r.call(t),c(e,t)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,r):[r]}return{exports:e,options:l}}var l=r(a,(function(){var e=this,t=e.$createElement;return(e._self._c||t)("button",{staticClass:"wvui-button",class:e.rootClasses,on:{click:e.onClick}},[e._t("default")],2)}),[],!1,null,null,null).exports,c=n(1),d=n.n(c);function h(e,t){return Object(c.computed)({get:function(){return e.value},set:function(e){return t("input",e)}})}var p={type:[String,Number,Boolean,Array],default:!1};u.a.use(d.a);var f=Object(c.defineComponent)({name:"WvuiCheckbox",model:{prop:"modelValue",event:"input"},props:{modelValue:p,inputValue:{type:[String,Number,Boolean],default:!1},disabled:{type:Boolean,default:!1},indeterminate:{type:Boolean,default:!1},inline:{type:Boolean,default:!1}},setup:function(e,t){var n=t.emit,i=Object(c.computed)((function(){return{"wvui-checkbox--inline":!!e.inline}})),s=Object(c.ref)(),o=Object(c.ref)(),u=h(Object(c.toRef)(e,"modelValue"),n);return{rootClasses:i,input:s,label:o,wrappedModel:u,focusInput:function(){s.value.focus()},clickLabel:function(){o.value.click()}}}}),v=(n(15),r(f,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("label",{ref:"label",staticClass:"wvui-checkbox",class:e.rootClasses,attrs:{"aria-disabled":e.disabled},on:{click:e.focusInput,keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.preventDefault(),e.clickLabel(t))}}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.wrappedModel,expression:"wrappedModel"}],ref:"input",staticClass:"wvui-checkbox__input",attrs:{type:"checkbox",disabled:e.disabled},domProps:{value:e.inputValue,indeterminate:e.indeterminate,checked:Array.isArray(e.wrappedModel)?e._i(e.wrappedModel,e.inputValue)>-1:e.wrappedModel},on:{change:function(t){var n=e.wrappedModel,i=t.target,s=!!i.checked;if(Array.isArray(n)){var o=e.inputValue,u=e._i(n,o);i.checked?u<0&&(e.wrappedModel=n.concat([o])):u>-1&&(e.wrappedModel=n.slice(0,u).concat(n.slice(u+1)))}else e.wrappedModel=s}}}),e._v(" "),n("span",{staticClass:"wvui-checkbox__icon"}),e._v(" "),n("span",{staticClass:"wvui-checkbox__label-content"},[e._t("default")],2)])}),[],!1,null,null,null).exports);function g(e,t){var n;if("string"==typeof e)return!1;if("shouldFlipExceptions"in e){var i=null===(n=e.shouldFlipExceptions)||void 0===n?void 0:n.indexOf(t);return void 0===i||-1===i}return"shouldFlip"in e&&!!e.shouldFlip}var m=u.a.extend({name:"WvuiIcon",props:{icon:{type:[String,Object],required:!0},iconTitle:{type:[String,Object],default:""},langCode:{type:String,default:function(){return document.documentElement.lang}}},data:function(){return{dir:document.documentElement.dir}},computed:{rootClasses:function(){return{"wvui-icon--flip-for-rtl":g(this.icon,this.langCode)}},lacksTitle:function(){return!this.iconTitle},iconPath:function(){return function(e,t,n){if("string"==typeof e)return e;if("path"in e)return e.path;if("langCodeMap"in e){var i=t in e.langCodeMap?e.langCodeMap[t]:e.default;return"string"==typeof i?i:i.path}return"rtl"===n?e.rtl:e.default}(this.icon,this.langCode,this.dir)}},mounted:function(){var e=window.getComputedStyle(this.$el);this.dir=(null==e?void 0:e.direction)||this.dir},methods:{onClick:function(e){this.$emit("click",e)}}}),y=(n(16),r(m,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("span",{staticClass:"wvui-icon",class:e.rootClasses,on:{click:e.onClick}},[n("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20","aria-hidden":e.lacksTitle}},[e.iconTitle?n("title",[e._v(e._s(e.iconTitle))]):e._e(),e._v(" "),n("path",{attrs:{fill:"currentColor",d:e.iconPath}})])])}),[],!1,null,null,null).exports),w=0;function _(e){var t="wvui-"+(void 0===e?"":e+"-")+w++;return{id:Object(c.computed)((function(e){return e.$attrs.id||t})),prefixId:function(e){return(this.$attrs.id||t)+"-"+e}}}u.a.use(d.a);var b=Object(c.defineComponent)({name:"WvuiOptionsMenu",model:{prop:"selectedItemId",event:"select"},props:{items:{type:Array,required:!0,validator:function(e){if(!Array.isArray(e))return!1;for(var t={},n=0,i=e;n<i.length;n++){var s=i[n];if(t[s.id])return console.error("Duplicate item ID "+s.id),!1;t[s.id]=!0}return!0}},selectedItemId:{type:String,default:null}},setup:function(){return{prefixId:_("options-menu").prefixId}},data:function(){return{activeItemIndex:null,highlightedItemIndex:null}},computed:{activeDescendantId:function(){return null!==this.highlightedItemIndex?this.prefixId(this.items[this.highlightedItemIndex].id):this.selectedItemId?this.prefixId(this.selectedItemId):null}},watch:{items:function(){this.activeItemIndex=null,this.highlightedItemIndex=null}},methods:{itemClasses:function(e,t){return{"wvui-options-menu__item--selected":this.selectedItemId===e.id,"wvui-options-menu__item--active":this.activeItemIndex===t,"wvui-options-menu__item--highlighted":this.highlightedItemIndex===t,"wvui-options-menu__item--enabled":!e.disabled,"wvui-options-menu__item--disabled":!!e.disabled}},onItemMousedown:function(e,t){var n=this;if(!e.disabled){this.activeItemIndex=t;var i=function(){n.activeItemIndex=null,document.documentElement.removeEventListener("mouseup",i)};document.documentElement.addEventListener("mouseup",i)}},onItemClick:function(e){e.disabled||(this.$emit("select",e.id),this.highlightedItemIndex=null)},getSelectedItemIndex:function(){if(null===this.selectedItemId)return null;for(var e=-1,t=0;t<this.items.length;t++)this.items[t].id===this.selectedItemId&&(e=t);return-1===e?null:e},moveHighlight:function(e){var t=this;if(0!==this.items.length){var n,i="backward"===e?-1:1,s=function(e){return(e+i+t.items.length)%t.items.length};if(null===this.highlightedItemIndex){var o=this.getSelectedItemIndex();n=null===o?0:s(o)}else n=s(this.highlightedItemIndex);var u=n;if(this.items[u].disabled){for(u=s(u);this.items[u].disabled&&u!==n;)u=s(u);this.items[u].disabled&&(u=null)}this.highlightedItemIndex=u}},selectHighlightedItem:function(){null!==this.highlightedItemIndex&&(this.$emit("select",this.items[this.highlightedItemIndex].id),this.highlightedItemIndex=null)},handleKeyboardEvent:function(e){"Enter"===e.key?this.selectHighlightedItem():"ArrowUp"===e.key?this.moveHighlight("backward"):"ArrowDown"===e.key&&this.moveHighlight("forward")}}}),I=b,x=(n(17),r(I,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("ul",{staticClass:"wvui-options-menu",attrs:{role:"listbox","aria-activedescendant":e.activeDescendantId}},e._l(e.items,(function(t,i){return n("li",{key:t.id,staticClass:"wvui-options-menu__item",class:e.itemClasses(t,i),attrs:{id:e.prefixId(t.id),role:"option","aria-disabled":!!t.disabled||null,"aria-selected":e.selectedItemId===t.id},on:{click:function(n){return e.onItemClick(t)},mousedown:function(n){return n.preventDefault(),e.onItemMousedown(t,i)}}},[e._t("default",[e._v("\n\t\t\t"+e._s(t.label)+"\n\t\t")],{item:t})],2)})),0)}),[],!1,null,null,null)),C=x.exports;u.a.use(d.a);var k,S=Object(c.defineComponent)({name:"WvuiDropdown",components:{WvuiIcon:y,WvuiOptionsMenu:C},model:{prop:"selectedItemId",event:"change"},props:{items:{type:Array,required:!0},selectedItemId:{type:String,default:null},defaultLabel:{type:String,default:""},disabled:{type:Boolean,default:!1}},setup:function(){return{prefixId:_("dropdown").prefixId}},data:function(){return{wvuiIconExpand:"M17.5 4.75l-7.5 7.5-7.5-7.5L1 6.25l9 9 9-9z",showMenu:!1}},computed:{wrappedModel:{get:function(){return this.selectedItemId},set:function(e){this.$emit("change",e)}},rootClasses:function(){return{"wvui-dropdown--disabled":this.disabled,"wvui-dropdown--open":this.showMenu,"wvui-dropdown--value-selected":null!==this.selectedItemId,"wvui-dropdown--no-selections":null===this.selectedItemId}},menuId:function(){return this.prefixId("menu")},itemsById:function(){for(var e={},t=0,n=this.items;t<n.length;t++){var i=n[t];e[i.id]=i}return e},selectedItem:function(){return null!==this.selectedItemId&&this.itemsById[this.selectedItemId]||null}},methods:{onKeyNavigation:function(e){if(!this.disabled){var t=this.showMenu;(this.showMenu||(this.showMenu=!0,"Enter"!==e.key))&&(this.$refs.menu.handleKeyboardEvent(e),"Enter"===e.key&&t&&(this.showMenu=!1))}},onClick:function(){this.disabled||(this.showMenu=!this.showMenu,this.$refs.handle.focus())}}}),M=(n(18),r(S,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"wvui-dropdown",class:e.rootClasses},[n("div",{ref:"handle",staticClass:"wvui-dropdown__handle",attrs:{tabindex:"0",role:"combobox","aria-autocomplete":"list","aria-owns":e.menuId,"aria-haspopup":"listbox","aria-disabled":e.disabled?"true":null,"aria-expanded":e.showMenu?"true":"false"},on:{mousedown:function(e){e.preventDefault()},click:e.onClick,blur:function(t){e.showMenu=!1},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),t.stopPropagation(),e.onKeyNavigation(t))},function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"]))return null;t.preventDefault(),t.stopPropagation(),e.showMenu=!1}]}},[e._t("selectedItem",[e._v("\n\t\t\t"+e._s(e.selectedItem?e.selectedItem.label:e.defaultLabel)+"\n\t\t")],{item:e.selectedItem,defaultLabel:e.defaultLabel}),e._v(" "),n("wvui-icon",{staticClass:"wvui-dropdown__indicator",attrs:{icon:e.wvuiIconExpand}})],2),e._v(" "),n("wvui-options-menu",{directives:[{name:"show",rawName:"v-show",value:e.showMenu,expression:"showMenu"}],ref:"menu",staticClass:"wvui-dropdown__menu",attrs:{id:e.menuId,items:e.items},on:{select:function(t){e.showMenu=!1}},scopedSlots:e._u([{key:"default",fn:function(t){var n=t.item;return[e._t("menuItem",null,{item:n})]}}],null,!0),model:{value:e.wrappedModel,callback:function(t){e.wrappedModel=t},expression:"wrappedModel"}})],1)}),[],!1,null,null,null).exports);!function(e){e.Text="text",e.Search="search"}(k||(k={}));var O=u.a.extend({name:"WvuiInput",components:{WvuiIcon:y},inheritAttrs:!1,props:{value:{type:[String,Number],default:""},type:{type:String,default:k.Text,validator:function(e){return t=e,Object.keys(k).some((function(e){return k[e]===t}));var t}},disabled:{type:Boolean,default:!1},startIcon:{type:[String,Object],default:void 0},endIcon:{type:[String,Object],default:void 0},clearable:{type:Boolean,default:!1}},data:function(){return{newValue:this.value,clearIcon:"M10 0a10 10 0 1010 10A10 10 0 0010 0zm5.66 14.24l-1.41 1.41L10 11.41l-4.24 4.25-1.42-1.42L8.59 10 4.34 5.76l1.42-1.42L10 8.59l4.24-4.24 1.41 1.41L11.41 10z"}},computed:{isClearable:function(){return this.clearable&&!!this.computedValue&&!this.disabled},rootClasses:function(){return{"wvui-input--has-start-icon":!!this.startIcon,"wvui-input--has-end-icon":!!this.endIcon||this.clearable,"wvui-input--clearable":this.clearable}},computedValue:{get:function(){return this.newValue},set:function(e){this.newValue=e,this.$emit("input",e)}}},watch:{value:function(e){this.newValue=e}},methods:{onInput:function(e){var t=e.target.value;this.setCurrentValue(t)},onChange:function(e){this.$emit("change",e)},onFocus:function(e){this.$emit("focus",e)},onBlur:function(e){this.$emit("blur",e)},onEndIconClick:function(){this.clearable&&(this.setCurrentValue(""),this.$emit("input",""))},setCurrentValue:function(e){this.computedValue=e}}}),E=(n(19),r(O,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"wvui-input",class:e.rootClasses},[n("input",e._b({ref:"input",staticClass:"wvui-input__input",attrs:{disabled:e.disabled,type:e.type},domProps:{value:e.computedValue},on:{input:e.onInput,change:e.onChange,focus:e.onFocus,blur:e.onBlur}},"input",e.$attrs,!1)),e._v(" "),e.startIcon?n("wvui-icon",{staticClass:"wvui-input__start-icon",attrs:{icon:e.startIcon}}):e._e(),e._v(" "),e.isClearable||e.endIcon?n("wvui-icon",{staticClass:"wvui-input__end-icon",attrs:{icon:e.endIcon||e.clearIcon},on:{click:e.onEndIconClick}}):e._e()],1)}),[],!1,null,null,null).exports),A=u.a.extend({name:"WvuiProgressBar"}),D=(n(20),r(A,(function(){var e=this,t=e.$createElement;e._self._c;return e._m(0)}),[function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"wvui-progress-bar",attrs:{role:"progressbar","aria-valuemin":"0","aria-valuemax":"100"}},[t("div",{staticClass:"wvui-progress-bar__bar"})])}],!1,null,null,null).exports);u.a.use(d.a);var $=Object(c.defineComponent)({name:"WvuiRadio",model:{prop:"modelValue",event:"input"},props:{modelValue:p,inputValue:{type:[String,Number,Boolean],default:!1},disabled:{type:Boolean,default:!1},name:{type:String,default:""},inline:{type:Boolean,default:!1}},setup:function(e,t){var n=t.emit,i=Object(c.computed)((function(){return{"wvui-radio--inline":!!e.inline}})),s=Object(c.ref)(),o=h(Object(c.toRef)(e,"modelValue"),n);return{rootClasses:i,input:s,focusInput:function(){s.value.focus()},wrappedModel:o}}}),T=(n(21),r($,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("label",{staticClass:"wvui-radio",class:e.rootClasses,attrs:{"aria-disabled":e.disabled},on:{click:e.focusInput}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.wrappedModel,expression:"wrappedModel"}],ref:"input",staticClass:"wvui-radio__input",attrs:{type:"radio",name:e.name,disabled:e.disabled},domProps:{value:e.inputValue,checked:e._q(e.wrappedModel,e.inputValue)},on:{change:function(t){e.wrappedModel=e.inputValue}}}),e._v(" "),n("span",{staticClass:"wvui-radio__icon"}),e._v(" "),n("span",{staticClass:"wvui-radio__label-content"},[e._t("default")],2)])}),[],!1,null,null,null).exports),V=u.a.extend({name:"WvuiToggleButton",props:{isActive:{type:Boolean,required:!0}},computed:{rootClasses:function(){return{"wvui-toggle-button--active":this.isActive,"wvui-toggle-button--inactive":!this.isActive}}},methods:{onClick:function(){this.$emit("change",!this.isActive)}}}),j=(n(22),r(V,(function(){var e=this,t=e.$createElement;return(e._self._c||t)("button",{staticClass:"wvui-toggle-button",class:e.rootClasses,attrs:{"aria-pressed":e.isActive},on:{mousedown:function(e){e.preventDefault()},click:e.onClick}},[e._t("default")],2)}),[],!1,null,null,null).exports);var B=u.a.extend({name:"WvuiTypeaheadSuggestionTitle",props:{query:{type:String,default:""},title:{type:String,required:!0},highlightQuery:{type:Boolean,default:!0}},computed:{titleChunks:function(){return this.highlightQuery?function(e,t){if(!e)return[t,"",""];var n=e.replace(/([\\{}()|.?*+\-^$[\]])/g,"\\$1"),i=t.match(new RegExp(n+"[̀-ͯ҃-҉֑-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࣓-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣ৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఀ-ఄా-ౄె-ైొ-్ౕౖౢౣಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝᠋-᠍ᢅᢆᢩᤠ-ᤫᤰ-᤻ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼᪰-᪾ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-ᮭ᯦-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿⃐-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯-꙲ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣠-꣱ꣿꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꧥꨩ-ꨶꩃꩌꩍꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭ﬞ︀-️︠-︯]*","i"));if(!i||void 0===i.index)return[t,"",""];var s=i.index,o=s+i[0].length,u=t.substring(s,o);return[t.substring(0,s),u,t.substring(o,t.length)]}(this.query,this.title):["",this.title,""]}}}),L=(n(23),r(B,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("span",{staticClass:"wvui-typeahead-suggestion__title"},[e._v("\n\t"+e._s(e.titleChunks[0])),n("span",{staticClass:"wvui-typeahead-suggestion__match"},[e._v(e._s(e.titleChunks[1]))]),e._v(e._s(e.titleChunks[2])+"\n")])}),[],!1,null,null,null).exports),W=function(){return(W=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function q(){return{generateUrl:function(e,t,n){return void 0===t&&(t={title:"Special:Search"}),void 0===n&&(n="/w/index.php"),"string"!=typeof e?e=e.title:t.fulltext="1",n+"?"+(i=W(W({},t),{search:e}),Object.keys(i).map((function(e){return e+"="+encodeURIComponent(i[e])})).join("&"));var i}}}var P=u.a.extend({name:"WvuiTypeaheadSuggestion",components:{WvuiTypeaheadSuggestionTitle:L,WvuiIcon:y},props:{active:{type:Boolean,default:!1},articlePath:{type:String,default:"/w/index.php"},query:{type:String,default:""},suggestion:{type:Object,required:!0},searchPageTitle:{type:String,default:"Special:Search"},urlGenerator:{type:Object,default:q},showThumbnail:{type:Boolean,default:!0},showDescription:{type:Boolean,default:!0},highlightQuery:{type:Boolean,default:!0}},data:function(){return{defaultThumbnailIcon:"M19 3H1v14h18zM3 14l3.5-4.5 2.5 3L12.5 8l4.5 6z"}},computed:{rootClasses:function(){return{"wvui-typeahead-suggestion--active":this.active}},suggestionWikiLink:function(){return this.urlGenerator.generateUrl(this.suggestion,{title:this.searchPageTitle},this.articlePath)},thumbnailBackgroundImage:function(){var e;return"url("+(null===(e=this.suggestion.thumbnail)||void 0===e?void 0:e.url)+")"}},methods:{onMouseOver:function(e){this.$emit("mouseover",e)},onMouseDown:function(e){this.$emit("mousedown",e)},onClick:function(e){this.$emit("click",e)}}}),F=(n(24),r(P,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.suggestion?n("a",{staticClass:"wvui-typeahead-suggestion",class:e.rootClasses,attrs:{href:e.suggestionWikiLink},on:{mouseover:e.onMouseOver,mousedown:e.onMouseDown,click:e.onClick}},[e.showThumbnail&&e.suggestion.thumbnail?n("span",{staticClass:"wvui-typeahead-suggestion__thumbnail",style:{backgroundImage:e.thumbnailBackgroundImage}}):e.showThumbnail?n("span",{staticClass:"wvui-typeahead-suggestion__thumbnail-placeholder"},[n("wvui-icon",{staticClass:"wvui-typeahead-suggestion__thumbnail-icon",attrs:{icon:e.defaultThumbnailIcon}})],1):e._e(),e._v(" "),n("span",{staticClass:"wvui-typeahead-suggestion__text"},[n("wvui-typeahead-suggestion-title",{attrs:{query:e.query,title:e.suggestion.title,"highlight-query":e.highlightQuery}}),e._v(" "),e.showDescription&&e.suggestion.description?n("span",{staticClass:"wvui-typeahead-suggestion__description"},[e._v(e._s(e.suggestion.description))]):e._e()],1)]):e._e()}),[],!1,null,null,null).exports),Q=u.a.extend({name:"WvuiTypeaheadSearch",components:{WvuiTypeaheadSuggestion:F,WvuiButton:l,WvuiInput:E,WvuiIcon:y},inheritAttrs:!1,props:{initialInputValue:{type:String,default:""},buttonLabel:{type:String,required:!0},formAction:{type:String,required:!0},client:{type:Object,required:!0},urlGenerator:{type:Object,default:function(){return q()}},domain:{type:String,default:"en.wikipedia.org"},searchPageTitle:{type:String,default:"Special:Search"},suggestionsLabel:{type:String,required:!0},focused:{type:Boolean,default:!1},id:{type:String,required:!0},showThumbnail:{type:Boolean,default:!0},showDescription:{type:Boolean,default:!0},highlightQuery:{type:Boolean,default:!0},autoExpandWidth:{type:Boolean,default:!1}},data:function(){return{startIcon:"M12.2 13.6a7 7 0 111.4-1.4l5.4 5.4-1.4 1.4-5.4-5.4zM3 8a5 5 0 1010 0A5 5 0 103 8z",articleIcon:"M12.43 14.34A5 5 0 0110 15a5 5 0 113.95-2L17 16.09V3a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 001.45-.63z M13 10 A3 3 0 0 1 10 13 A3 3 0 0 1 7 10 A3 3 0 0 1 13 10 z",isHovered:!1,suggestionActiveIndex:-1,suggestionsList:[],isFocused:this.focused,searchQuery:"",inputValue:this.initialInputValue,InputType:k,isExpanded:!1,request:null,debounceId:null}},computed:{rootClasses:function(){return{"wvui-typeahead-search--active":this.isHovered,"wvui-typeahead-search--focused":this.isFocused,"wvui-typeahead-search--has-value":!!this.searchQuery,"wvui-typeahead-search--expanded":this.isExpanded,"wvui-typeahead-search--show-thumbnail":this.showThumbnail,"wvui-typeahead-search--auto-expand-width":this.showThumbnail&&this.autoExpandWidth,"wvui-typeahead-search--full-width":this.showThumbnail&&!this.autoExpandWidth}},footerClasses:function(){return{"wvui-typeahead-search__suggestions__footer--active":this.isFooterActive}},footerUrl:function(){return this.urlGenerator.generateUrl(this.searchQuery,{title:this.searchPageTitle},this.formAction)},isFooterActive:function(){return this.suggestionActiveIndex===this.suggestionsList.length},suggestionsId:function(){return this.id+"-suggestions"},activeSuggestionId:function(){return this.isExpanded?this.suggestionActiveIndex<0||this.suggestionActiveIndex>this.suggestionsList.length?"":this.isFooterActive?this.footerId:this.getSuggestionId(this.suggestionsList[this.suggestionActiveIndex]):""},footerId:function(){return this.suggestionsId+"-footer"},isExpandedString:function(){return this.isExpanded?"true":"false"}},mounted:function(){this.initialInputValue&&this.onInput(this.initialInputValue)},methods:{isSuggestionSelected:function(e){var t=this.suggestionsList[e].title;return this.inputValue.toLowerCase()===t.toLowerCase()&&!this.isFooterActive?"true":"false"},updateSuggestions:function(e,t){this.searchQuery=e,this.suggestionsList=t,this.suggestionActiveIndex=-1,this.isExpanded=!!this.searchQuery&&this.isFocused},clearSuggestions:function(){this.updateSuggestions("",[])},onInput:function(e){var t=this;this.inputValue=e,this.debounceId&&clearTimeout(this.debounceId),this.debounceId=setTimeout((function(){t.inputValue=e;var n=e.trim();t.request&&t.request.abort(),n?(t.$emit("fetch-start"),t.request=t.client.fetchByTitle(e,t.domain),t.request.fetch.then((function(e){var i=e.results;t.updateSuggestions(n,i);var s={numberOfResults:i.length,query:n};t.$emit("fetch-end",s)})).catch((function(){}))):t.clearSuggestions()}),120)},onSuggestionMouseOver:function(e){this.suggestionActiveIndex=e},onInputFocus:function(){this.isHovered=!0,this.isFocused=!0,this.isExpanded=!!this.searchQuery},onInputBlur:function(){this.isFocused=!1,this.isHovered=!1,this.isExpanded=!1},onFooterHover:function(){this.suggestionActiveIndex=this.suggestionsList.length},onRootMouseOver:function(){this.isHovered=!0},onRootMouseOut:function(){this.isHovered=this.isFocused,this.suggestionActiveIndex=-1},onSuggestionMouseDown:function(e){e.preventDefault()},onSuggestionClick:function(e){var t={index:this.suggestionActiveIndex,numberOfResults:this.suggestionsList.length};this.inputValue=e?e.title:this.searchQuery,this.updateSuggestions(this.inputValue,[]),this.isFocused=!0,this.isExpanded=!1,this.$emit("suggestion-click",t)},onKeyDownUp:function(e){this.handleKeyUpDown(e,-1)},onKeyDownDown:function(e){this.handleKeyUpDown(e,1)},handleKeyUpDown:function(e,t){this.isFocused&&this.isExpanded&&(e.preventDefault(),this.nudgeActiveSuggestion(t))},nudgeActiveSuggestion:function(e){var t=this.suggestionActiveIndex;(t+=e)<-1?t=this.suggestionsList.length:t>this.suggestionsList.length+1&&(t=0),this.suggestionActiveIndex=t;var n=this.suggestionsList[t];this.inputValue=n?n.title:this.searchQuery},onKeyDownEscape:function(e){e.preventDefault(),this.isExpanded=!1},getSuggestionId:function(e){return"wvui-typeahead-search-suggestion-"+e.id},onSubmit:function(e){this.suggestionActiveIndex===this.suggestionsList.length&&(e.preventDefault(),window.location.assign(this.footerUrl));var t={index:this.suggestionActiveIndex,numberOfResults:this.suggestionsList.length};this.$emit("submit",t)}}}),U=(n(25),r(Q,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"wvui-typeahead-search",class:e.rootClasses,attrs:{role:"combobox","aria-expanded":e.isExpandedString,"aria-haspopup":"listbox","aria-owns":e.suggestionsId},on:{mouseover:e.onRootMouseOver,mouseout:e.onRootMouseOut,keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:e.onKeyDownUp(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:e.onKeyDownDown(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"escape",void 0,t.key,void 0)?null:e.onKeyDownEscape(t)}]}},[n("form",{staticClass:"wvui-typeahead-search__form",attrs:{id:e.id,action:e.formAction},on:{submit:e.onSubmit}},[n("div",{staticClass:"wvui-typeahead-search__wrapper"},[n("wvui-input",e._b({staticClass:"wvui-typeahead-search__input",attrs:{"start-icon":e.startIcon,value:e.inputValue,type:e.InputType.Search,name:"search",autocapitalize:"off",autocomplete:"off","aria-autocomplete":"list","aria-controls":e.suggestionsId,"aria-activedescendant":e.activeSuggestionId},on:{input:e.onInput,blur:e.onInputBlur,focus:e.onInputFocus}},"wvui-input",e.$attrs,!1)),e._v(" "),e._t("default"),e._v(" "),n("ol",{staticClass:"wvui-typeahead-search__suggestions",attrs:{id:e.suggestionsId,role:"listbox","aria-label":e.suggestionsLabel}},[e._l(e.suggestionsList,(function(t,i){return n("li",{key:i,attrs:{role:"option","aria-selected":e.isSuggestionSelected(i)}},[n("wvui-typeahead-suggestion",{key:t.id,staticClass:"wvui-typeahead-search__suggestion",attrs:{id:e.getSuggestionId(t),"search-page-title":e.searchPageTitle,"article-path":e.formAction,query:e.searchQuery,active:e.suggestionActiveIndex===i,suggestion:t,"show-thumbnail":e.showThumbnail,"show-description":e.showDescription,"highlight-query":e.highlightQuery},on:{mouseover:function(t){return e.onSuggestionMouseOver(i)},mousedown:e.onSuggestionMouseDown,click:function(n){return e.onSuggestionClick(t)}}})],1)})),e._v(" "),n("li",{attrs:{role:"option"}},[n("a",{ref:"footer",staticClass:"wvui-typeahead-search__suggestions__footer",class:e.footerClasses,attrs:{id:e.footerId,tabindex:"-1",href:e.footerUrl},on:{mouseover:e.onFooterHover,mousedown:e.onSuggestionMouseDown,click:function(t){return e.onSuggestionClick()}}},[n("wvui-icon",{staticClass:"wvui-typeahead-search__suggestions__footer__icon",attrs:{icon:e.articleIcon}}),e._v(" "),n("span",{staticClass:"wvui-typeahead-search__suggestions__footer__text"},[e._t("search-footer-text",[n("strong",{staticClass:"wvui-typeahead-search__suggestions__footer__text__query"},[e._v("\n\t\t\t\t\t\t\t\t\t"+e._s(e.searchQuery)+"\n\t\t\t\t\t\t\t\t")])],{searchQuery:e.searchQuery})],2)],1)])],2)],2),e._v(" "),n("wvui-button",{staticClass:"wvui-typeahead-search__submit"},[e._v("\n\t\t\t"+e._s(e.buttonLabel)+"\n\t\t")])],1)])}),[],!1,null,null,null).exports),R="0.4.0";t.default={WvuiButton:l,WvuiCheckbox:v,WvuiDropdown:M,WvuiInput:E,WvuiIcon:y,WvuiOptionsMenu:C,WvuiProgressBar:D,WvuiRadio:T,WvuiToggleButton:j,WvuiTypeaheadSearch:U,WvuiTypeaheadSuggestion:F}}])}));
//# sourceMappingURL=wvui.js.map.json