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

1 lines 6.79 kB
{"version":3,"file":"index.mjs","sources":["../../src/badgedirective/BaseBadgeDirective.js","../../src/badgedirective/BadgeDirective.js"],"sourcesContent":["import BaseDirective from '@primevue/core/basedirective';\nimport BadgeDirectiveStyle from 'primevue/badgedirective/style';\n\nconst BaseBadgeDirective = BaseDirective.extend({\n style: BadgeDirectiveStyle\n});\n\nexport default BaseBadgeDirective;\n","import { addClass, createElement, hasClass, removeClass } from '@primeuix/utils/dom';\nimport { uuid } from '@primeuix/utils/uuid';\nimport BaseBadgeDirective from './BaseBadgeDirective';\n\nconst BadgeDirective = BaseBadgeDirective.extend('badge', {\n mounted(el, binding) {\n console.warn('Deprecated since v4. Use OverlayBadge component instead.');\n const id = uuid('pv_id') + '_badge';\n\n const badge = createElement('span', {\n id,\n class: !this.isUnstyled() && this.cx('root'),\n [this.$attrSelector]: '',\n 'p-bind': this.ptm('root', {\n context: {\n ...binding.modifiers,\n nogutter: String(binding.value).length === 1,\n dot: binding.value == null\n }\n })\n });\n\n el.$_pbadgeId = badge.getAttribute('id');\n\n for (let modifier in binding.modifiers) {\n !this.isUnstyled() && addClass(badge, 'p-badge-' + modifier);\n }\n\n if (binding.value != null) {\n if (typeof binding.value === 'object') el.$_badgeValue = binding.value.value;\n else el.$_badgeValue = binding.value;\n badge.appendChild(document.createTextNode(el.$_badgeValue));\n\n if (String(el.$_badgeValue).length === 1 && !this.isUnstyled()) {\n !this.isUnstyled() && addClass(badge, 'p-badge-circle');\n }\n } else {\n !this.isUnstyled() && addClass(badge, 'p-badge-dot');\n }\n\n el.setAttribute('data-pd-badge', true);\n !this.isUnstyled() && addClass(el, 'p-overlay-badge');\n el.setAttribute('data-p-overlay-badge', 'true');\n el.appendChild(badge);\n\n this.$el = badge;\n },\n updated(el, binding) {\n !this.isUnstyled() && addClass(el, 'p-overlay-badge');\n el.setAttribute('data-p-overlay-badge', 'true');\n\n if (binding.oldValue !== binding.value) {\n let badge = document.getElementById(el.$_pbadgeId);\n\n if (typeof binding.value === 'object') el.$_badgeValue = binding.value.value;\n else el.$_badgeValue = binding.value;\n\n if (!this.isUnstyled()) {\n if (el.$_badgeValue) {\n if (hasClass(badge, 'p-badge-dot')) removeClass(badge, 'p-badge-dot');\n\n if (el.$_badgeValue.length === 1) addClass(badge, 'p-badge-circle');\n else removeClass(badge, 'p-badge-circle');\n } else if (!el.$_badgeValue && !hasClass(badge, 'p-badge-dot')) {\n addClass(badge, 'p-badge-dot');\n }\n }\n\n badge.innerHTML = '';\n badge.appendChild(document.createTextNode(el.$_badgeValue));\n }\n }\n});\n\nexport default BadgeDirective;\n"],"names":["BaseBadgeDirective","BaseDirective","extend","style","BadgeDirectiveStyle","BadgeDirective","mounted","el","binding","console","warn","id","uuid","badge","createElement","_defineProperty","isUnstyled","cx","$attrSelector","ptm","context","_objectSpread","modifiers","nogutter","String","value","length","dot","$_pbadgeId","getAttribute","modifier","addClass","_typeof","$_badgeValue","appendChild","document","createTextNode","setAttribute","$el","updated","oldValue","getElementById","hasClass","removeClass","innerHTML"],"mappings":";;;;;AAGA,IAAMA,kBAAkB,GAAGC,aAAa,CAACC,MAAM,CAAC;AAC5CC,EAAAA,KAAK,EAAEC;AACX,CAAC,CAAC;;;;;;;;ACDF,IAAMC,cAAc,GAAGL,kBAAkB,CAACE,MAAM,CAAC,OAAO,EAAE;AACtDI,EAAAA,OAAO,WAAPA,OAAOA,CAACC,EAAE,EAAEC,OAAO,EAAE;AACjBC,IAAAA,OAAO,CAACC,IAAI,CAAC,0DAA0D,CAAC;AACxE,IAAA,IAAMC,EAAE,GAAGC,IAAI,CAAC,OAAO,CAAC,GAAG,QAAQ;IAEnC,IAAMC,KAAK,GAAGC,aAAa,CAAC,MAAM,EAAAC,eAAA,CAAAA,eAAA,CAAA;AAC9BJ,MAAAA,EAAE,EA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