source: trip-planner-front/node_modules/primeng/fesm2015/primeng-dynamicdialog.mjs@ 8d391a1

Last change on this file since 8d391a1 was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 22.4 KB
Line 
1import * as i0 from '@angular/core';
2import { Directive, Component, ChangeDetectionStrategy, ViewEncapsulation, ViewChild, NgModule, Injectable } from '@angular/core';
3import { animation, style, animate, trigger, transition, useAnimation } from '@angular/animations';
4import * as i4 from '@angular/common';
5import { CommonModule } from '@angular/common';
6import { DomHandler } from 'primeng/dom';
7import { ZIndexUtils } from 'primeng/utils';
8import { Subject } from 'rxjs';
9import * as i3 from 'primeng/api';
10
11class DynamicDialogContent {
12 constructor(viewContainerRef) {
13 this.viewContainerRef = viewContainerRef;
14 }
15}
16DynamicDialogContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogContent, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
17DynamicDialogContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: DynamicDialogContent, selector: "[pDynamicDialogContent]", host: { classAttribute: "p-element" }, ngImport: i0 });
18i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogContent, decorators: [{
19 type: Directive,
20 args: [{
21 selector: '[pDynamicDialogContent]',
22 host: {
23 'class': 'p-element'
24 }
25 }]
26 }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
27
28class DynamicDialogConfig {
29}
30
31class DynamicDialogRef {
32 constructor() {
33 this._onClose = new Subject();
34 this.onClose = this._onClose.asObservable();
35 this._onDestroy = new Subject();
36 this.onDestroy = this._onDestroy.asObservable();
37 }
38 close(result) {
39 this._onClose.next(result);
40 }
41 destroy() {
42 this._onDestroy.next(null);
43 }
44}
45
46const showAnimation = animation([
47 style({ transform: '{{transform}}', opacity: 0 }),
48 animate('{{transition}}', style({ transform: 'none', opacity: 1 }))
49]);
50const hideAnimation = animation([
51 animate('{{transition}}', style({ transform: '{{transform}}', opacity: 0 }))
52]);
53class DynamicDialogComponent {
54 constructor(componentFactoryResolver, cd, renderer, config, dialogRef, zone, primeNGConfig) {
55 this.componentFactoryResolver = componentFactoryResolver;
56 this.cd = cd;
57 this.renderer = renderer;
58 this.config = config;
59 this.dialogRef = dialogRef;
60 this.zone = zone;
61 this.primeNGConfig = primeNGConfig;
62 this.visible = true;
63 this.transformOptions = "scale(0.7)";
64 }
65 ngAfterViewInit() {
66 this.loadChildComponent(this.childComponentType);
67 this.cd.detectChanges();
68 }
69 loadChildComponent(componentType) {
70 let componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentType);
71 let viewContainerRef = this.insertionPoint.viewContainerRef;
72 viewContainerRef.clear();
73 this.componentRef = viewContainerRef.createComponent(componentFactory);
74 }
75 moveOnTop() {
76 if (this.config.autoZIndex !== false) {
77 ZIndexUtils.set('modal', this.container, (this.config.baseZIndex || 0) + this.primeNGConfig.zIndex.modal);
78 this.wrapper.style.zIndex = String(parseInt(this.container.style.zIndex, 10) - 1);
79 }
80 }
81 onAnimationStart(event) {
82 switch (event.toState) {
83 case 'visible':
84 this.container = event.element;
85 this.wrapper = this.container.parentElement;
86 this.moveOnTop();
87 this.bindGlobalListeners();
88 if (this.config.modal !== false) {
89 this.enableModality();
90 }
91 this.focus();
92 break;
93 case 'void':
94 if (this.config.modal !== false) {
95 DomHandler.addClass(this.wrapper, 'p-component-overlay-leave');
96 }
97 break;
98 }
99 }
100 onAnimationEnd(event) {
101 if (event.toState === 'void') {
102 this.onContainerDestroy();
103 this.dialogRef.destroy();
104 }
105 }
106 onContainerDestroy() {
107 this.unbindGlobalListeners();
108 if (this.container && this.config.autoZIndex !== false) {
109 ZIndexUtils.clear(this.container);
110 }
111 if (this.config.modal !== false) {
112 this.disableModality();
113 }
114 this.container = null;
115 }
116 close() {
117 this.visible = false;
118 this.cd.markForCheck();
119 }
120 hide() {
121 if (this.dialogRef) {
122 this.dialogRef.close();
123 }
124 }
125 enableModality() {
126 if (this.config.closable !== false && this.config.dismissableMask) {
127 this.maskClickListener = this.renderer.listen(this.wrapper, 'mousedown', (event) => {
128 if (this.wrapper && this.wrapper.isSameNode(event.target)) {
129 this.hide();
130 }
131 });
132 }
133 if (this.config.modal !== false) {
134 DomHandler.addClass(document.body, 'p-overflow-hidden');
135 }
136 }
137 disableModality() {
138 if (this.wrapper) {
139 if (this.config.dismissableMask) {
140 this.unbindMaskClickListener();
141 }
142 if (this.config.modal !== false) {
143 DomHandler.removeClass(document.body, 'p-overflow-hidden');
144 }
145 if (!this.cd.destroyed) {
146 this.cd.detectChanges();
147 }
148 }
149 }
150 onKeydown(event) {
151 if (event.which === 9) {
152 event.preventDefault();
153 let focusableElements = DomHandler.getFocusableElements(this.container);
154 if (focusableElements && focusableElements.length > 0) {
155 if (!focusableElements[0].ownerDocument.activeElement) {
156 focusableElements[0].focus();
157 }
158 else {
159 let focusedIndex = focusableElements.indexOf(focusableElements[0].ownerDocument.activeElement);
160 if (event.shiftKey) {
161 if (focusedIndex == -1 || focusedIndex === 0)
162 focusableElements[focusableElements.length - 1].focus();
163 else
164 focusableElements[focusedIndex - 1].focus();
165 }
166 else {
167 if (focusedIndex == -1 || focusedIndex === (focusableElements.length - 1))
168 focusableElements[0].focus();
169 else
170 focusableElements[focusedIndex + 1].focus();
171 }
172 }
173 }
174 }
175 }
176 focus() {
177 let focusable = DomHandler.findSingle(this.container, '[autofocus]');
178 if (focusable) {
179 this.zone.runOutsideAngular(() => {
180 setTimeout(() => focusable.focus(), 5);
181 });
182 }
183 }
184 bindGlobalListeners() {
185 this.bindDocumentKeydownListener();
186 if (this.config.closeOnEscape !== false && this.config.closable !== false) {
187 this.bindDocumentEscapeListener();
188 }
189 }
190 unbindGlobalListeners() {
191 this.unbindDocumentKeydownListener();
192 this.unbindDocumentEscapeListener();
193 }
194 bindDocumentKeydownListener() {
195 this.zone.runOutsideAngular(() => {
196 this.documentKeydownListener = this.onKeydown.bind(this);
197 window.document.addEventListener('keydown', this.documentKeydownListener);
198 });
199 }
200 unbindDocumentKeydownListener() {
201 if (this.documentKeydownListener) {
202 window.document.removeEventListener('keydown', this.documentKeydownListener);
203 this.documentKeydownListener = null;
204 }
205 }
206 bindDocumentEscapeListener() {
207 const documentTarget = this.maskViewChild ? this.maskViewChild.nativeElement.ownerDocument : 'document';
208 this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', (event) => {
209 if (event.which == 27) {
210 if (parseInt(this.container.style.zIndex) == ZIndexUtils.getCurrent()) {
211 this.hide();
212 }
213 }
214 });
215 }
216 unbindDocumentEscapeListener() {
217 if (this.documentEscapeListener) {
218 this.documentEscapeListener();
219 this.documentEscapeListener = null;
220 }
221 }
222 unbindMaskClickListener() {
223 if (this.maskClickListener) {
224 this.maskClickListener();
225 this.maskClickListener = null;
226 }
227 }
228 ngOnDestroy() {
229 this.onContainerDestroy();
230 if (this.componentRef) {
231 this.componentRef.destroy();
232 }
233 }
234}
235DynamicDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogComponent, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }, { token: DynamicDialogConfig }, { token: DynamicDialogRef }, { token: i0.NgZone }, { token: i3.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Component });
236DynamicDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: DynamicDialogComponent, selector: "p-dynamicDialog", host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "insertionPoint", first: true, predicate: DynamicDialogContent, descendants: true }, { propertyName: "maskViewChild", first: true, predicate: ["mask"], descendants: true }], ngImport: i0, template: `
237 <div #mask [ngClass]="{'p-dialog-mask':true, 'p-component-overlay-enter p-dialog-mask-scrollblocker': config.modal !== false}">
238 <div [ngClass]="{'p-dialog p-dynamic-dialog p-component':true, 'p-dialog-rtl': config.rtl}" [ngStyle]="config.style" [class]="config.styleClass"
239 [@animation]="{value: 'visible', params: {transform: transformOptions, transition: config.transitionOptions || '150ms cubic-bezier(0, 0, 0.2, 1)'}}"
240 (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)" role="dialog" *ngIf="visible"
241 [style.width]="config.width" [style.height]="config.height">
242 <div class="p-dialog-header" *ngIf="config.showHeader === false ? false: true">
243 <span class="p-dialog-title">{{config.header}}</span>
244 <div class="p-dialog-header-icons">
245 <button [ngClass]="'p-dialog-header-icon p-dialog-header-maximize p-link'" type="button" (click)="hide()" (keydown.enter)="hide()" *ngIf="config.closable !== false">
246 <span class="p-dialog-header-close-icon pi pi-times"></span>
247 </button>
248 </div>
249 </div>
250 <div class="p-dialog-content" [ngStyle]="config.contentStyle">
251 <ng-template pDynamicDialogContent></ng-template>
252 </div>
253 <div class="p-dialog-footer" *ngIf="config.footer">
254 {{config.footer}}
255 </div>
256 </div>
257 </div>
258 `, isInline: true, styles: [".p-dialog-mask{position:fixed;top:0;left:0;width:100%;height:100%;display:flex;justify-content:center;align-items:center;pointer-events:none}.p-dialog-mask.p-component-overlay{pointer-events:auto}.p-dialog{display:flex;flex-direction:column;pointer-events:auto;max-height:90%;transform:scale(1);position:relative}.p-dialog-content{overflow-y:auto;flex-grow:1}.p-dialog-header{display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.p-dialog-footer{flex-shrink:0}.p-dialog .p-dialog-header-icons{display:flex;align-items:center}.p-dialog .p-dialog-header-icon{display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-fluid .p-dialog-footer .p-button{width:auto}.p-dialog-top .p-dialog,.p-dialog-bottom .p-dialog,.p-dialog-left .p-dialog,.p-dialog-right .p-dialog,.p-dialog-top-left .p-dialog,.p-dialog-top-right .p-dialog,.p-dialog-bottom-left .p-dialog,.p-dialog-bottom-right .p-dialog{margin:.75rem;transform:translate(0)}.p-dialog-maximized{transition:none;transform:none;width:100vw!important;height:100vh!important;top:0px!important;left:0px!important;max-height:100%;height:100%}.p-dialog-maximized .p-dialog-content{flex-grow:1}.p-dialog-left{justify-content:flex-start}.p-dialog-right{justify-content:flex-end}.p-dialog-top{align-items:flex-start}.p-dialog-top-left{justify-content:flex-start;align-items:flex-start}.p-dialog-top-right{justify-content:flex-end;align-items:flex-start}.p-dialog-bottom{align-items:flex-end}.p-dialog-bottom-left{justify-content:flex-start;align-items:flex-end}.p-dialog-bottom-right{justify-content:flex-end;align-items:flex-end}.p-dialog .p-resizable-handle{position:absolute;font-size:.1px;display:block;cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.p-confirm-dialog .p-dialog-content{display:flex;align-items:center}\n"], directives: [{ type: i0.forwardRef(function () { return i4.NgClass; }), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i0.forwardRef(function () { return i4.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i0.forwardRef(function () { return i4.NgStyle; }), selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i0.forwardRef(function () { return DynamicDialogContent; }), selector: "[pDynamicDialogContent]" }], animations: [
259 trigger('animation', [
260 transition('void => visible', [
261 useAnimation(showAnimation)
262 ]),
263 transition('visible => void', [
264 useAnimation(hideAnimation)
265 ])
266 ])
267 ], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
268i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogComponent, decorators: [{
269 type: Component,
270 args: [{ selector: 'p-dynamicDialog', template: `
271 <div #mask [ngClass]="{'p-dialog-mask':true, 'p-component-overlay-enter p-dialog-mask-scrollblocker': config.modal !== false}">
272 <div [ngClass]="{'p-dialog p-dynamic-dialog p-component':true, 'p-dialog-rtl': config.rtl}" [ngStyle]="config.style" [class]="config.styleClass"
273 [@animation]="{value: 'visible', params: {transform: transformOptions, transition: config.transitionOptions || '150ms cubic-bezier(0, 0, 0.2, 1)'}}"
274 (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)" role="dialog" *ngIf="visible"
275 [style.width]="config.width" [style.height]="config.height">
276 <div class="p-dialog-header" *ngIf="config.showHeader === false ? false: true">
277 <span class="p-dialog-title">{{config.header}}</span>
278 <div class="p-dialog-header-icons">
279 <button [ngClass]="'p-dialog-header-icon p-dialog-header-maximize p-link'" type="button" (click)="hide()" (keydown.enter)="hide()" *ngIf="config.closable !== false">
280 <span class="p-dialog-header-close-icon pi pi-times"></span>
281 </button>
282 </div>
283 </div>
284 <div class="p-dialog-content" [ngStyle]="config.contentStyle">
285 <ng-template pDynamicDialogContent></ng-template>
286 </div>
287 <div class="p-dialog-footer" *ngIf="config.footer">
288 {{config.footer}}
289 </div>
290 </div>
291 </div>
292 `, animations: [
293 trigger('animation', [
294 transition('void => visible', [
295 useAnimation(showAnimation)
296 ]),
297 transition('visible => void', [
298 useAnimation(hideAnimation)
299 ])
300 ])
301 ], changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, host: {
302 'class': 'p-element'
303 }, styles: [".p-dialog-mask{position:fixed;top:0;left:0;width:100%;height:100%;display:flex;justify-content:center;align-items:center;pointer-events:none}.p-dialog-mask.p-component-overlay{pointer-events:auto}.p-dialog{display:flex;flex-direction:column;pointer-events:auto;max-height:90%;transform:scale(1);position:relative}.p-dialog-content{overflow-y:auto;flex-grow:1}.p-dialog-header{display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.p-dialog-footer{flex-shrink:0}.p-dialog .p-dialog-header-icons{display:flex;align-items:center}.p-dialog .p-dialog-header-icon{display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-fluid .p-dialog-footer .p-button{width:auto}.p-dialog-top .p-dialog,.p-dialog-bottom .p-dialog,.p-dialog-left .p-dialog,.p-dialog-right .p-dialog,.p-dialog-top-left .p-dialog,.p-dialog-top-right .p-dialog,.p-dialog-bottom-left .p-dialog,.p-dialog-bottom-right .p-dialog{margin:.75rem;transform:translate(0)}.p-dialog-maximized{transition:none;transform:none;width:100vw!important;height:100vh!important;top:0px!important;left:0px!important;max-height:100%;height:100%}.p-dialog-maximized .p-dialog-content{flex-grow:1}.p-dialog-left{justify-content:flex-start}.p-dialog-right{justify-content:flex-end}.p-dialog-top{align-items:flex-start}.p-dialog-top-left{justify-content:flex-start;align-items:flex-start}.p-dialog-top-right{justify-content:flex-end;align-items:flex-start}.p-dialog-bottom{align-items:flex-end}.p-dialog-bottom-left{justify-content:flex-start;align-items:flex-end}.p-dialog-bottom-right{justify-content:flex-end;align-items:flex-end}.p-dialog .p-resizable-handle{position:absolute;font-size:.1px;display:block;cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.p-confirm-dialog .p-dialog-content{display:flex;align-items:center}\n"] }]
304 }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }, { type: DynamicDialogConfig }, { type: DynamicDialogRef }, { type: i0.NgZone }, { type: i3.PrimeNGConfig }]; }, propDecorators: { insertionPoint: [{
305 type: ViewChild,
306 args: [DynamicDialogContent]
307 }], maskViewChild: [{
308 type: ViewChild,
309 args: ['mask']
310 }] } });
311class DynamicDialogModule {
312}
313DynamicDialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
314DynamicDialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogModule, declarations: [DynamicDialogComponent, DynamicDialogContent], imports: [CommonModule] });
315DynamicDialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogModule, imports: [[CommonModule]] });
316i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DynamicDialogModule, decorators: [{
317 type: NgModule,
318 args: [{
319 imports: [CommonModule],
320 declarations: [DynamicDialogComponent, DynamicDialogContent],
321 entryComponents: [DynamicDialogComponent]
322 }]
323 }] });
324
325class DynamicDialogInjector {
326 constructor(_parentInjector, _additionalTokens) {
327 this._parentInjector = _parentInjector;
328 this._additionalTokens = _additionalTokens;
329 }
330 get(token, notFoundValue, flags) {
331 const value = this._additionalTokens.get(token);
332 if (value)
333 return value;
334 return this._parentInjector.get(token, notFoundValue);
335 }
336}
337
338class DialogService {
339 constructor(componentFactoryResolver, appRef, injector) {
340 this.componentFactoryResolver = componentFactoryResolver;
341 this.appRef = appRef;
342 this.injector = injector;
343 this.dialogComponentRefMap = new Map();
344 }
345 open(componentType, config) {
346 const dialogRef = this.appendDialogComponentToBody(config);
347 this.dialogComponentRefMap.get(dialogRef).instance.childComponentType = componentType;
348 return dialogRef;
349 }
350 appendDialogComponentToBody(config) {
351 const map = new WeakMap();
352 map.set(DynamicDialogConfig, config);
353 const dialogRef = new DynamicDialogRef();
354 map.set(DynamicDialogRef, dialogRef);
355 const sub = dialogRef.onClose.subscribe(() => {
356 this.dialogComponentRefMap.get(dialogRef).instance.close();
357 });
358 const destroySub = dialogRef.onDestroy.subscribe(() => {
359 this.removeDialogComponentFromBody(dialogRef);
360 destroySub.unsubscribe();
361 sub.unsubscribe();
362 });
363 const componentFactory = this.componentFactoryResolver.resolveComponentFactory(DynamicDialogComponent);
364 const componentRef = componentFactory.create(new DynamicDialogInjector(this.injector, map));
365 this.appRef.attachView(componentRef.hostView);
366 const domElem = componentRef.hostView.rootNodes[0];
367 document.body.appendChild(domElem);
368 this.dialogComponentRefMap.set(dialogRef, componentRef);
369 return dialogRef;
370 }
371 removeDialogComponentFromBody(dialogRef) {
372 if (!dialogRef || !this.dialogComponentRefMap.has(dialogRef)) {
373 return;
374 }
375 const dialogComponentRef = this.dialogComponentRefMap.get(dialogRef);
376 this.appRef.detachView(dialogComponentRef.hostView);
377 dialogComponentRef.destroy();
378 this.dialogComponentRefMap.delete(dialogRef);
379 }
380}
381DialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DialogService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.ApplicationRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
382DialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DialogService });
383i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DialogService, decorators: [{
384 type: Injectable
385 }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.ApplicationRef }, { type: i0.Injector }]; } });
386
387/**
388 * Generated bundle index. Do not edit.
389 */
390
391export { DialogService, DynamicDialogComponent, DynamicDialogConfig, DynamicDialogInjector, DynamicDialogModule, DynamicDialogRef };
Note: See TracBrowser for help on using the repository browser.