primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 2.16 kB
JavaScript
;var e=require("vue"),n={name:"Chip",emits:["remove"],props:{label:{type:String,default:null},icon:{type:String,default:null},image:{type:String,default:null},removable:{type:Boolean,default:!1},removeIcon:{type:String,default:"pi pi-times-circle"}},data:()=>({visible:!0}),methods:{onKeydown(e){"Enter"!==e.key&&"Backspace"!==e.key||this.close(e)},close(e){this.visible=!1,this.$emit("remove",e)}},computed:{containerClass(){return["p-chip p-component",{"p-chip-image":null!=this.image}]},iconClass(){return["p-chip-icon",this.icon]},removeIconClass(){return["p-chip-remove-icon",this.removeIcon]}}};const t=["aria-label"],l=["src"],o={key:2,class:"p-chip-text"};!function(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var l=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&l.firstChild?l.insertBefore(o,l.firstChild):l.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-chip {\n display: inline-flex;\n align-items: center;\n}\n.p-chip-text {\n line-height: 1.5;\n}\n.p-chip-icon.pi {\n line-height: 1.5;\n}\n.p-chip-remove-icon {\n line-height: 1.5;\n cursor: pointer;\n}\n.p-chip img {\n border-radius: 50%;\n}\n"),n.render=function(n,i,c,a,s,r){return s.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(r.containerClass),"aria-label":c.label},[e.renderSlot(n.$slots,"default",{},(()=>[c.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.image},null,8,l)):c.icon?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(r.iconClass)},null,2)):e.createCommentVNode("",!0),c.label?(e.openBlock(),e.createElementBlock("div",o,e.toDisplayString(c.label),1)):e.createCommentVNode("",!0)])),c.removable?(e.openBlock(),e.createElementBlock("span",{key:0,tabindex:"0",class:e.normalizeClass(r.removeIconClass),onClick:i[0]||(i[0]=(...e)=>r.close&&r.close(...e)),onKeydown:i[1]||(i[1]=(...e)=>r.onKeydown&&r.onKeydown(...e))},null,34)):e.createCommentVNode("",!0)],10,t)):e.createCommentVNode("",!0)},module.exports=n;