primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 3.3 kB
JavaScript
this.primevue=this.primevue||{},this.primevue.tristatecheckbox=function(e,l,t,o){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=a(e),n=a(l),c=a(t),s={name:"TriStateCheckbox",extends:i.default,emits:["click","update:modelValue","change","keydown","focus","blur"],props:{modelValue:null,inputId:{type:String,default:null},inputProps:{type:null,default:null},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},data:()=>({focused:!1}),methods:{getPTOptions(e){return this.ptm(e,{context:{active:null!==this.modelValue,focused:this.focused,disabled:this.disabled}})},updateModel(){if(!this.disabled){let e;switch(this.modelValue){case!0:e=!1;break;case!1:e=null;break;default:e=!0}this.$emit("update:modelValue",e)}},onClick(e){this.updateModel(),this.$emit("click",e),this.$emit("change",e),this.$refs.input.focus()},onKeyDown(e){"Enter"===e.code&&(this.updateModel(),this.$emit("keydown",e),e.preventDefault())},onFocus(e){this.focused=!0,this.$emit("focus",e)},onBlur(e){this.focused=!1,this.$emit("blur",e)}},computed:{containerClass(){return["p-checkbox p-component",{"p-checkbox-checked":!0===this.modelValue,"p-checkbox-disabled":this.disabled,"p-checkbox-focused":this.focused}]},ariaValueLabel(){return this.modelValue?this.$primevue.config.locale.aria.trueLabel:!1===this.modelValue?this.$primevue.config.locale.aria.falseLabel:this.$primevue.config.locale.aria.nullLabel}},components:{CheckIcon:n.default,TimesIcon:c.default}};const d=["id","checked","tabindex","disabled","aria-labelledby","aria-label"];return s.render=function(e,l,t,a,i,n){return o.openBlock(),o.createElementBlock("div",o.mergeProps({class:n.containerClass,onClick:l[3]||(l[3]=e=>n.onClick(e))},e.ptm("root")),[o.createElementVNode("div",o.mergeProps({class:"p-hidden-accessible"},e.ptm("hiddenInputWrapper")),[o.createElementVNode("input",o.mergeProps({ref:"input",id:t.inputId,type:"checkbox",checked:!0===t.modelValue,tabindex:t.tabindex,disabled:t.disabled,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onKeydown:l[0]||(l[0]=e=>n.onKeyDown(e)),onFocus:l[1]||(l[1]=e=>n.onFocus(e)),onBlur:l[2]||(l[2]=e=>n.onBlur(e))},{...t.inputProps,...e.ptm("hiddenInput")}),null,16,d)],16),o.createElementVNode("span",o.mergeProps({class:"p-sr-only","aria-live":"polite"},e.ptm("srOnlyAria")),o.toDisplayString(n.ariaValueLabel),17),o.createElementVNode("div",o.mergeProps({ref:"box",class:["p-checkbox-box",{"p-highlight":null!=t.modelValue,"p-disabled":t.disabled,"p-focus":i.focused}]},n.getPTOptions("checbox")),[!0===t.modelValue?o.renderSlot(e.$slots,"checkicon",{key:0},(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent("CheckIcon"),o.mergeProps({class:"p-checkbox-icon"},e.ptm("checkIcon")),null,16))])):!1===t.modelValue?o.renderSlot(e.$slots,"uncheckicon",{key:1},(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent("TimesIcon"),o.mergeProps({class:"p-checkbox-icon"},e.ptm("uncheckIcon")),null,16))])):o.renderSlot(e.$slots,"nullableicon",{key:2},(()=>[o.createElementVNode("span",o.mergeProps({class:"p-checkbox-icon"},e.ptm("nullableIcon")),null,16)]))],16)],16)},s}(primevue.basecomponent,primevue.icons.check,primevue.icons.times,Vue);