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
272 lines (266 loc) • 11.4 kB
JavaScript
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, inject, 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-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
padding: ${dt('toolbar.padding')};
background: ${dt('toolbar.background')};
border: 1px solid ${dt('toolbar.border.color')};
color: ${dt('toolbar.color')};
border-radius: ${dt('toolbar.border.radius')};
gap: ${dt('toolbar.gap')};
}
.p-toolbar-start,
.p-toolbar-center,
.p-toolbar-end {
display: flex;
align-items: center;
}
`;
const classes = {
root: 'p-toolbar p-component',
start: 'p-toolbar-start',
center: 'p-toolbar-center',
end: 'p-toolbar-end'
};
class ToolbarStyle extends BaseStyle {
name = 'toolbar';
theme = theme;
classes = classes;
static ɵfac = /*@__PURE__*/ (() => { let ɵToolbarStyle_BaseFactory; return function ToolbarStyle_Factory(__ngFactoryType__) { return (ɵToolbarStyle_BaseFactory || (ɵToolbarStyle_BaseFactory = i0.ɵɵgetInheritedFactory(ToolbarStyle)))(__ngFactoryType__ || ToolbarStyle); }; })();
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ToolbarStyle, factory: ToolbarStyle.ɵfac });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToolbarStyle, [{
type: Injectable
}], null, null); })();
/**
*
* Toolbar is a grouping component for buttons and other content.
*
* [Live Demo](https://www.primeng.org/toolbar/)
*
* @module toolbarstyle
*
*/
var ToolbarClasses;
(function (ToolbarClasses) {
/**
* Class name of the root element
*/
ToolbarClasses["root"] = "p-toolbar";
/**
* Class name of the start element
*/
ToolbarClasses["start"] = "p-toolbar-start";
/**
* Class name of the center element
*/
ToolbarClasses["center"] = "p-toolbar-center";
/**
* Class name of the end element
*/
ToolbarClasses["end"] = "p-toolbar-end";
})(ToolbarClasses || (ToolbarClasses = {}));
const _c0 = ["start"];
const _c1 = ["end"];
const _c2 = ["center"];
const _c3 = ["*"];
function Toolbar_div_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Toolbar_div_2_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 4);
i0.ɵɵtemplate(1, Toolbar_div_2_ng_container_1_Template, 1, 0, "ng-container", 5);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r0 = i0.ɵɵnextContext();
i0.ɵɵattribute("data-pc-section", "start");
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.startTemplate || ctx_r0._startTemplate);
} }
function Toolbar_div_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Toolbar_div_3_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 6);
i0.ɵɵtemplate(1, Toolbar_div_3_ng_container_1_Template, 1, 0, "ng-container", 5);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r0 = i0.ɵɵnextContext();
i0.ɵɵattribute("data-pc-section", "center");
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.centerTemplate || ctx_r0._centerTemplate);
} }
function Toolbar_div_4_ng_container_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Toolbar_div_4_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 7);
i0.ɵɵtemplate(1, Toolbar_div_4_ng_container_1_Template, 1, 0, "ng-container", 5);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r0 = i0.ɵɵnextContext();
i0.ɵɵattribute("data-pc-section", "end");
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.endTemplate || ctx_r0._endTemplate);
} }
/**
* Toolbar is a grouping component for buttons and other content.
* @group Components
*/
class Toolbar extends BaseComponent {
/**
* Inline style of the component.
* @group Props
*/
style;
/**
* Style class of the component.
* @group Props
*/
styleClass;
/**
* Defines a string value that labels an interactive element.
* @group Props
*/
ariaLabelledBy;
_componentStyle = inject(ToolbarStyle);
getBlockableElement() {
return this.el.nativeElement.children[0];
}
/**
* Defines template option for start.
* @group Templates
*/
startTemplate;
/**
* Defines template option for end.
* @group Templates
*/
endTemplate;
/**
* Defines template option for center.
* @group Templates
*/
centerTemplate;
templates;
_startTemplate;
_endTemplate;
_centerTemplate;
ngAfterContentInit() {
this.templates.forEach((item) => {
switch (item.getType()) {
case 'start':
case 'left':
this._startTemplate = item.template;
break;
case 'end':
case 'right':
this._endTemplate = item.template;
break;
case 'center':
this._centerTemplate = item.template;
break;
}
});
}
static ɵfac = /*@__PURE__*/ (() => { let ɵToolbar_BaseFactory; return function Toolbar_Factory(__ngFactoryType__) { return (ɵToolbar_BaseFactory || (ɵToolbar_BaseFactory = i0.ɵɵgetInheritedFactory(Toolbar)))(__ngFactoryType__ || Toolbar); }; })();
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Toolbar, selectors: [["p-toolbar"]], contentQueries: function Toolbar_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
i0.ɵɵcontentQuery(dirIndex, _c0, 4);
i0.ɵɵcontentQuery(dirIndex, _c1, 4);
i0.ɵɵcontentQuery(dirIndex, _c2, 4);
i0.ɵɵcontentQuery(dirIndex, PrimeTemplate, 4);
} if (rf & 2) {
let _t;
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.startTemplate = _t.first);
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.endTemplate = _t.first);
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.centerTemplate = _t.first);
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.templates = _t);
} }, inputs: { style: "style", styleClass: "styleClass", ariaLabelledBy: "ariaLabelledBy" }, features: [i0.ɵɵProvidersFeature([ToolbarStyle]), i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c3, decls: 5, vars: 9, consts: [["role", "toolbar", 3, "ngClass", "ngStyle"], ["class", "p-toolbar-start", 4, "ngIf"], ["class", "p-toolbar-center", 4, "ngIf"], ["class", "p-toolbar-end", 4, "ngIf"], [1, "p-toolbar-start"], [4, "ngTemplateOutlet"], [1, "p-toolbar-center"], [1, "p-toolbar-end"]], template: function Toolbar_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵprojectionDef();
i0.ɵɵelementStart(0, "div", 0);
i0.ɵɵprojection(1);
i0.ɵɵtemplate(2, Toolbar_div_2_Template, 2, 2, "div", 1)(3, Toolbar_div_3_Template, 2, 2, "div", 2)(4, Toolbar_div_4_Template, 2, 2, "div", 3);
i0.ɵɵelementEnd();
} if (rf & 2) {
i0.ɵɵclassMap(ctx.styleClass);
i0.ɵɵproperty("ngClass", "p-toolbar p-component")("ngStyle", ctx.style);
i0.ɵɵattribute("aria-labelledby", ctx.ariaLabelledBy)("data-pc-name", "toolbar");
i0.ɵɵadvance(2);
i0.ɵɵproperty("ngIf", ctx.startTemplate || ctx._startTemplate);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx.centerTemplate || ctx._centerTemplate);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx.endTemplate || ctx._endTemplate);
} }, dependencies: [CommonModule, i1.NgClass, i1.NgIf, i1.NgTemplateOutlet, i1.NgStyle, SharedModule], encapsulation: 2, changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Toolbar, [{
type: Component,
args: [{
selector: 'p-toolbar',
standalone: true,
imports: [CommonModule, SharedModule],
template: `
<div [ngClass]="'p-toolbar p-component'" [attr.aria-labelledby]="ariaLabelledBy" [ngStyle]="style" [class]="styleClass" role="toolbar" [attr.data-pc-name]="'toolbar'">
<ng-content></ng-content>
<div class="p-toolbar-start" *ngIf="startTemplate || _startTemplate" [attr.data-pc-section]="'start'">
<ng-container *ngTemplateOutlet="startTemplate || _startTemplate"></ng-container>
</div>
<div class="p-toolbar-center" *ngIf="centerTemplate || _centerTemplate" [attr.data-pc-section]="'center'">
<ng-container *ngTemplateOutlet="centerTemplate || _centerTemplate"></ng-container>
</div>
<div class="p-toolbar-end" *ngIf="endTemplate || _endTemplate" [attr.data-pc-section]="'end'">
<ng-container *ngTemplateOutlet="endTemplate || _endTemplate"></ng-container>
</div>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
providers: [ToolbarStyle]
}]
}], null, { style: [{
type: Input
}], styleClass: [{
type: Input
}], ariaLabelledBy: [{
type: Input
}], startTemplate: [{
type: ContentChild,
args: ['start', { descendants: false }]
}], endTemplate: [{
type: ContentChild,
args: ['end', { descendants: false }]
}], centerTemplate: [{
type: ContentChild,
args: ['center', { descendants: false }]
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Toolbar, { className: "Toolbar", filePath: "toolbar.ts", lineNumber: 33 }); })();
class ToolbarModule {
static ɵfac = function ToolbarModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToolbarModule)(); };
static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ToolbarModule });
static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [Toolbar, SharedModule, SharedModule] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToolbarModule, [{
type: NgModule,
args: [{
imports: [Toolbar, SharedModule],
exports: [Toolbar, SharedModule]
}]
}], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ToolbarModule, { imports: [Toolbar, SharedModule], exports: [Toolbar, SharedModule] }); })();
/**
* Generated bundle index. Do not edit.
*/
export { Toolbar, ToolbarClasses, ToolbarModule, ToolbarStyle };
//# sourceMappingURL=primeng-toolbar.mjs.map