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
345 lines (335 loc) • 16.4 kB
JavaScript
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, Component, EventEmitter, inject, booleanAttribute, ContentChildren, ContentChild, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, NgModule } from '@angular/core';
import { SharedModule, PrimeTemplate } from 'primeng/api';
import { BaseComponent } from 'primeng/basecomponent';
import * as i2 from 'primeng/button';
import { ButtonModule } from 'primeng/button';
import { TimesIcon } from 'primeng/icons';
import { BaseStyle } from 'primeng/base';
import { Ripple } from 'primeng/ripple';
const theme = ({ dt }) => `
.p-inplace-display {
display: inline-block;
cursor: pointer;
border: 1px solid transparent;
padding: ${dt('inplace.padding')};
border-radius: ${dt('inplace.border.radius')};
transition: background ${dt('inplace.transition.duration')}, color ${dt('inplace.transition.duration')}, outline-color ${dt('inplace.transition.duration')}, box-shadow ${dt('inplace.transition.duration')};
outline-color: transparent;
}
.p-inplace-display:not(.p-disabled):hover {
background: ${dt('inplace.display.hover.background')};
color: ${dt('inplace.display.hover.color')};
}
.p-inplace-display:focus-visible {
box-shadow: ${dt('inplace.focus.ring.shadow')};
outline: ${dt('inplace.focus.ring.width')} ${dt('inplace.focus.ring.style')} ${dt('inplace.focus.ring.color')};
outline-offset: ${dt('inplace.focus.ring.offset')};
}
.p-inplace-content {
display: block;
}
`;
const classes = {
root: 'p-inplace p-component',
display: ({ props }) => ['p-inplace-display', { 'p-disabled': props.disabled }],
content: 'p-inplace-content'
};
class InplaceStyle extends BaseStyle {
name = 'inplace';
theme = theme;
classes = classes;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceStyle });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceStyle, decorators: [{
type: Injectable
}] });
/**
*
* Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
*
* [Live Demo](https://www.primeng.org/inplace)
*
* @module inplacestyle
*
*/
var InplaceClasses;
(function (InplaceClasses) {
/**
* Class name of the root element
*/
InplaceClasses["root"] = "p-inplace";
/**
* Class name of the display element
*/
InplaceClasses["display"] = "p-inplace-display";
/**
* Class name of the content element
*/
InplaceClasses["content"] = "p-inplace-content";
})(InplaceClasses || (InplaceClasses = {}));
class InplaceDisplay {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceDisplay, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: InplaceDisplay, isStandalone: true, selector: "p-inplacedisplay, p-inplaceDisplay", ngImport: i0, template: '<ng-content></ng-content>', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceDisplay, decorators: [{
type: Component,
args: [{
selector: 'p-inplacedisplay, p-inplaceDisplay',
standalone: true,
imports: [CommonModule],
template: '<ng-content></ng-content>'
}]
}] });
class InplaceContent {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceContent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: InplaceContent, isStandalone: true, selector: "p-inplacecontent, p-inplaceContent", ngImport: i0, template: '<ng-content></ng-content>', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceContent, decorators: [{
type: Component,
args: [{
selector: 'p-inplacecontent, p-inplaceContent',
standalone: true,
imports: [CommonModule],
template: '<ng-content></ng-content>'
}]
}] });
/**
* Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
* @group Components
*/
class Inplace extends BaseComponent {
/**
* Whether the content is displayed or not.
* @group Props
*/
active = false;
/**
* Displays a button to switch back to display mode.
* @group Props
*/
closable = false;
/**
* When present, it specifies that the element should be disabled.
* @group Props
*/
disabled = false;
/**
* Allows to prevent clicking.
* @group Props
*/
preventClick;
/**
* Inline style of the element.
* @group Props
*/
style;
/**
* Class of the element.
* @group Props
*/
styleClass;
/**
* Icon to display in the close button.
* @group Props
*/
closeIcon;
/**
* Establishes a string value that labels the close button.
* @group Props
*/
closeAriaLabel;
/**
* Callback to invoke when inplace is opened.
* @param {Event} event - Browser event.
* @group Emits
*/
onActivate = new EventEmitter();
/**
* Callback to invoke when inplace is closed.
* @param {Event} event - Browser event.
* @group Emits
*/
onDeactivate = new EventEmitter();
hover;
/**
* Display template of the element.
* @group Templates
*/
displayTemplate;
/**
* Content template of the element.
* @group Templates
*/
contentTemplate;
/**
* Close icon template of the element.
* @group Templates
*/
closeIconTemplate;
_componentStyle = inject(InplaceStyle);
onActivateClick(event) {
if (!this.preventClick)
this.activate(event);
}
onDeactivateClick(event) {
if (!this.preventClick)
this.deactivate(event);
}
/**
* Activates the content.
* @param {Event} event - Browser event.
* @group Method
*/
activate(event) {
if (!this.disabled) {
this.active = true;
this.onActivate.emit(event);
this.cd.markForCheck();
}
}
/**
* Deactivates the content.
* @param {Event} event - Browser event.
* @group Method
*/
deactivate(event) {
if (!this.disabled) {
this.active = false;
this.hover = false;
this.onDeactivate.emit(event);
this.cd.markForCheck();
}
}
onKeydown(event) {
if (event.code === 'Enter') {
this.activate(event);
event.preventDefault();
}
}
templates;
_displayTemplate;
_closeIconTemplate;
_contentTemplate;
ngAfterContentInit() {
this.templates?.forEach((item) => {
switch (item.getType()) {
case 'display':
this._displayTemplate = item.template;
break;
case 'closeicon':
this._closeIconTemplate = item.template;
break;
case 'content':
this._contentTemplate = item.template;
break;
}
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Inplace, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.2", type: Inplace, isStandalone: true, selector: "p-inplace", inputs: { active: ["active", "active", booleanAttribute], closable: ["closable", "closable", booleanAttribute], disabled: ["disabled", "disabled", booleanAttribute], preventClick: ["preventClick", "preventClick", booleanAttribute], style: "style", styleClass: "styleClass", closeIcon: "closeIcon", closeAriaLabel: "closeAriaLabel" }, outputs: { onActivate: "onActivate", onDeactivate: "onDeactivate" }, providers: [InplaceStyle], queries: [{ propertyName: "displayTemplate", first: true, predicate: ["display"] }, { propertyName: "contentTemplate", first: true, predicate: ["content"] }, { propertyName: "closeIconTemplate", first: true, predicate: ["closeicon"] }, { propertyName: "templates", predicate: PrimeTemplate }], usesInheritance: true, ngImport: i0, template: `
<div [ngClass]="{ 'p-inplace p-component': true, 'p-inplace-closable': closable }" [ngStyle]="style" [class]="styleClass" [attr.aria-live]="'polite'">
<div class="p-inplace-display" (click)="onActivateClick($event)" tabindex="0" role="button" (keydown)="onKeydown($event)" [ngClass]="{ 'p-disabled': disabled }" *ngIf="!active">
<ng-content select="[pInplaceDisplay]"></ng-content>
<ng-container *ngTemplateOutlet="displayTemplate || _displayTemplate"></ng-container>
</div>
<div class="p-inplace-content" *ngIf="active">
<ng-content select="[pInplaceContent]"></ng-content>
<ng-container *ngTemplateOutlet="contentTemplate || _contentTemplate; context: { closeCallback: onDeactivateClick.bind(this) }"></ng-container>
<ng-container *ngIf="closable">
<button *ngIf="closeIcon" type="button" [icon]="closeIcon" pButton pRipple (click)="onDeactivateClick($event)" [attr.aria-label]="closeAriaLabel"></button>
<button *ngIf="!closeIcon" type="button" pButton pRipple [ngClass]="'p-button-icon-only'" (click)="onDeactivateClick($event)" [attr.aria-label]="closeAriaLabel">
<TimesIcon *ngIf="!closeIconTemplate && !_closeIconTemplate" />
<ng-template *ngTemplateOutlet="closeIconTemplate || _closeIconTemplate"></ng-template>
</button>
</ng-container>
</div>
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i2.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "component", type: TimesIcon, selector: "TimesIcon" }, { kind: "ngmodule", type: SharedModule }, { kind: "directive", type: Ripple, selector: "[pRipple]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: Inplace, decorators: [{
type: Component,
args: [{
selector: 'p-inplace',
standalone: true,
imports: [CommonModule, ButtonModule, TimesIcon, SharedModule, Ripple],
template: `
<div [ngClass]="{ 'p-inplace p-component': true, 'p-inplace-closable': closable }" [ngStyle]="style" [class]="styleClass" [attr.aria-live]="'polite'">
<div class="p-inplace-display" (click)="onActivateClick($event)" tabindex="0" role="button" (keydown)="onKeydown($event)" [ngClass]="{ 'p-disabled': disabled }" *ngIf="!active">
<ng-content select="[pInplaceDisplay]"></ng-content>
<ng-container *ngTemplateOutlet="displayTemplate || _displayTemplate"></ng-container>
</div>
<div class="p-inplace-content" *ngIf="active">
<ng-content select="[pInplaceContent]"></ng-content>
<ng-container *ngTemplateOutlet="contentTemplate || _contentTemplate; context: { closeCallback: onDeactivateClick.bind(this) }"></ng-container>
<ng-container *ngIf="closable">
<button *ngIf="closeIcon" type="button" [icon]="closeIcon" pButton pRipple (click)="onDeactivateClick($event)" [attr.aria-label]="closeAriaLabel"></button>
<button *ngIf="!closeIcon" type="button" pButton pRipple [ngClass]="'p-button-icon-only'" (click)="onDeactivateClick($event)" [attr.aria-label]="closeAriaLabel">
<TimesIcon *ngIf="!closeIconTemplate && !_closeIconTemplate" />
<ng-template *ngTemplateOutlet="closeIconTemplate || _closeIconTemplate"></ng-template>
</button>
</ng-container>
</div>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
providers: [InplaceStyle]
}]
}], propDecorators: { active: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], closable: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], disabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], preventClick: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], closeIcon: [{
type: Input
}], closeAriaLabel: [{
type: Input
}], onActivate: [{
type: Output
}], onDeactivate: [{
type: Output
}], displayTemplate: [{
type: ContentChild,
args: ['display', { descendants: false }]
}], contentTemplate: [{
type: ContentChild,
args: ['content', { descendants: false }]
}], closeIconTemplate: [{
type: ContentChild,
args: ['closeicon', { descendants: false }]
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}] } });
class InplaceModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: InplaceModule, imports: [Inplace, InplaceContent, InplaceDisplay, SharedModule], exports: [Inplace, InplaceContent, InplaceDisplay, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceModule, imports: [Inplace, InplaceContent, InplaceDisplay, SharedModule, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: InplaceModule, decorators: [{
type: NgModule,
args: [{
imports: [Inplace, InplaceContent, InplaceDisplay, SharedModule],
exports: [Inplace, InplaceContent, InplaceDisplay, SharedModule]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { Inplace, InplaceClasses, InplaceContent, InplaceDisplay, InplaceModule, InplaceStyle };
//# sourceMappingURL=primeng-inplace.mjs.map