UNPKG

primeng

Version:

PrimeNG is an open source UI library for Angular 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 PrimeB

304 lines (291 loc) 10.9 kB
import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { Injectable, inject, booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, ContentChild, ContentChildren, NgModule } from '@angular/core'; import { PrimeTemplate, SharedModule } from 'primeng/api'; import { BaseComponent } from 'primeng/basecomponent'; import { BaseStyle } from 'primeng/base'; const theme = ({ dt }) => ` .p-tag { display: inline-flex; align-items: center; justify-content: center; background: ${dt('tag.primary.background')}; color: ${dt('tag.primary.color')}; font-size: ${dt('tag.font.size')}; font-weight: ${dt('tag.font.weight')}; padding: ${dt('tag.padding')}; border-radius: ${dt('tag.border.radius')}; gap: ${dt('tag.gap')}; } .p-tag-icon { font-size: ${dt('tag.icon.size')}; width: ${dt('tag.icon.size')}; height:${dt('tag.icon.size')}; } .p-tag-rounded { border-radius: ${dt('tag.rounded.border.radius')}; } .p-tag-success { background: ${dt('tag.success.background')}; color: ${dt('tag.success.color')}; } .p-tag-info { background: ${dt('tag.info.background')}; color: ${dt('tag.info.color')}; } .p-tag-warn { background: ${dt('tag.warn.background')}; color: ${dt('tag.warn.color')}; } .p-tag-danger { background: ${dt('tag.danger.background')}; color: ${dt('tag.danger.color')}; } .p-tag-secondary { background: ${dt('tag.secondary.background')}; color: ${dt('tag.secondary.color')}; } .p-tag-contrast { background: ${dt('tag.contrast.background')}; color: ${dt('tag.contrast.color')}; } `; const classes = { root: ({ props }) => [ 'p-tag p-component', { 'p-tag-info': props.severity === 'info', 'p-tag-success': props.severity === 'success', 'p-tag-warn': props.severity === 'warn', 'p-tag-danger': props.severity === 'danger', 'p-tag-secondary': props.severity === 'secondary', 'p-tag-contrast': props.severity === 'contrast', 'p-tag-rounded': props.rounded } ], icon: 'p-tag-icon', label: 'p-tag-label' }; class TagStyle extends BaseStyle { name = 'tag'; theme = theme; classes = classes; static ɵfac = /*@__PURE__*/ (() => { let ɵTagStyle_BaseFactory; return function TagStyle_Factory(__ngFactoryType__) { returnTagStyle_BaseFactory || (ɵTagStyle_BaseFactory = i0.ɵɵgetInheritedFactory(TagStyle)))(__ngFactoryType__ || TagStyle); }; })(); static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TagStyle, factory: TagStyle.ɵfac }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TagStyle, [{ type: Injectable }], null, null); })(); /** * * Tag component is used to categorize content. * * [Live Demo](https://www.primeng.org/tag) * * @module tagstyle * */ var TagClasses; (function (TagClasses) { /** * Class name of the root element */ TagClasses["root"] = "p-tag"; /** * Class name of the icon element */ TagClasses["icon"] = "p-tag-icon"; /** * Class name of the label element */ TagClasses["label"] = "p-tag-label"; })(TagClasses || (TagClasses = {})); const _c0 = ["icon"]; const _c1 = ["*"]; function Tag_ng_container_1_span_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelement(0, "span", 4); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(2); i0.ɵɵproperty("ngClass", ctx_r0.icon); } } function Tag_ng_container_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainerStart(0); i0.ɵɵtemplate(1, Tag_ng_container_1_span_1_Template, 1, 1, "span", 3); i0.ɵɵelementContainerEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx_r0.icon); } } function Tag_span_2_1_ng_template_0_Template(rf, ctx) { } function Tag_span_2_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵtemplate(0, Tag_span_2_1_ng_template_0_Template, 0, 0, "ng-template"); } } function Tag_span_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "span", 5); i0.ɵɵtemplate(1, Tag_span_2_1_Template, 1, 0, null, 6); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.iconTemplate || ctx_r0._iconTemplate); } } /** * Tag component is used to categorize content. * @group Components */ class Tag extends BaseComponent { /** * Inline style of the component. * @group Props */ get style() { return this._style; } set style(value) { this._style = value; this.cd.markForCheck(); } /** * Style class of the component. * @group Props */ styleClass; /** * Severity type of the tag. * @group Props */ severity; /** * Value to display inside the tag. * @group Props */ value; /** * Icon of the tag to display next to the value. * @group Props */ icon; /** * Whether the corners of the tag are rounded. * @group Props */ rounded; iconTemplate; templates; _iconTemplate; _style; _componentStyle = inject(TagStyle); ngAfterContentInit() { this.templates?.forEach((item) => { switch (item.getType()) { case 'icon': this._iconTemplate = item.template; break; } }); } containerClass() { let classes = 'p-tag p-component'; if (this.severity) { classes += ` p-tag-${this.severity}`; } if (this.rounded) { classes += ' p-tag-rounded'; } if (this.styleClass) { classes += ` ${this.styleClass}`; } return classes; } static ɵfac = /*@__PURE__*/ (() => { let ɵTag_BaseFactory; return function Tag_Factory(__ngFactoryType__) { returnTag_BaseFactory || (ɵTag_BaseFactory = i0.ɵɵgetInheritedFactory(Tag)))(__ngFactoryType__ || Tag); }; })(); static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Tag, selectors: [["p-tag"]], contentQueries: function Tag_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) { i0.ɵɵcontentQuery(dirIndex, _c0, 4); i0.ɵɵcontentQuery(dirIndex, PrimeTemplate, 4); } if (rf & 2) { let _t; i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.iconTemplate = _t.first); i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.templates = _t); } }, hostVars: 4, hostBindings: function Tag_HostBindings(rf, ctx) { if (rf & 2) { i0.ɵɵstyleMap(ctx.style); i0.ɵɵclassMap(ctx.containerClass()); } }, inputs: { style: "style", styleClass: "styleClass", severity: "severity", value: "value", icon: "icon", rounded: [2, "rounded", "rounded", booleanAttribute] }, features: [i0.ɵɵProvidersFeature([TagStyle]), i0.ɵɵInputTransformsFeature, i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c1, decls: 5, vars: 3, consts: [[4, "ngIf"], ["class", "p-tag-icon", 4, "ngIf"], [1, "p-tag-label"], ["class", "p-tag-icon", 3, "ngClass", 4, "ngIf"], [1, "p-tag-icon", 3, "ngClass"], [1, "p-tag-icon"], [4, "ngTemplateOutlet"]], template: function Tag_Template(rf, ctx) { if (rf & 1) { i0.ɵɵprojectionDef(); i0.ɵɵprojection(0); i0.ɵɵtemplate(1, Tag_ng_container_1_Template, 2, 1, "ng-container", 0)(2, Tag_span_2_Template, 2, 1, "span", 1); i0.ɵɵelementStart(3, "span", 2); i0.ɵɵtext(4); i0.ɵɵelementEnd(); } if (rf & 2) { i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", !ctx.iconTemplate && !ctx._iconTemplate); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.iconTemplate || ctx._iconTemplate); i0.ɵɵadvance(2); i0.ɵɵtextInterpolate(ctx.value); } }, dependencies: [CommonModule, i1.NgClass, i1.NgIf, i1.NgTemplateOutlet, SharedModule], encapsulation: 2, changeDetection: 0 }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Tag, [{ type: Component, args: [{ selector: 'p-tag', standalone: true, imports: [CommonModule, SharedModule], template: ` <ng-content></ng-content> <ng-container *ngIf="!iconTemplate && !_iconTemplate"> <span class="p-tag-icon" [ngClass]="icon" *ngIf="icon"></span> </ng-container> <span class="p-tag-icon" *ngIf="iconTemplate || _iconTemplate"> <ng-template *ngTemplateOutlet="iconTemplate || _iconTemplate"></ng-template> </span> <span class="p-tag-label">{{ value }}</span> `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [TagStyle], host: { '[class]': 'containerClass()', '[style]': 'style' } }] }], null, { style: [{ type: Input }], styleClass: [{ type: Input }], severity: [{ type: Input }], value: [{ type: Input }], icon: [{ type: Input }], rounded: [{ type: Input, args: [{ transform: booleanAttribute }] }], iconTemplate: [{ type: ContentChild, args: ['icon', { descendants: false }] }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Tag, { className: "Tag", filePath: "tag.ts", lineNumber: 33 }); })(); class TagModule { static ɵfac = function TagModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TagModule)(); }; static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TagModule }); static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [Tag, SharedModule, SharedModule] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TagModule, [{ type: NgModule, args: [{ imports: [Tag, SharedModule], exports: [Tag, SharedModule] }] }], null, null); })(); (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TagModule, { imports: [Tag, SharedModule], exports: [Tag, SharedModule] }); })(); /** * Generated bundle index. Do not edit. */ export { Tag, TagClasses, TagModule, TagStyle }; //# sourceMappingURL=primeng-tag.mjs.map