primeng
Version:
PrimeNG is a premium UI library for Angular featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBlock,
238 lines (233 loc) • 12.7 kB
JavaScript
export * from 'primeng/types/inplace';
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, InjectionToken, Component, inject, signal, input, booleanAttribute, output, contentChild, ViewEncapsulation, ChangeDetectionStrategy, NgModule } from '@angular/core';
import { SharedModule } from 'primeng/api';
import { BaseComponent, PARENT_INSTANCE } from 'primeng/basecomponent';
import * as i1 from 'primeng/bind';
import { Bind } from 'primeng/bind';
import { style } from '@primeuix/styles/inplace';
import { BaseStyle } from 'primeng/base';
const classes = {
root: () => ['p-inplace p-component'],
display: ({ instance }) => ['p-inplace-display', { 'p-disabled': instance.disabled() }],
content: 'p-inplace-content'
};
class InplaceStyle extends BaseStyle {
name = 'inplace';
style = style;
classes = classes;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceStyle });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", 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 = {}));
const INPLACE_INSTANCE = new InjectionToken('INPLACE_INSTANCE');
class InplaceDisplay extends BaseComponent {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceDisplay, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: InplaceDisplay, isStandalone: true, selector: "p-inplacedisplay, p-inplace-display", usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceDisplay, decorators: [{
type: Component,
args: [{
selector: 'p-inplacedisplay, p-inplace-display',
standalone: true,
template: '<ng-content></ng-content>'
}]
}] });
class InplaceContent extends BaseComponent {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceContent, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: InplaceContent, isStandalone: true, selector: "p-inplacecontent, p-inplace-content", usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceContent, decorators: [{
type: Component,
args: [{
selector: 'p-inplacecontent, p-inplace-content',
standalone: true,
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 {
componentName = 'Inplace';
$pcInplace = inject(INPLACE_INSTANCE, { optional: true, skipSelf: true }) ?? undefined;
bindDirectiveInstance = inject(Bind, { self: true });
/**
* Whether the content is displayed or not.
* @group Props
*/
active = signal(false, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
/**
* When present, it specifies that the element should be disabled.
* @group Props
*/
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
/**
* Allows to prevent clicking.
* @group Props
*/
preventClick = input(false, { ...(ngDevMode ? { debugName: "preventClick" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
/**
* Callback to invoke when inplace is opened.
* @param {Event} event - Browser event.
* @group Emits
*/
onActivate = output();
/**
* Callback to invoke when inplace is closed.
* @param {Event} event - Browser event.
* @group Emits
*/
onDeactivate = output();
/**
* Custom display template.
* @group Templates
*/
displayTemplate = contentChild('display', { ...(ngDevMode ? { debugName: "displayTemplate" } : /* istanbul ignore next */ {}), descendants: false });
/**
* Custom content template.
* @group Templates
*/
contentTemplate = contentChild('content', { ...(ngDevMode ? { debugName: "contentTemplate" } : /* istanbul ignore next */ {}), descendants: false });
_componentStyle = inject(InplaceStyle);
onAfterViewChecked() {
this.bindDirectiveInstance.setAttrs(this.ptms(['host', 'root']));
}
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.set(true);
if (event)
this.onActivate.emit(event);
}
}
/**
* Deactivates the content.
* @param {Event} event - Browser event.
* @group Method
*/
deactivate(event) {
if (!this.disabled()) {
this.active.set(false);
if (event)
this.onDeactivate.emit(event);
}
}
onKeydown(event) {
if (event.code === 'Enter') {
this.activate(event);
event.preventDefault();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Inplace, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: Inplace, isStandalone: true, selector: "p-inplace", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, preventClick: { classPropertyName: "preventClick", publicName: "preventClick", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onActivate: "onActivate", onDeactivate: "onDeactivate" }, host: { properties: { "attr.aria-live": "'polite'", "class": "cx('root')" } }, providers: [InplaceStyle, { provide: INPLACE_INSTANCE, useExisting: Inplace }, { provide: PARENT_INSTANCE, useExisting: Inplace }], queries: [{ propertyName: "displayTemplate", first: true, predicate: ["display"], isSignal: true }, { propertyName: "contentTemplate", first: true, predicate: ["content"], isSignal: true }], usesInheritance: true, hostDirectives: [{ directive: i1.Bind }], ngImport: i0, template: `
(!active()) {
<div [class]="cx('display')" [pBind]="ptm('display')" (click)="onActivateClick($event)" tabindex="0" role="button" (keydown)="onKeydown($event)" [attr.data-p-disabled]="disabled()">
<ng-content select="[pInplaceDisplay]"></ng-content>
(displayTemplate()) {
<ng-container [ngTemplateOutlet]="displayTemplate()!"></ng-container>
}
</div>
}
(active()) {
<div [class]="cx('content')" [pBind]="ptm('content')">
<ng-content select="[pInplaceContent]"></ng-content>
(contentTemplate()) {
<ng-container [ngTemplateOutlet]="contentTemplate()!" [ngTemplateOutletContext]="{ closeCallback: onDeactivateClick.bind(this) }"></ng-container>
}
</div>
}
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: SharedModule }, { kind: "directive", type: Bind, selector: "[pBind]", inputs: ["pBind"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Inplace, decorators: [{
type: Component,
args: [{
selector: 'p-inplace',
standalone: true,
imports: [NgTemplateOutlet, SharedModule, Bind],
template: `
(!active()) {
<div [class]="cx('display')" [pBind]="ptm('display')" (click)="onActivateClick($event)" tabindex="0" role="button" (keydown)="onKeydown($event)" [attr.data-p-disabled]="disabled()">
<ng-content select="[pInplaceDisplay]"></ng-content>
(displayTemplate()) {
<ng-container [ngTemplateOutlet]="displayTemplate()!"></ng-container>
}
</div>
}
(active()) {
<div [class]="cx('content')" [pBind]="ptm('content')">
<ng-content select="[pInplaceContent]"></ng-content>
(contentTemplate()) {
<ng-container [ngTemplateOutlet]="contentTemplate()!" [ngTemplateOutletContext]="{ closeCallback: onDeactivateClick.bind(this) }"></ng-container>
}
</div>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
providers: [InplaceStyle, { provide: INPLACE_INSTANCE, useExisting: Inplace }, { provide: PARENT_INSTANCE, useExisting: Inplace }],
host: {
'[attr.aria-live]': "'polite'",
'[class]': "cx('root')"
},
hostDirectives: [Bind]
}]
}], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], preventClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "preventClick", required: false }] }], onActivate: [{ type: i0.Output, args: ["onActivate"] }], onDeactivate: [{ type: i0.Output, args: ["onDeactivate"] }], displayTemplate: [{ type: i0.ContentChild, args: ['display', { ...{ descendants: false }, isSignal: true }] }], contentTemplate: [{ type: i0.ContentChild, args: ['content', { ...{ descendants: false }, isSignal: true }] }] } });
class InplaceModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: InplaceModule, imports: [Inplace, InplaceContent, InplaceDisplay, SharedModule], exports: [Inplace, InplaceContent, InplaceDisplay, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: InplaceModule, imports: [Inplace, SharedModule, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", 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