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

385 lines (373 loc) 15.1 kB
import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { Injectable, inject, numberAttribute, 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-progressbar { position: relative; overflow: hidden; height: ${dt('progressbar.height')}; background: ${dt('progressbar.background')}; border-radius: ${dt('progressbar.border.radius')}; } .p-progressbar-value { margin: 0; background: ${dt('progressbar.value.background')}; } .p-progressbar-label { color: ${dt('progressbar.label.color')}; font-size: ${dt('progressbar.label.font.size')}; font-weight: ${dt('progressbar.label.font.weight')}; } .p-progressbar-determinate .p-progressbar-value { height: 100%; width: 0%; position: absolute; display: none; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: width 1s ease-in-out; } .p-progressbar-determinate .p-progressbar-label { display: inline-flex; } .p-progressbar-indeterminate .p-progressbar-value::before { content: ""; position: absolute; background: inherit; top: 0; inset-inline-start: 0; bottom: 0; will-change: inset-inline-start, inset-inline-end; animation: p-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite; } .p-progressbar-indeterminate .p-progressbar-value::after { content: ""; position: absolute; background: inherit; top: 0; inset-inline-start: 0; bottom: 0; will-change: inset-inline-start, inset-inline-end; animation: p-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite; animation-delay: 1.15s; } @-webkit-keyframes p-progressbar-indeterminate-anim { 0% { inset-inline-start: -35%; inset-inline-end: 100%; } 60% { inset-inline-start: 100%; inset-inline-end: -90%; } 100% { inset-inline-start: 100%; inset-inline-end: -90%; } } @keyframes p-progressbar-indeterminate-anim { 0% { inset-inline-start: -35%; inset-inline-end: 100%; } 60% { inset-inline-start: 100%; inset-inline-end: -90%; } 100% { inset-inline-start: 100%; inset-inline-end: -90%; } } @-webkit-keyframes p-progressbar-indeterminate-anim-short { 0% { inset-inline-start: -200%; inset-inline-end: 100%; } 60% { inset-inline-start: 107%; inset-inline-end: -8%; } 100% { inset-inline-start: 107%; inset-inline-end: -8%; } } @keyframes p-progressbar-indeterminate-anim-short { 0% { inset-inline-start: -200%; inset-inline-end: 100%; } 60% { inset-inline-start: 107%; inset-inline-end: -8%; } 100% { inset-inline-start: 107%; inset-inline-end: -8%; } } `; const classes = { root: ({ instance }) => [ 'p-progressbar p-component', { 'p-progressbar-determinate': instance.determinate, 'p-progressbar-indeterminate': instance.indeterminate } ], value: 'p-progressbar-value', label: 'p-progressbar-label' }; class ProgressBarStyle extends BaseStyle { name = 'progressbar'; theme = theme; classes = classes; static ɵfac = /*@__PURE__*/ (() => { let ɵProgressBarStyle_BaseFactory; return function ProgressBarStyle_Factory(__ngFactoryType__) { return (ɵProgressBarStyle_BaseFactory || (ɵProgressBarStyle_BaseFactory = i0.ɵɵgetInheritedFactory(ProgressBarStyle)))(__ngFactoryType__ || ProgressBarStyle); }; })(); static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ProgressBarStyle, factory: ProgressBarStyle.ɵfac }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProgressBarStyle, [{ type: Injectable }], null, null); })(); /** * * ProgressBar is a process status indicator. * * [Live Demo](https://www.primeng.org/progressbar) * * @module progressbarstyle * */ var ProgressBarClasses; (function (ProgressBarClasses) { /** * Class name of the root element */ ProgressBarClasses["root"] = "p-progressbar"; /** * Class name of the value element */ ProgressBarClasses["value"] = "p-progressbar-value"; /** * Class name of the label element */ ProgressBarClasses["label"] = "p-progressbar-label"; })(ProgressBarClasses || (ProgressBarClasses = {})); const _c0 = ["content"]; const _c1 = (a0, a1) => ({ "p-progressbar p-component": true, "p-progressbar-determinate": a0, "p-progressbar-indeterminate": a1 }); const _c2 = a0 => ({ $implicit: a0 }); function ProgressBar_div_1_div_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div"); i0.ɵɵtext(1); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(2); i0.ɵɵstyleProp("display", ctx_r0.value != null && ctx_r0.value !== 0 ? "flex" : "none"); i0.ɵɵattribute("data-pc-section", "label"); i0.ɵɵadvance(); i0.ɵɵtextInterpolate2("", ctx_r0.value, "", ctx_r0.unit, ""); } } function ProgressBar_div_1_ng_container_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementContainer(0); } } function ProgressBar_div_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 3)(1, "div", 4); i0.ɵɵtemplate(2, ProgressBar_div_1_div_2_Template, 2, 5, "div", 5)(3, ProgressBar_div_1_ng_container_3_Template, 1, 0, "ng-container", 6); i0.ɵɵelementEnd()(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵclassMap(ctx_r0.valueStyleClass); i0.ɵɵstyleProp("width", ctx_r0.value + "%")("background", ctx_r0.color); i0.ɵɵproperty("ngClass", "p-progressbar-value p-progressbar-value-animate"); i0.ɵɵattribute("data-pc-section", "value"); i0.ɵɵadvance(2); i0.ɵɵproperty("ngIf", ctx_r0.showValue && !ctx_r0.contentTemplate && !ctx_r0._contentTemplate); i0.ɵɵadvance(); i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.contentTemplate || ctx_r0._contentTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction1(11, _c2, ctx_r0.value)); } } function ProgressBar_div_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 7); i0.ɵɵelement(1, "div", 8); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵclassMap(ctx_r0.valueStyleClass); i0.ɵɵproperty("ngClass", "p-progressbar-indeterminate-container"); i0.ɵɵattribute("data-pc-section", "container"); i0.ɵɵadvance(); i0.ɵɵstyleProp("background", ctx_r0.color); i0.ɵɵattribute("data-pc-section", "value"); } } /** * ProgressBar is a process status indicator. * @group Components */ class ProgressBar extends BaseComponent { /** * Current value of the progress. * @group Props */ value; /** * Whether to display the progress bar value. * @group Props */ showValue = true; /** * Style class of the element. * @group Props */ styleClass; /** * Style class of the value element. * @group Props */ valueStyleClass; /** * Inline style of the element. * @group Props */ style; /** * Unit sign appended to the value. * @group Props */ unit = '%'; /** * Defines the mode of the progress * @group Props */ mode = 'determinate'; /** * Color for the background of the progress. * @group Props */ color; /** * Template of the content. * @group templates */ contentTemplate; _componentStyle = inject(ProgressBarStyle); templates; _contentTemplate; ngAfterContentInit() { this.templates?.forEach((item) => { switch (item.getType()) { case 'content': this._contentTemplate = item.template; break; default: this._contentTemplate = item.template; } }); } static ɵfac = /*@__PURE__*/ (() => { let ɵProgressBar_BaseFactory; return function ProgressBar_Factory(__ngFactoryType__) { return (ɵProgressBar_BaseFactory || (ɵProgressBar_BaseFactory = i0.ɵɵgetInheritedFactory(ProgressBar)))(__ngFactoryType__ || ProgressBar); }; })(); static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ProgressBar, selectors: [["p-progressBar"], ["p-progressbar"], ["p-progress-bar"]], contentQueries: function ProgressBar_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.contentTemplate = _t.first); i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.templates = _t); } }, inputs: { value: [2, "value", "value", numberAttribute], showValue: [2, "showValue", "showValue", booleanAttribute], styleClass: "styleClass", valueStyleClass: "valueStyleClass", style: "style", unit: "unit", mode: "mode", color: "color" }, features: [i0.ɵɵProvidersFeature([ProgressBarStyle]), i0.ɵɵInputTransformsFeature, i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 14, consts: [["role", "progressbar", 3, "ngStyle", "ngClass"], ["style", "display:flex", 3, "ngClass", "class", "width", "background", 4, "ngIf"], [3, "ngClass", "class", 4, "ngIf"], [2, "display", "flex", 3, "ngClass"], [1, "p-progressbar-label"], [3, "display", 4, "ngIf"], [4, "ngTemplateOutlet", "ngTemplateOutletContext"], [3, "ngClass"], [1, "p-progressbar-value", "p-progressbar-value-animate"]], template: function ProgressBar_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 0); i0.ɵɵtemplate(1, ProgressBar_div_1_Template, 4, 13, "div", 1)(2, ProgressBar_div_2_Template, 2, 7, "div", 2); i0.ɵɵelementEnd(); } if (rf & 2) { i0.ɵɵclassMap(ctx.styleClass); i0.ɵɵproperty("ngStyle", ctx.style)("ngClass", i0.ɵɵpureFunction2(11, _c1, ctx.mode === "determinate", ctx.mode === "indeterminate")); i0.ɵɵattribute("aria-valuemin", 0)("aria-valuenow", ctx.value)("aria-valuemax", 100)("data-pc-name", "progressbar")("data-pc-section", "root"); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.mode === "determinate"); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.mode === "indeterminate"); } }, dependencies: [CommonModule, i1.NgClass, i1.NgIf, i1.NgTemplateOutlet, i1.NgStyle, SharedModule], encapsulation: 2, changeDetection: 0 }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProgressBar, [{ type: Component, args: [{ selector: 'p-progressBar, p-progressbar, p-progress-bar', standalone: true, imports: [CommonModule, SharedModule], template: ` <div role="progressbar" [class]="styleClass" [ngStyle]="style" [attr.aria-valuemin]="0" [attr.aria-valuenow]="value" [attr.aria-valuemax]="100" [attr.data-pc-name]="'progressbar'" [attr.data-pc-section]="'root'" [ngClass]="{ 'p-progressbar p-component': true, 'p-progressbar-determinate': mode === 'determinate', 'p-progressbar-indeterminate': mode === 'indeterminate' }" > <div *ngIf="mode === 'determinate'" [ngClass]="'p-progressbar-value p-progressbar-value-animate'" [class]="valueStyleClass" [style.width]="value + '%'" style="display:flex" [style.background]="color" [attr.data-pc-section]="'value'"> <div class="p-progressbar-label"> <div *ngIf="showValue && !contentTemplate && !_contentTemplate" [style.display]="value != null && value !== 0 ? 'flex' : 'none'" [attr.data-pc-section]="'label'">{{ value }}{{ unit }}</div> <ng-container *ngTemplateOutlet="contentTemplate || _contentTemplate; context: { $implicit: value }"></ng-container> </div> </div> <div *ngIf="mode === 'indeterminate'" [ngClass]="'p-progressbar-indeterminate-container'" [class]="valueStyleClass" [attr.data-pc-section]="'container'"> <div class="p-progressbar-value p-progressbar-value-animate" [style.background]="color" [attr.data-pc-section]="'value'"></div> </div> </div> `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [ProgressBarStyle] }] }], null, { value: [{ type: Input, args: [{ transform: numberAttribute }] }], showValue: [{ type: Input, args: [{ transform: booleanAttribute }] }], styleClass: [{ type: Input }], valueStyleClass: [{ type: Input }], style: [{ type: Input }], unit: [{ type: Input }], mode: [{ type: Input }], color: [{ type: Input }], contentTemplate: [{ type: ContentChild, args: ['content', { descendants: false }] }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ProgressBar, { className: "ProgressBar", filePath: "progressbar.ts", lineNumber: 46 }); })(); class ProgressBarModule { static ɵfac = function ProgressBarModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ProgressBarModule)(); }; static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ProgressBarModule }); static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [ProgressBar, SharedModule, SharedModule] }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProgressBarModule, [{ type: NgModule, args: [{ imports: [ProgressBar, SharedModule], exports: [ProgressBar, SharedModule] }] }], null, null); })(); (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ProgressBarModule, { imports: [ProgressBar, SharedModule], exports: [ProgressBar, SharedModule] }); })(); /** * Generated bundle index. Do not edit. */ export { ProgressBar, ProgressBarClasses, ProgressBarModule, ProgressBarStyle }; //# sourceMappingURL=primeng-progressbar.mjs.map