import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common'; import { Directive, Inject, NgModule, Optional, PLATFORM_ID } from '@angular/core'; import { DomHandler } from 'primeng/dom'; import * as i0 from "@angular/core"; import * as i1 from "primeng/api"; /** * Ripple directive adds ripple effect to the host element. * @group Components */ export class Ripple { document; platformId; renderer; el; zone; config; constructor(document, platformId, renderer, el, zone, config) { this.document = document; this.platformId = platformId; this.renderer = renderer; this.el = el; this.zone = zone; this.config = config; } animationListener; mouseDownListener; timeout; ngAfterViewInit() { if (isPlatformBrowser(this.platformId)) { if (this.config && this.config.ripple) { this.zone.runOutsideAngular(() => { this.create(); this.mouseDownListener = this.renderer.listen(this.el.nativeElement, 'mousedown', this.onMouseDown.bind(this)); }); } } } onMouseDown(event) { let ink = this.getInk(); if (!ink || this.document.defaultView?.getComputedStyle(ink, null).display === 'none') { return; } DomHandler.removeClass(ink, 'p-ink-active'); if (!DomHandler.getHeight(ink) && !DomHandler.getWidth(ink)) { let d = Math.max(DomHandler.getOuterWidth(this.el.nativeElement), DomHandler.getOuterHeight(this.el.nativeElement)); ink.style.height = d + 'px'; ink.style.width = d + 'px'; } let offset = DomHandler.getOffset(this.el.nativeElement); let x = event.pageX - offset.left + this.document.body.scrollTop - DomHandler.getWidth(ink) / 2; let y = event.pageY - offset.top + this.document.body.scrollLeft - DomHandler.getHeight(ink) / 2; this.renderer.setStyle(ink, 'top', y + 'px'); this.renderer.setStyle(ink, 'left', x + 'px'); DomHandler.addClass(ink, 'p-ink-active'); this.timeout = setTimeout(() => { let ink = this.getInk(); if (ink) { DomHandler.removeClass(ink, 'p-ink-active'); } }, 401); } getInk() { const children = this.el.nativeElement.children; for (let i = 0; i < children.length; i++) { if (typeof children[i].className === 'string' && children[i].className.indexOf('p-ink') !== -1) { return children[i]; } } return null; } resetInk() { let ink = this.getInk(); if (ink) { DomHandler.removeClass(ink, 'p-ink-active'); } } onAnimationEnd(event) { if (this.timeout) { clearTimeout(this.timeout); } DomHandler.removeClass(event.currentTarget, 'p-ink-active'); } create() { let ink = this.renderer.createElement('span'); this.renderer.addClass(ink, 'p-ink'); this.renderer.appendChild(this.el.nativeElement, ink); this.renderer.setAttribute(ink, 'aria-hidden', 'true'); this.renderer.setAttribute(ink, 'role', 'presentation'); if (!this.animationListener) { this.animationListener = this.renderer.listen(ink, 'animationend', this.onAnimationEnd.bind(this)); } } remove() { let ink = this.getInk(); if (ink) { this.mouseDownListener && this.mouseDownListener(); this.animationListener && this.animationListener(); this.mouseDownListener = null; this.animationListener = null; DomHandler.removeElement(ink); } } ngOnDestroy() { if (this.config && this.config.ripple) { this.remove(); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Ripple, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i1.PrimeNGConfig, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.7", type: Ripple, selector: "[pRipple]", host: { classAttribute: "p-ripple p-element" }, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Ripple, decorators: [{ type: Directive, args: [{ selector: '[pRipple]', host: { class: 'p-ripple p-element' } }] }], ctorParameters: () => [{ type: Document, decorators: [{ type: Inject, args: [DOCUMENT] }] }, { type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID] }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.PrimeNGConfig, decorators: [{ type: Optional }] }] }); export class RippleModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RippleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: RippleModule, declarations: [Ripple], imports: [CommonModule], exports: [Ripple] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RippleModule, imports: [CommonModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RippleModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], exports: [Ripple], declarations: [Ripple] }] }] }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmlwcGxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9jb21wb25lbnRzL3JpcHBsZS9yaXBwbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUM1RSxPQUFPLEVBQWlCLFNBQVMsRUFBYyxNQUFNLEVBQUUsUUFBUSxFQUFxQixRQUFRLEVBQUUsV0FBVyxFQUFhLE1BQU0sZUFBZSxDQUFDO0FBRTVJLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxhQUFhLENBQUM7OztBQUV6Qzs7O0dBR0c7QUFPSCxNQUFNLE9BQU8sTUFBTTtJQUN1QjtJQUFpRDtJQUF5QjtJQUE0QjtJQUF1QjtJQUFpQztJQUFwTSxZQUFzQyxRQUFrQixFQUErQixVQUFlLEVBQVUsUUFBbUIsRUFBUyxFQUFjLEVBQVMsSUFBWSxFQUFxQixNQUFxQjtRQUFuTCxhQUFRLEdBQVIsUUFBUSxDQUFVO1FBQStCLGVBQVUsR0FBVixVQUFVLENBQUs7UUFBVSxhQUFRLEdBQVIsUUFBUSxDQUFXO1FBQVMsT0FBRSxHQUFGLEVBQUUsQ0FBWTtRQUFTLFNBQUksR0FBSixJQUFJLENBQVE7UUFBcUIsV0FBTSxHQUFOLE1BQU0sQ0FB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4gICAgICAgICAgICBpZiAoaW5rKSB7XG4gICAgICAgICAgICAgICAgRG9tSGFuZGxlci5yZW1vdmVDbGFzcyhpbmssICdwLWluay1hY3RpdmUnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgNDAxKTtcbiAgICB9XG5cbiAgICBnZXRJbmsoKSB7XG4gICAgICAgIGNvbnN0IGNoaWxkcmVuID0gdGhpcy5lbC5uYXRpdmVFbGVtZW50LmNoaWxkcmVuO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoaWxkcmVuLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIGNoaWxkcmVuW2ldLmNsYXNzTmFtZSA9PT0gJ3N0cmluZycgJiYgY2hpbGRyZW5baV0uY2xhc3NOYW1lLmluZGV4T2YoJ3AtaW5rJykgIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNoaWxkcmVuW2ldO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuICAgIHJlc2V0SW5rKCkge1xuICAgICAgICBsZXQgaW5rID0gdGhpcy5nZXRJbmsoKTtcbiAgICAgICAgaWYgKGluaykge1xuICAgICAgICAgICAgRG9tSGFuZGxlci5yZW1vdmVDbGFzcyhpbmssICdwLWluay1hY3RpdmUnKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIG9uQW5pbWF0aW9uRW5kKGV2ZW50OiBFdmVudCkge1xuICAgICAgICBpZiAodGhpcy50aW1lb3V0KSB7XG4gICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy50aW1lb3V0KTtcbiAgICAgICAgfVxuICAgICAgICBEb21IYW5kbGVyLnJlbW92ZUNsYXNzKGV2ZW50LmN1cnJlbnRUYXJnZXQsICdwLWluay1hY3RpdmUnKTtcbiAgICB9XG5cbiAgICBjcmVhdGUoKSB7XG4gICAgICAgIGxldCBpbmsgPSB0aGlzLnJlbmRlc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