@firestitch/popover 9.4.15 → 12.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/app/class/popover-ref.d.ts +34 -34
  2. package/app/components/popover/popover.component.d.ts +50 -47
  3. package/app/components/popover-wrapper/popover-wrapper.component.d.ts +39 -36
  4. package/app/enums/position.d.ts +6 -6
  5. package/app/fs-popover.module.d.ts +13 -4
  6. package/app/helpers/create-injector.d.ts +4 -4
  7. package/app/helpers/create-overlay-ref.d.ts +4 -4
  8. package/app/helpers/create-position-strategy.d.ts +4 -4
  9. package/app/helpers/create-template-portal.d.ts +4 -4
  10. package/app/helpers/point-in-rect.d.ts +1 -1
  11. package/app/interfaces/popover-config.interface.d.ts +16 -16
  12. package/app/services/popover.service.d.ts +20 -17
  13. package/bundles/firestitch-popover.umd.js +872 -779
  14. package/bundles/firestitch-popover.umd.js.map +1 -1
  15. package/esm2015/app/class/popover-ref.js +86 -96
  16. package/esm2015/app/components/popover/popover.component.js +191 -224
  17. package/esm2015/app/components/popover-wrapper/popover-wrapper.component.js +119 -124
  18. package/esm2015/app/enums/position.js +8 -8
  19. package/esm2015/app/fs-popover.module.js +44 -35
  20. package/esm2015/app/helpers/create-injector.js +9 -9
  21. package/esm2015/app/helpers/create-overlay-ref.js +12 -12
  22. package/esm2015/app/helpers/create-position-strategy.js +56 -56
  23. package/esm2015/app/helpers/create-template-portal.js +5 -5
  24. package/esm2015/app/helpers/point-in-rect.js +4 -4
  25. package/esm2015/app/interfaces/popover-config.interface.js +2 -1
  26. package/esm2015/app/services/popover.service.js +56 -60
  27. package/esm2015/firestitch-popover.js +5 -7
  28. package/esm2015/public_api.js +8 -7
  29. package/fesm2015/firestitch-popover.js +540 -578
  30. package/fesm2015/firestitch-popover.js.map +1 -1
  31. package/firestitch-popover.d.ts +5 -6
  32. package/package.json +7 -8
  33. package/public_api.d.ts +5 -4
  34. package/styles.scss +4 -3
  35. package/bundles/firestitch-popover.umd.min.js +0 -16
  36. package/bundles/firestitch-popover.umd.min.js.map +0 -1
  37. package/esm5/app/class/popover-ref.js +0 -152
  38. package/esm5/app/components/popover/popover.component.js +0 -241
  39. package/esm5/app/components/popover-wrapper/popover-wrapper.component.js +0 -138
  40. package/esm5/app/enums/position.js +0 -8
  41. package/esm5/app/fs-popover.module.js +0 -39
  42. package/esm5/app/helpers/create-injector.js +0 -9
  43. package/esm5/app/helpers/create-overlay-ref.js +0 -12
  44. package/esm5/app/helpers/create-position-strategy.js +0 -56
  45. package/esm5/app/helpers/create-template-portal.js +0 -5
  46. package/esm5/app/helpers/point-in-rect.js +0 -4
  47. package/esm5/app/interfaces/popover-config.interface.js +0 -1
  48. package/esm5/app/services/popover.service.js +0 -70
  49. package/esm5/firestitch-popover.js +0 -7
  50. package/esm5/public_api.js +0 -7
  51. package/fesm5/firestitch-popover.js +0 -708
  52. package/fesm5/firestitch-popover.js.map +0 -1
  53. package/firestitch-popover.metadata.json +0 -1
@@ -1,708 +0,0 @@
1
- import { __read, __decorate, __metadata, __extends, __param } from 'tslib';
2
- import { Injectable, ElementRef, NgZone, ViewChild, HostBinding, Component, ChangeDetectionStrategy, Injector, Optional, Input, TemplateRef, NgModule } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
4
- import { CdkPortalOutlet, BasePortalOutlet, PortalInjector, TemplatePortal, ComponentPortal, PortalModule } from '@angular/cdk/portal';
5
- import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
6
- import { NavigationEnd, Router } from '@angular/router';
7
- import { BehaviorSubject, combineLatest, Subject, fromEvent, timer, pipe, merge } from 'rxjs';
8
- import { map, filter, takeUntil, debounceTime, delay, tap, switchMap, mapTo, startWith, distinctUntilChanged, withLatestFrom, finalize } from 'rxjs/operators';
9
- import { guid } from '@firestitch/common';
10
- import { OverlayConfig, Overlay } from '@angular/cdk/overlay';
11
-
12
- var Position;
13
- (function (Position) {
14
- Position["North"] = "north";
15
- Position["South"] = "south";
16
- Position["East"] = "east";
17
- Position["West"] = "west";
18
- })(Position || (Position = {}));
19
-
20
- var FsPopoverRef = /** @class */ (function () {
21
- function FsPopoverRef(config) {
22
- if (config === void 0) { config = {}; }
23
- this._autoShow$ = new BehaviorSubject(true);
24
- this._autoClose$ = new BehaviorSubject(true);
25
- this._componentLoading$ = new BehaviorSubject(true);
26
- this._init(config);
27
- }
28
- Object.defineProperty(FsPopoverRef.prototype, "loadingDiameter", {
29
- get: function () {
30
- return this._loadingDiameter;
31
- },
32
- enumerable: true,
33
- configurable: true
34
- });
35
- Object.defineProperty(FsPopoverRef.prototype, "size", {
36
- get: function () {
37
- return this._size;
38
- },
39
- enumerable: true,
40
- configurable: true
41
- });
42
- Object.defineProperty(FsPopoverRef.prototype, "theme", {
43
- get: function () {
44
- return this._theme;
45
- },
46
- enumerable: true,
47
- configurable: true
48
- });
49
- Object.defineProperty(FsPopoverRef.prototype, "loading", {
50
- get: function () {
51
- return this._loading;
52
- },
53
- enumerable: true,
54
- configurable: true
55
- });
56
- Object.defineProperty(FsPopoverRef.prototype, "autoShow$", {
57
- get: function () {
58
- return this._autoShow$.asObservable();
59
- },
60
- enumerable: true,
61
- configurable: true
62
- });
63
- Object.defineProperty(FsPopoverRef.prototype, "autoShow", {
64
- get: function () {
65
- return this._autoShow$.getValue();
66
- },
67
- set: function (value) {
68
- this._autoShow$.next(value);
69
- },
70
- enumerable: true,
71
- configurable: true
72
- });
73
- Object.defineProperty(FsPopoverRef.prototype, "autoClose$", {
74
- get: function () {
75
- return this._autoClose$.asObservable();
76
- },
77
- enumerable: true,
78
- configurable: true
79
- });
80
- Object.defineProperty(FsPopoverRef.prototype, "autoClose", {
81
- get: function () {
82
- return this._autoClose$.getValue();
83
- },
84
- set: function (value) {
85
- this._autoClose$.next(value);
86
- },
87
- enumerable: true,
88
- configurable: true
89
- });
90
- Object.defineProperty(FsPopoverRef.prototype, "componentVisible$", {
91
- get: function () {
92
- return combineLatest([
93
- this.autoShow$,
94
- this.componentLoading$,
95
- ]).pipe(map(function (_a) {
96
- var _b = __read(_a, 2), autoShow = _b[0], componentLoading = _b[1];
97
- return autoShow || !componentLoading;
98
- }));
99
- },
100
- enumerable: true,
101
- configurable: true
102
- });
103
- Object.defineProperty(FsPopoverRef.prototype, "componentLoading$", {
104
- get: function () {
105
- return this._componentLoading$.asObservable();
106
- },
107
- enumerable: true,
108
- configurable: true
109
- });
110
- Object.defineProperty(FsPopoverRef.prototype, "componentLoading", {
111
- get: function () {
112
- return this._componentLoading$.getValue();
113
- },
114
- enumerable: true,
115
- configurable: true
116
- });
117
- Object.defineProperty(FsPopoverRef.prototype, "wrapperClass", {
118
- get: function () {
119
- return this._wrapperClass;
120
- },
121
- enumerable: true,
122
- configurable: true
123
- });
124
- Object.defineProperty(FsPopoverRef.prototype, "maxWidth", {
125
- get: function () {
126
- return this._maxWidth;
127
- },
128
- enumerable: true,
129
- configurable: true
130
- });
131
- FsPopoverRef.prototype.show = function () {
132
- var _this = this;
133
- setTimeout(function () {
134
- _this._componentLoading$.next(false);
135
- setTimeout(function () {
136
- _this.updatePosition();
137
- });
138
- });
139
- };
140
- FsPopoverRef.prototype.close = function () {
141
- this.overlayRef.detach();
142
- this._componentLoading$.next(true);
143
- };
144
- FsPopoverRef.prototype.updatePosition = function () {
145
- this.overlayRef.updatePosition();
146
- };
147
- FsPopoverRef.prototype._init = function (config) {
148
- this._wrapperClass = config.wrapperClass;
149
- this._maxWidth = config.maxWidth;
150
- this._loading = config.loading;
151
- this._loadingDiameter = config.loadingDiameter;
152
- this._size = config.size;
153
- this._theme = config.theme;
154
- this._autoShow$.next(config.autoShow);
155
- this._autoClose$.next(config.autoClose);
156
- };
157
- FsPopoverRef.ctorParameters = function () { return [
158
- { type: undefined }
159
- ]; };
160
- FsPopoverRef = __decorate([
161
- Injectable(),
162
- __metadata("design:paramtypes", [Object])
163
- ], FsPopoverRef);
164
- return FsPopoverRef;
165
- }());
166
-
167
- var FsPopoverWrapperComponent = /** @class */ (function (_super) {
168
- __extends(FsPopoverWrapperComponent, _super);
169
- function FsPopoverWrapperComponent(popoverRef, _el, _zone) {
170
- var _this = _super.call(this) || this;
171
- _this.popoverRef = popoverRef;
172
- _this._el = _el;
173
- _this._zone = _zone;
174
- _this.hidden = false;
175
- _this._updatePosition = new Subject();
176
- _this._destroy$ = new Subject();
177
- _this._updateClass();
178
- _this.wrapperClass = _this.popoverRef.wrapperClass;
179
- _this.maxWidth = _this.popoverRef.maxWidth;
180
- return _this;
181
- }
182
- Object.defineProperty(FsPopoverWrapperComponent.prototype, "maxWidth", {
183
- set: function (value) {
184
- this._el.nativeElement.style.maxWidth = value ? value + 'px' : void 0;
185
- },
186
- enumerable: true,
187
- configurable: true
188
- });
189
- Object.defineProperty(FsPopoverWrapperComponent.prototype, "wrapperClass", {
190
- set: function (value) {
191
- this._wrapperClass = value;
192
- this._updateClass();
193
- },
194
- enumerable: true,
195
- configurable: true
196
- });
197
- FsPopoverWrapperComponent.prototype.ngOnInit = function () {
198
- if (!this.popoverRef.autoShow && this.popoverRef.componentLoading) {
199
- this._watchMousePosition();
200
- }
201
- this._observeContentChanges();
202
- this._listenUpdatePositionRequests();
203
- };
204
- FsPopoverWrapperComponent.prototype.ngOnDestroy = function () {
205
- this._contentChangesObserver.disconnect();
206
- this._destroy$.next();
207
- this._destroy$.complete();
208
- };
209
- /**
210
- * Attach a TemplatePortal as content to this popover container.
211
- * @param portal Portal to be attached as the popover content.
212
- */
213
- FsPopoverWrapperComponent.prototype.attachTemplatePortal = function (portal) {
214
- if (this._portalOutlet.hasAttached()) {
215
- throw Error('Popover template already attached');
216
- }
217
- return this._portalOutlet.attachTemplatePortal(portal);
218
- };
219
- /**
220
- * Attach a ComponentPortal as content to this popover container.
221
- * @param portal Portal to be attached as the popover content.
222
- */
223
- FsPopoverWrapperComponent.prototype.attachComponentPortal = function (portal) {
224
- if (this._portalOutlet.hasAttached()) {
225
- throw Error('Popover component already attached');
226
- }
227
- return this._portalOutlet.attachComponentPortal(portal);
228
- };
229
- FsPopoverWrapperComponent.prototype.updatePosition = function () {
230
- this._updatePosition.next();
231
- };
232
- FsPopoverWrapperComponent.prototype._watchMousePosition = function () {
233
- var _this = this;
234
- var componentVisibilityChange$ = this.popoverRef.componentVisible$
235
- .pipe(filter(function (value) { return value === true; }));
236
- this._zone.runOutsideAngular(function () {
237
- fromEvent(document, 'mousemove')
238
- .pipe(takeUntil(componentVisibilityChange$), takeUntil(_this._destroy$))
239
- .subscribe(function (e) {
240
- _this.spinner.nativeElement.style.left = e.x + 'px';
241
- _this.spinner.nativeElement.style.top = (e.y + 20) + 'px';
242
- });
243
- });
244
- };
245
- FsPopoverWrapperComponent.prototype._updateClass = function () {
246
- this.class = ['popover-wrapper', this._wrapperClass].filter(Boolean).join(' ');
247
- };
248
- FsPopoverWrapperComponent.prototype._observeContentChanges = function () {
249
- var _this = this;
250
- var config = {
251
- childList: true,
252
- subtree: true
253
- };
254
- this._contentChangesObserver = new MutationObserver(function () {
255
- _this.updatePosition();
256
- });
257
- this._contentChangesObserver.observe(this._el.nativeElement, config);
258
- };
259
- FsPopoverWrapperComponent.prototype._listenUpdatePositionRequests = function () {
260
- var _this = this;
261
- this._updatePosition
262
- .pipe(debounceTime(50), takeUntil(this._destroy$))
263
- .subscribe(function () {
264
- _this.popoverRef.updatePosition();
265
- });
266
- };
267
- FsPopoverWrapperComponent.ctorParameters = function () { return [
268
- { type: FsPopoverRef },
269
- { type: ElementRef },
270
- { type: NgZone }
271
- ]; };
272
- __decorate([
273
- ViewChild(CdkPortalOutlet, { static: true }),
274
- __metadata("design:type", CdkPortalOutlet)
275
- ], FsPopoverWrapperComponent.prototype, "_portalOutlet", void 0);
276
- __decorate([
277
- ViewChild('spinner'),
278
- __metadata("design:type", Object)
279
- ], FsPopoverWrapperComponent.prototype, "spinner", void 0);
280
- __decorate([
281
- HostBinding('class'),
282
- __metadata("design:type", Object)
283
- ], FsPopoverWrapperComponent.prototype, "class", void 0);
284
- FsPopoverWrapperComponent = __decorate([
285
- Component({
286
- selector: 'fs-popover-wrapper',
287
- template: "<div class=\"wrapper\" [ngClass]=\"{\n 'theme-dark' : popoverRef.theme === 'dark',\n 'size-tiny': popoverRef.size === 'tiny',\n 'size-small': popoverRef.size === 'small',\n 'hidden': !(popoverRef.componentVisible$ | async)\n }\">\n <div class=\"mat-elevation-z4 popover-content\">\n <ng-template cdkPortalOutlet></ng-template>\n </div>\n\n <div class=\"fs-popover-arrow light\"></div>\n <div class=\"fs-popover-arrow dark\"></div>\n</div>\n\n<div class=\"loading-spinner\"\n #spinner\n *ngIf=\"popoverRef.loading && !(popoverRef.componentVisible$ | async)\"\n [style.marginLeft]=\"(popoverRef.loadingDiameter * -.25) +'px'\">\n <mat-spinner [diameter]=\"popoverRef.loadingDiameter\"></mat-spinner>\n</div>\n",
288
- changeDetection: ChangeDetectionStrategy.OnPush,
289
- styles: [".wrapper{padding:6px;-webkit-animation:.2s fadeIn;animation:.2s fadeIn}.wrapper.hidden{display:none}.wrapper .popover-content{background:#fff;border-radius:4px;padding:8px;color:#1b1b1b;box-sizing:border-box;overflow:hidden}.wrapper.theme-dark .popover-content{background-color:#707070;color:#fff}.wrapper.size-small .popover-content{font-size:80%}.wrapper.size-tiny .popover-content{font-size:75%}.wrapper .fs-popover-arrow{width:0;height:0;font-size:0;line-height:0;position:absolute;z-index:1}.wrapper .fs-popover-arrow.dark{z-index:0}::ng-deep .fs-popover-bottom .fs-popover-arrow,::ng-deep .fs-popover-top .fs-popover-arrow{border-left:10px solid transparent;border-right:10px solid transparent}::ng-deep .fs-popover-left .fs-popover-arrow,::ng-deep .fs-popover-right .fs-popover-arrow{border-top:10px solid transparent;border-bottom:10px solid transparent}::ng-deep .fs-popover-top .fs-popover-arrow{bottom:-3px;left:calc(50% - 10px);border-top:10px solid #fff}::ng-deep .fs-popover-top .fs-popover-arrow.dark{border-top-color:rgba(223,223,223,.25);bottom:-4px}::ng-deep .fs-popover-bottom .fs-popover-arrow{top:-3px;left:calc(50% - 10px);border-bottom:10px solid #fff}::ng-deep .fs-popover-bottom .fs-popover-arrow.dark{border-bottom-color:rgba(223,223,223,.25);top:-4px}::ng-deep .fs-popover-left .fs-popover-arrow{left:-3px;top:calc(50% - 10px);border-right:10px solid #fff}::ng-deep .fs-popover-left .fs-popover-arrow.dark{border-right-color:rgba(223,223,223,.25);left:-4px}::ng-deep .fs-popover-right .fs-popover-arrow{right:-3px;top:calc(50% - 10px);border-left:10px solid #fff}::ng-deep .fs-popover-right .fs-popover-arrow.dark{border-left-color:rgba(223,223,223,.25);right:-4px}::ng-deep .fs-popover-bottom .wrapper.theme-dark .fs-popover-arrow{border-bottom-color:#707070}::ng-deep .fs-popover-left .wrapper.theme-dark .fs-popover-arrow{border-right-color:#707070}::ng-deep .fs-popover-right .wrapper.theme-dark .fs-popover-arrow{border-left-color:#707070}::ng-deep .fs-popover-top .wrapper.theme-dark .fs-popover-arrow{border-top-color:#707070}.loading-spinner{margin-top:10px}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}"]
290
- }),
291
- __metadata("design:paramtypes", [FsPopoverRef,
292
- ElementRef,
293
- NgZone])
294
- ], FsPopoverWrapperComponent);
295
- return FsPopoverWrapperComponent;
296
- }(BasePortalOutlet));
297
-
298
- function createPopupPositionStrategy(el, overlay, position) {
299
- var overlayX = 'center';
300
- var overlayY = 'center';
301
- var originX = 'center';
302
- var originY = 'center';
303
- var offsetX = 0;
304
- var offsetY = 0;
305
- var panelClass = [];
306
- switch (position) {
307
- case Position.North:
308
- originY = 'top';
309
- overlayY = 'bottom';
310
- panelClass = ['fs-popover-top'];
311
- offsetY = -8;
312
- break;
313
- case Position.South:
314
- originY = 'bottom';
315
- overlayY = 'top';
316
- panelClass = ['fs-popover-bottom'];
317
- offsetY = 8;
318
- break;
319
- case Position.East:
320
- overlayX = 'start';
321
- originX = 'end';
322
- panelClass = ['fs-popover-left'];
323
- offsetX = 8;
324
- break;
325
- case Position.West:
326
- overlayX = 'end';
327
- originX = 'start';
328
- panelClass = ['fs-popover-right'];
329
- offsetX = -8;
330
- break;
331
- }
332
- return createBasePopupPositionStrategy(el, overlay)
333
- .withPositions([
334
- {
335
- originX: originX,
336
- originY: originY,
337
- overlayX: overlayX,
338
- overlayY: overlayY,
339
- offsetX: offsetX,
340
- offsetY: offsetY,
341
- panelClass: panelClass,
342
- }
343
- ]);
344
- }
345
- function createBasePopupPositionStrategy(el, overlay) {
346
- return overlay.position()
347
- .flexibleConnectedTo(el)
348
- .withGrowAfterOpen(true)
349
- .withFlexibleDimensions(false)
350
- .withViewportMargin(4);
351
- }
352
-
353
- function createOverlayRef(el, overlay, position) {
354
- var config = {
355
- positionStrategy: createPopupPositionStrategy(el, overlay, position),
356
- scrollStrategy: overlay.scrollStrategies.reposition(),
357
- hasBackdrop: false
358
- };
359
- var overlayConfig = new OverlayConfig(config);
360
- return overlay.create(overlayConfig);
361
- }
362
-
363
- function createInjector(popoverRef, parentInjector) {
364
- var injectionTokens = new WeakMap([
365
- [FsPopoverRef, popoverRef],
366
- ]);
367
- return new PortalInjector(parentInjector, injectionTokens);
368
- }
369
-
370
- function createTempatePortal(template, popoverRef, data) {
371
- return new TemplatePortal(template, void 0, { data: data, popover: popoverRef });
372
- }
373
-
374
- var FsPopoverService = /** @class */ (function () {
375
- function FsPopoverService(_injector, _overlay) {
376
- this._injector = _injector;
377
- this._overlay = _overlay;
378
- }
379
- Object.defineProperty(FsPopoverService.prototype, "hasActivePopover", {
380
- get: function () {
381
- return !!this._activeElement;
382
- },
383
- enumerable: true,
384
- configurable: true
385
- });
386
- Object.defineProperty(FsPopoverService.prototype, "activeElementGUID", {
387
- get: function () {
388
- return this._activeElementGUID;
389
- },
390
- enumerable: true,
391
- configurable: true
392
- });
393
- FsPopoverService.prototype.setActivePopoverGUID = function (value) {
394
- this._activeElementGUID = value;
395
- };
396
- FsPopoverService.prototype.openPopover = function (el, template, data, popoverRef, position) {
397
- if (this._activeElement) {
398
- this.close(this._activeElement.popoverRef);
399
- }
400
- var overlayRef = createOverlayRef(el, this._overlay, position);
401
- var containerRef = this._openPortalPreview(FsPopoverWrapperComponent, overlayRef, popoverRef);
402
- var templatePortal = createTempatePortal(template, popoverRef, data);
403
- containerRef.instance.attachTemplatePortal(templatePortal);
404
- popoverRef.overlayRef = overlayRef;
405
- this._activeElement = {
406
- overlayRef: overlayRef,
407
- popoverRef: popoverRef,
408
- };
409
- return containerRef.location.nativeElement;
410
- };
411
- FsPopoverService.prototype.close = function (popoverRef) {
412
- if (popoverRef === void 0) { popoverRef = null; }
413
- if (this._activeElement.popoverRef === popoverRef) {
414
- popoverRef.close();
415
- this._activeElement = void 0;
416
- this._activeElementGUID = void 0;
417
- }
418
- };
419
- FsPopoverService.prototype._openPortalPreview = function (component, overlayRef, popoverRef) {
420
- var containerPortal = new ComponentPortal(component, void 0, createInjector(popoverRef, this._injector));
421
- return overlayRef.attach(containerPortal);
422
- };
423
- FsPopoverService.ctorParameters = function () { return [
424
- { type: Injector },
425
- { type: Overlay }
426
- ]; };
427
- FsPopoverService = __decorate([
428
- Injectable(),
429
- __metadata("design:paramtypes", [Injector,
430
- Overlay])
431
- ], FsPopoverService);
432
- return FsPopoverService;
433
- }());
434
-
435
- function pointInRect(x1, y1, x2, y2, px, py) {
436
- return (px > x1 && px < x2) && (py > y1 && py < y2);
437
- }
438
-
439
- var FsPopoverComponent = /** @class */ (function () {
440
- function FsPopoverComponent(_elRef, _popoverService, _ngZone, _router) {
441
- this._elRef = _elRef;
442
- this._popoverService = _popoverService;
443
- this._ngZone = _ngZone;
444
- this._router = _router;
445
- this._guid = guid('xxxxxxx');
446
- this.leaveDelay = 100;
447
- this.showDelay = 0;
448
- this.maxWidth = 250;
449
- this.autoShow = true;
450
- this.autoClose = true;
451
- this.loadingDiameter = 20;
452
- this.loading = true;
453
- this.indication = true;
454
- this.position = Position.South;
455
- this.theme = 'light';
456
- this.size = 'normal';
457
- this.trigger = 'mouseover';
458
- this._mouseEnter$ = fromEvent(this._elRef.nativeElement, 'mouseenter');
459
- this._mouseMove$ = fromEvent(document, 'mousemove', { passive: true });
460
- this._mouseLeave$ = fromEvent(this._elRef.nativeElement, 'mouseleave');
461
- this._popoverClosed$ = new Subject();
462
- this._destroy$ = new Subject();
463
- }
464
- Object.defineProperty(FsPopoverComponent.prototype, "openTimer$", {
465
- get: function () {
466
- return timer(this.showDelay);
467
- },
468
- enumerable: true,
469
- configurable: true
470
- });
471
- Object.defineProperty(FsPopoverComponent.prototype, "closeTimer$", {
472
- get: function () {
473
- return timer(this.leaveDelay);
474
- },
475
- enumerable: true,
476
- configurable: true
477
- });
478
- FsPopoverComponent.prototype.ngOnInit = function () {
479
- var _this = this;
480
- this._popoverRef = new FsPopoverRef({
481
- maxWidth: this.maxWidth,
482
- wrapperClass: this.wrapperClass,
483
- autoShow: this.autoShow,
484
- autoClose: this.autoClose,
485
- loadingDiameter: this.loadingDiameter,
486
- loading: this.loading,
487
- size: this.size,
488
- theme: this.theme,
489
- });
490
- this._ngZone.runOutsideAngular(function () {
491
- if (_this.trigger === 'click') {
492
- _this._listenMouseHostClick();
493
- }
494
- else {
495
- _this._listenMouseHostEnter();
496
- }
497
- });
498
- this._listenRouteChange();
499
- };
500
- FsPopoverComponent.prototype.ngOnDestroy = function () {
501
- this._popoverClosed$.next();
502
- this._destroy$.next();
503
- };
504
- FsPopoverComponent.prototype._closePopover = function () {
505
- var _this = this;
506
- this._popoverClosed$.next();
507
- this._ngZone.run(function () {
508
- _this._wrapperElement = null;
509
- if (_this._popoverService.hasActivePopover) {
510
- _this._popoverService.close(_this._popoverRef);
511
- }
512
- });
513
- };
514
- FsPopoverComponent.prototype._listenRouteChange = function () {
515
- var _this = this;
516
- this._router.events
517
- .pipe(filter(function (event) {
518
- return event instanceof NavigationEnd;
519
- }), pipe(takeUntil(this._destroy$
520
- .pipe(delay(200)))))
521
- .subscribe(function () {
522
- _this._closePopover();
523
- });
524
- };
525
- FsPopoverComponent.prototype._listenMouseHostClick = function () {
526
- var _this = this;
527
- fromEvent(this._elRef.nativeElement, 'click', { passive: true })
528
- .pipe(tap(function (e) {
529
- e.stopPropagation();
530
- _this._openPopover();
531
- }), switchMap(function () { return _this._listenMouseHostLeave$(); }), switchMap(function () { return _this.closeTimer$; }), takeUntil(this._destroy$))
532
- .subscribe(function () {
533
- _this._closePopover();
534
- });
535
- };
536
- FsPopoverComponent.prototype._listenMouseHostEnter = function () {
537
- var _this = this;
538
- var actualMouseState$ = merge(this._mouseLeave$.pipe(mapTo(true)), this._mouseEnter$.pipe(mapTo(false)))
539
- .pipe(startWith(false), distinctUntilChanged());
540
- this._mouseEnter$
541
- .pipe(filter(function () {
542
- return !_this._wrapperElement;
543
- }), tap(function () {
544
- _this._popoverService.setActivePopoverGUID(_this._guid);
545
- }), switchMap(function () { return _this.openTimer$; }),
546
- // we have to check that after all delays mouse still over an elemen
547
- withLatestFrom(actualMouseState$), filter(function (_a) {
548
- var _b = __read(_a, 2), _ = _b[0], mouseLeave = _b[1];
549
- return !mouseLeave;
550
- }), tap(function () { return _this._openPopover(); }), switchMap(function () { return _this._listenMouseHostLeave$(); }), switchMap(function () { return _this.closeTimer$; }), tap(function () { return _this._closePopover(); }), finalize(function () { return _this._closePopover(); }), takeUntil(this._destroy$))
551
- .subscribe();
552
- };
553
- FsPopoverComponent.prototype._openPopover = function () {
554
- var _this = this;
555
- if (this.trigger === 'mouseover' && this._popoverService.activeElementGUID !== this._guid) {
556
- return;
557
- }
558
- this._hostBounds = this._elRef.nativeElement.getBoundingClientRect();
559
- this._ngZone.run(function () {
560
- _this._wrapperElement = _this._popoverService.openPopover(_this._elRef, _this.template, _this.data, _this._popoverRef, _this.position);
561
- });
562
- };
563
- FsPopoverComponent.prototype._listenMouseHostLeave$ = function () {
564
- var _this = this;
565
- var mouseMove$ = this._mouseMove$
566
- .pipe(debounceTime(50), filter(function () { return !!_this._wrapperElement; }), filter(function (event) {
567
- return _this._popoverRef.autoClose && _this._mouseLeftTheTargets(event);
568
- }));
569
- var mouseClick$ = fromEvent(this._elRef.nativeElement, 'click');
570
- return merge(mouseMove$, mouseClick$);
571
- //
572
- // return this._mouseLeave$
573
- // .pipe(
574
- // //
575
- // timeoutWith(200, mouseMove$),
576
- // );
577
- };
578
- // Check if mouse left target or popover rects
579
- FsPopoverComponent.prototype._mouseLeftTheTargets = function (event) {
580
- var hostBounds = this._hostBounds;
581
- var popoverBounds = this._wrapperElement.getBoundingClientRect();
582
- var pointInHostRect = pointInRect(hostBounds.x, hostBounds.y, hostBounds.x + hostBounds.width, hostBounds.y + hostBounds.height, event.x, event.y);
583
- var pointInPopoverRect = pointInRect(popoverBounds.x, popoverBounds.y, popoverBounds.x + popoverBounds.width, popoverBounds.y + popoverBounds.height, event.x, event.y);
584
- return !pointInHostRect && !pointInPopoverRect;
585
- };
586
- FsPopoverComponent.ctorParameters = function () { return [
587
- { type: ElementRef },
588
- { type: FsPopoverService },
589
- { type: NgZone },
590
- { type: Router, decorators: [{ type: Optional }] }
591
- ]; };
592
- __decorate([
593
- Input(),
594
- __metadata("design:type", TemplateRef)
595
- ], FsPopoverComponent.prototype, "template", void 0);
596
- __decorate([
597
- Input(),
598
- __metadata("design:type", Object)
599
- ], FsPopoverComponent.prototype, "data", void 0);
600
- __decorate([
601
- Input(),
602
- __metadata("design:type", Object)
603
- ], FsPopoverComponent.prototype, "leaveDelay", void 0);
604
- __decorate([
605
- Input(),
606
- __metadata("design:type", Object)
607
- ], FsPopoverComponent.prototype, "showDelay", void 0);
608
- __decorate([
609
- Input(),
610
- __metadata("design:type", Object)
611
- ], FsPopoverComponent.prototype, "maxWidth", void 0);
612
- __decorate([
613
- Input(),
614
- __metadata("design:type", String)
615
- ], FsPopoverComponent.prototype, "wrapperClass", void 0);
616
- __decorate([
617
- Input(),
618
- __metadata("design:type", Object)
619
- ], FsPopoverComponent.prototype, "autoShow", void 0);
620
- __decorate([
621
- Input(),
622
- __metadata("design:type", Object)
623
- ], FsPopoverComponent.prototype, "autoClose", void 0);
624
- __decorate([
625
- Input(),
626
- __metadata("design:type", Object)
627
- ], FsPopoverComponent.prototype, "loadingDiameter", void 0);
628
- __decorate([
629
- Input(),
630
- __metadata("design:type", Object)
631
- ], FsPopoverComponent.prototype, "loading", void 0);
632
- __decorate([
633
- Input(),
634
- HostBinding('class.indication'),
635
- __metadata("design:type", Object)
636
- ], FsPopoverComponent.prototype, "indication", void 0);
637
- __decorate([
638
- Input(),
639
- __metadata("design:type", String)
640
- ], FsPopoverComponent.prototype, "position", void 0);
641
- __decorate([
642
- Input(),
643
- __metadata("design:type", String)
644
- ], FsPopoverComponent.prototype, "theme", void 0);
645
- __decorate([
646
- Input(),
647
- __metadata("design:type", String)
648
- ], FsPopoverComponent.prototype, "size", void 0);
649
- __decorate([
650
- Input(),
651
- __metadata("design:type", String)
652
- ], FsPopoverComponent.prototype, "trigger", void 0);
653
- FsPopoverComponent = __decorate([
654
- Component({
655
- selector: 'fs-popover',
656
- template: "<ng-content></ng-content>\n<!-- <div class=\"line-container\">\n <div class=\"line\"></div>\n</div> -->\n\n<div class=\"line\"></div>\n\n",
657
- changeDetection: ChangeDetectionStrategy.OnPush,
658
- styles: [":host{display:inline-flex;cursor:pointer;position:relative}::ng-deep fs-popover.indication .line{width:100%;bottom:0;border-bottom:1px dashed #ccc;position:absolute;opacity:.6}"]
659
- }),
660
- __param(3, Optional()),
661
- __metadata("design:paramtypes", [ElementRef,
662
- FsPopoverService,
663
- NgZone,
664
- Router])
665
- ], FsPopoverComponent);
666
- return FsPopoverComponent;
667
- }());
668
-
669
- var FsPopoverModule = /** @class */ (function () {
670
- function FsPopoverModule() {
671
- }
672
- FsPopoverModule_1 = FsPopoverModule;
673
- FsPopoverModule.forRoot = function () {
674
- return {
675
- ngModule: FsPopoverModule_1,
676
- providers: [FsPopoverService]
677
- };
678
- };
679
- var FsPopoverModule_1;
680
- FsPopoverModule = FsPopoverModule_1 = __decorate([
681
- NgModule({
682
- imports: [
683
- CommonModule,
684
- PortalModule,
685
- MatProgressSpinnerModule,
686
- ],
687
- declarations: [
688
- FsPopoverComponent,
689
- FsPopoverWrapperComponent,
690
- ],
691
- exports: [
692
- FsPopoverComponent,
693
- ],
694
- })
695
- ], FsPopoverModule);
696
- return FsPopoverModule;
697
- }());
698
-
699
- /*
700
- * Public API Surface of fs-menu
701
- */
702
-
703
- /**
704
- * Generated bundle index. Do not edit.
705
- */
706
-
707
- export { FsPopoverComponent, FsPopoverModule, FsPopoverRef, FsPopoverService as ɵa, FsPopoverWrapperComponent as ɵb };
708
- //# sourceMappingURL=firestitch-popover.js.map