UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

2 lines (1 loc) 4.98 kB
this.primevue=this.primevue||{},this.primevue.rating=function(e,n,t,o,a,c,l){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=i(e),s=i(n),u=i(t),d={name:"Rating",extends:{name:"BaseRating",extends:i(a).default,props:{modelValue:{type:Number,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},stars:{type:Number,default:5},cancel:{type:Boolean,default:!0},onIcon:{type:String,default:void 0},offIcon:{type:String,default:void 0},cancelIcon:{type:String,default:void 0}},style:i(c).default,provide:function(){return{$parentInstance:this}}},emits:["update:modelValue","change","focus","blur"],data:function(){return{name:this.$attrs.name,focusedOptionIndex:-1,isFocusVisibleItem:!0}},watch:{"$attrs.name":function(e){this.name=e||o.UniqueComponentId()}},mounted:function(){this.name=this.name||o.UniqueComponentId()},methods:{getPTOptions:function(e,n){return this.ptm(e,{context:{active:n<=this.modelValue,focused:n===this.focusedOptionIndex}})},onOptionClick:function(e,n){if(!this.readonly&&!this.disabled){this.onOptionSelect(e,n),this.isFocusVisibleItem=!1;var t=o.DomHandler.getFirstFocusableElement(e.currentTarget);t&&o.DomHandler.focus(t)}},onFocus:function(e,n){this.focusedOptionIndex=n,this.$emit("focus",e)},onBlur:function(e){this.focusedOptionIndex=-1,this.$emit("blur",e)},onChange:function(e,n){this.onOptionSelect(e,n),this.isFocusVisibleItem=!0},onOptionSelect:function(e,n){this.focusedOptionIndex=n,this.updateModel(e,n||null)},updateModel:function(e,n){this.$emit("update:modelValue",n),this.$emit("change",{originalEvent:e,value:n})},cancelAriaLabel:function(){return this.$primevue.config.locale.clear},starAriaLabel:function(e){return 1===e?this.$primevue.config.locale.aria.star:this.$primevue.config.locale.aria.stars.replace(/{star}/g,e)}},components:{StarFillIcon:u.default,StarIcon:s.default,BanIcon:r.default}},p=["data-p-focused"],m=["name","checked","disabled","readonly","aria-label"],f=["onClick","data-p-active","data-p-focused"],h=["value","name","checked","disabled","readonly","aria-label","onFocus","onChange"];return d.render=function(e,n,t,o,a,c){return l.openBlock(),l.createElementBlock("div",l.mergeProps({class:e.cx("root")},e.ptm("root"),{"data-pc-name":"rating"}),[e.cancel?(l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,class:e.cx("cancelItem"),onClick:n[3]||(n[3]=function(e){return c.onOptionClick(e,0)})},c.getPTOptions("cancelItem",0),{"data-p-focused":0===a.focusedOptionIndex}),[l.createElementVNode("span",l.mergeProps({class:"p-hidden-accessible"},e.ptm("hiddenCancelInputWrapper"),{"data-p-hidden-accessible":!0}),[l.createElementVNode("input",l.mergeProps({type:"radio",value:"0",name:a.name,checked:0===e.modelValue,disabled:e.disabled,readonly:e.readonly,"aria-label":c.cancelAriaLabel(),onFocus:n[0]||(n[0]=function(e){return c.onFocus(e,0)}),onBlur:n[1]||(n[1]=function(){return c.onBlur&&c.onBlur.apply(c,arguments)}),onChange:n[2]||(n[2]=function(e){return c.onChange(e,0)})},e.ptm("hiddenCancelInput")),null,16,m)],16),l.renderSlot(e.$slots,"cancelicon",{class:l.normalizeClass(e.cx("cancelIcon"))},(function(){return[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(e.cancelIcon?"span":"BanIcon"),l.mergeProps({class:[e.cx("cancelIcon"),e.cancelIcon]},e.ptm("cancelIcon")),null,16,["class"]))]}))],16,p)):l.createCommentVNode("",!0),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(e.stars,(function(t){return l.openBlock(),l.createElementBlock("div",l.mergeProps({key:t,class:e.cx("item",{value:t}),onClick:function(e){return c.onOptionClick(e,t)}},c.getPTOptions("item",t),{"data-p-active":t<=e.modelValue,"data-p-focused":t===a.focusedOptionIndex}),[l.createElementVNode("span",l.mergeProps({class:"p-hidden-accessible"},e.ptm("hiddenItemInputWrapper"),{"data-p-hidden-accessible":!0}),[l.createElementVNode("input",l.mergeProps({type:"radio",value:t,name:a.name,checked:e.modelValue===t,disabled:e.disabled,readonly:e.readonly,"aria-label":c.starAriaLabel(t),onFocus:function(e){return c.onFocus(e,t)},onBlur:n[4]||(n[4]=function(){return c.onBlur&&c.onBlur.apply(c,arguments)}),onChange:function(e){return c.onChange(e,t)}},e.ptm("hiddenItemInput")),null,16,h)],16),t<=e.modelValue?l.renderSlot(e.$slots,"onicon",{key:0,value:t,class:l.normalizeClass(e.cx("onIcon"))},(function(){return[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(e.onIcon?"span":"StarFillIcon"),l.mergeProps({class:[e.cx("onIcon"),e.onIcon]},e.ptm("onIcon")),null,16,["class"]))]})):l.renderSlot(e.$slots,"officon",{key:1,value:t,class:l.normalizeClass(e.cx("offIcon"))},(function(){return[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(e.offIcon?"span":"StarIcon"),l.mergeProps({class:[e.cx("offIcon"),e.offIcon]},e.ptm("offIcon")),null,16,["class"]))]}))],16,f)})),128))],16)},d}(primevue.icons.ban,primevue.icons.star,primevue.icons.starfill,primevue.utils,primevue.basecomponent,primevue.rating.style,Vue);