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.7 kB
import e from"primevue/icons/check";import t from"primevue/icons/times";import n from"primevue/basecomponent";import i from"primevue/tristatecheckbox/style";import{openBlock as o,createElementBlock as l,mergeProps as a,createElementVNode as c,toDisplayString as r,renderSlot as u,normalizeClass as s,createBlock as d,resolveDynamicComponent as p}from"vue";var b={name:"TriStateCheckbox",extends:{name:"BaseTriStateCheckbox",extends:n,props:{modelValue:null,inputId:{type:String,default:null},inputProps:{type:null,default:null},disabled:{type:Boolean,default:!1},tabindex:{type:Number,default:0},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null}},style:i,provide:function(){return{$parentInstance:this}}},emits:["click","update:modelValue","change","keydown","focus","blur"],data:function(){return{focused:!1}},methods:{getPTOptions:function(e){return this.ptm(e,{context:{active:null!==this.modelValue,focused:this.focused,disabled:this.disabled}})},updateModel:function(){if(!this.disabled){var e;switch(this.modelValue){case!0:e=!1;break;case!1:e=null;break;default:e=!0}this.$emit("update:modelValue",e)}},onClick:function(e){this.updateModel(),this.$emit("click",e),this.$emit("change",e),this.$refs.input.focus()},onKeyDown:function(e){"Enter"!==e.code&&"NumpadEnter"!==e.code||(this.updateModel(),this.$emit("keydown",e),e.preventDefault())},onFocus:function(e){this.focused=!0,this.$emit("focus",e)},onBlur:function(e){this.focused=!1,this.$emit("blur",e)}},computed:{ariaValueLabel:function(){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:e,TimesIcon:t}};function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach((function(t){y(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function y(e,t,n){var i;return(t="symbol"==f(i=k(t,"string"))?i:String(i))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t){if("object"!=f(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=f(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var v=["id","checked","tabindex","disabled","aria-labelledby","aria-label"],g=["data-p-highlight","data-p-disabled","data-p-focused"];b.render=function(e,t,n,i,b,f){return o(),l("div",a({class:e.cx("root"),onClick:t[3]||(t[3]=function(e){return f.onClick(e)})},e.ptm("root"),{"data-pc-name":"tristatecheckbox"}),[c("div",a({class:"p-hidden-accessible"},e.ptm("hiddenInputWrapper"),{"data-p-hidden-accessible":!0}),[c("input",a({ref:"input",id:e.inputId,type:"checkbox",checked:!0===e.modelValue,tabindex:e.tabindex,disabled:e.disabled,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onKeydown:t[0]||(t[0]=function(e){return f.onKeyDown(e)}),onFocus:t[1]||(t[1]=function(e){return f.onFocus(e)}),onBlur:t[2]||(t[2]=function(e){return f.onBlur(e)})},h(h({},e.inputProps),e.ptm("hiddenInput"))),null,16,v)],16),c("span",a({role:"status",class:"p-hidden-accessible","aria-live":"polite"},e.ptm("hiddenValueLabel"),{"data-p-hidden-accessible":!0}),r(f.ariaValueLabel),17),c("div",a({ref:"box",class:e.cx("checkbox")},f.getPTOptions("checkbox"),{"data-p-highlight":null!=e.modelValue,"data-p-disabled":e.disabled,"data-p-focused":b.focused}),[!0===e.modelValue?u(e.$slots,"checkicon",{key:0,class:s(e.cx("checkIcon"))},(function(){return[(o(),d(p("CheckIcon"),a({class:e.cx("checkIcon")},e.ptm("checkIcon")),null,16,["class"]))]})):!1===e.modelValue?u(e.$slots,"uncheckicon",{key:1,class:s(e.cx("uncheckIcon"))},(function(){return[(o(),d(p("TimesIcon"),a({class:e.cx("uncheckIcon")},e.ptm("uncheckIcon")),null,16,["class"]))]})):u(e.$slots,"nullableicon",{key:2,class:s(e.cx("nullableIcon"))},(function(){return[c("span",a({class:e.cx("nullableIcon")},e.ptm("nullableIcon")),null,16)]}))],16,g)],16)};export{b as default};