@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
3 lines (2 loc) • 3.04 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("./badge-constants.cjs"),l=require("../../common/utils/index.cjs"),e=require("vue"),r=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),s=require("../icon/icon-constants.cjs"),d={compatConfig:{MODE:3},name:"DtBadge",props:{iconSize:{type:String,default:"200",validator:t=>Object.keys(s.ICON_SIZE_MODIFIERS).includes(t)},text:{type:String,default:""},kind:{type:String,default:"label",validator:t=>Object.keys(n.BADGE_KIND_MODIFIERS).includes(t)},type:{type:String,default:"default",validator:t=>Object.keys(n.BADGE_TYPE_MODIFIERS).includes(t)},decoration:{type:String,default:void 0,validator:t=>Object.keys(n.BADGE_DECORATION_MODIFIERS).includes(t)},labelClass:{type:[String,Array,Object],default:""},subtle:{type:Boolean,default:!1},outlined:{type:Boolean,default:!1}},data(){return{BADGE_TYPE_MODIFIERS:n.BADGE_TYPE_MODIFIERS,BADGE_KIND_MODIFIERS:n.BADGE_KIND_MODIFIERS,BADGE_DECORATION_MODIFIERS:n.BADGE_DECORATION_MODIFIERS}},computed:{hasLeftIcon(){return l.hasSlotContent(this.$slots.leftIcon)},hasRightIcon(){return l.hasSlotContent(this.$slots.rightIcon)},hasIcons(){return this.hasLeftIcon||this.hasRightIcon}},updated(){this.validateProps()},methods:{validateProps(){this.validateTypePropCombination(),this.validateDecorationPropCombination()},validateTypePropCombination(){this.type==="ai"&&this.kind==="count"&&console.error("DtBadge error: type: 'ai' with kind: 'count' is an invalid combination."),this.type!=="bulletin"&&this.subtle&&console.error("DtBadge error: subtle can only be used with type 'bulletin'")},validateDecorationPropCombination(){this.decoration&&((this.kind!=="label"||this.type!=="default")&&console.error("DtBadge error: decoration prop can only be used with kind: 'label' and type: 'default'."),this.hasIcons&&console.error("DtBadge error: decoration prop cannot be used with leftIcon or rightIcon."))}}},c={key:0,class:"d-badge__decorative"},u={key:1,class:"d-badge__icon-left"},_={key:2,class:"d-badge__icon-right"};function I(t,h,o,b,a,i){return e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(["d-badge",a.BADGE_TYPE_MODIFIERS[o.type],a.BADGE_KIND_MODIFIERS[o.kind],a.BADGE_DECORATION_MODIFIERS[o.decoration],{"d-badge--subtle":o.subtle},{"d-badge--outlined":o.outlined}]),"data-qa":"dt-badge"},[o.decoration?(e.openBlock(),e.createElementBlock("span",c)):e.createCommentVNode("",!0),i.hasLeftIcon?(e.openBlock(),e.createElementBlock("span",u,[e.renderSlot(t.$slots,"leftIcon",{iconSize:o.iconSize})])):e.createCommentVNode("",!0),e.createElementVNode("span",{class:e.normalizeClass(["d-badge__label",o.labelClass])},[e.renderSlot(t.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(o.text),1)])],2),i.hasRightIcon?(e.openBlock(),e.createElementBlock("span",_,[e.renderSlot(t.$slots,"rightIcon",{iconSize:o.iconSize})])):e.createCommentVNode("",!0)],2)}const D=r._(d,[["render",I]]);exports.default=D;
//# sourceMappingURL=badge.cjs.map