@firestitch/popover 12.1.2 → 12.2.0

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 (36) hide show
  1. package/app/class/popover-ref.d.ts +34 -34
  2. package/app/components/popover/popover.component.d.ts +6 -50
  3. package/app/components/popover-wrapper/popover-wrapper.component.d.ts +41 -39
  4. package/app/directives/popover.directive.d.ts +55 -0
  5. package/app/enums/position.d.ts +6 -6
  6. package/app/fs-popover.module.d.ts +11 -10
  7. package/app/helpers/create-injector.d.ts +4 -4
  8. package/app/helpers/create-overlay-ref.d.ts +4 -4
  9. package/app/helpers/create-position-strategy.d.ts +4 -4
  10. package/app/helpers/create-template-portal.d.ts +4 -4
  11. package/app/helpers/point-in-rect.d.ts +1 -1
  12. package/app/interfaces/popover-config.interface.d.ts +16 -16
  13. package/app/services/popover.service.d.ts +21 -20
  14. package/bundles/firestitch-popover.umd.js +994 -937
  15. package/bundles/firestitch-popover.umd.js.map +1 -1
  16. package/esm2015/app/class/popover-ref.js +85 -85
  17. package/esm2015/app/components/popover/popover.component.js +17 -191
  18. package/esm2015/app/components/popover-wrapper/popover-wrapper.component.js +121 -118
  19. package/esm2015/app/directives/popover.directive.js +216 -0
  20. package/esm2015/app/enums/position.js +7 -7
  21. package/esm2015/app/fs-popover.module.js +38 -33
  22. package/esm2015/app/helpers/create-injector.js +8 -8
  23. package/esm2015/app/helpers/create-overlay-ref.js +11 -11
  24. package/esm2015/app/helpers/create-position-strategy.js +55 -55
  25. package/esm2015/app/helpers/create-template-portal.js +4 -4
  26. package/esm2015/app/helpers/point-in-rect.js +3 -3
  27. package/esm2015/app/interfaces/popover-config.interface.js +1 -1
  28. package/esm2015/app/services/popover.service.js +64 -59
  29. package/esm2015/firestitch-popover.js +4 -4
  30. package/esm2015/public_api.js +9 -8
  31. package/fesm2015/firestitch-popover.js +572 -521
  32. package/fesm2015/firestitch-popover.js.map +1 -1
  33. package/firestitch-popover.d.ts +5 -5
  34. package/package.json +1 -1
  35. package/public_api.d.ts +6 -5
  36. package/styles.scss +1 -1
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, ChangeDetectionStrategy, ViewChild, HostBinding, Injectable, Optional, Input, NgModule } from '@angular/core';
2
+ import { Component, ChangeDetectionStrategy, ViewChild, HostBinding, TemplateRef, Injectable, Directive, Optional, Input, NgModule } from '@angular/core';
3
3
  import * as i2 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import * as i3 from '@angular/cdk/portal';
@@ -12,550 +12,601 @@ import { guid } from '@firestitch/common';
12
12
  import * as i1 from '@angular/cdk/overlay';
13
13
  import { OverlayConfig } from '@angular/cdk/overlay';
14
14
 
15
- var Position;
16
- (function (Position) {
17
- Position["North"] = "north";
18
- Position["South"] = "south";
19
- Position["East"] = "east";
20
- Position["West"] = "west";
15
+ var Position;
16
+ (function (Position) {
17
+ Position["North"] = "north";
18
+ Position["South"] = "south";
19
+ Position["East"] = "east";
20
+ Position["West"] = "west";
21
21
  })(Position || (Position = {}));
22
22
 
23
- class FsPopoverRef {
24
- constructor(config = {}) {
25
- this._autoShow$ = new BehaviorSubject(true);
26
- this._autoClose$ = new BehaviorSubject(true);
27
- this._componentLoading$ = new BehaviorSubject(true);
28
- this._init(config);
29
- }
30
- get loadingDiameter() {
31
- return this._loadingDiameter;
32
- }
33
- get size() {
34
- return this._size;
35
- }
36
- get theme() {
37
- return this._theme;
38
- }
39
- get loading() {
40
- return this._loading;
41
- }
42
- get autoShow$() {
43
- return this._autoShow$.asObservable();
44
- }
45
- get autoShow() {
46
- return this._autoShow$.getValue();
47
- }
48
- set autoShow(value) {
49
- this._autoShow$.next(value);
50
- }
51
- get autoClose$() {
52
- return this._autoClose$.asObservable();
53
- }
54
- get autoClose() {
55
- return this._autoClose$.getValue();
56
- }
57
- set autoClose(value) {
58
- this._autoClose$.next(value);
59
- }
60
- get componentVisible$() {
61
- return combineLatest([
62
- this.autoShow$,
63
- this.componentLoading$,
64
- ]).pipe(map(([autoShow, componentLoading]) => {
65
- return autoShow || !componentLoading;
66
- }));
67
- }
68
- get componentLoading$() {
69
- return this._componentLoading$.asObservable();
70
- }
71
- get componentLoading() {
72
- return this._componentLoading$.getValue();
73
- }
74
- get wrapperClass() {
75
- return this._wrapperClass;
76
- }
77
- get maxWidth() {
78
- return this._maxWidth;
79
- }
80
- show() {
81
- setTimeout(() => {
82
- this._componentLoading$.next(false);
83
- setTimeout(() => {
84
- this.updatePosition();
85
- });
86
- });
87
- }
88
- close() {
89
- this.overlayRef.detach();
90
- this._componentLoading$.next(true);
91
- }
92
- updatePosition() {
93
- this.overlayRef.updatePosition();
94
- }
95
- _init(config) {
96
- this._wrapperClass = config.wrapperClass;
97
- this._maxWidth = config.maxWidth;
98
- this._loading = config.loading;
99
- this._loadingDiameter = config.loadingDiameter;
100
- this._size = config.size;
101
- this._theme = config.theme;
102
- this._autoShow$.next(config.autoShow);
103
- this._autoClose$.next(config.autoClose);
104
- }
23
+ class FsPopoverRef {
24
+ constructor(config = {}) {
25
+ this._autoShow$ = new BehaviorSubject(true);
26
+ this._autoClose$ = new BehaviorSubject(true);
27
+ this._componentLoading$ = new BehaviorSubject(true);
28
+ this._init(config);
29
+ }
30
+ get loadingDiameter() {
31
+ return this._loadingDiameter;
32
+ }
33
+ get size() {
34
+ return this._size;
35
+ }
36
+ get theme() {
37
+ return this._theme;
38
+ }
39
+ get loading() {
40
+ return this._loading;
41
+ }
42
+ get autoShow$() {
43
+ return this._autoShow$.asObservable();
44
+ }
45
+ get autoShow() {
46
+ return this._autoShow$.getValue();
47
+ }
48
+ set autoShow(value) {
49
+ this._autoShow$.next(value);
50
+ }
51
+ get autoClose$() {
52
+ return this._autoClose$.asObservable();
53
+ }
54
+ get autoClose() {
55
+ return this._autoClose$.getValue();
56
+ }
57
+ set autoClose(value) {
58
+ this._autoClose$.next(value);
59
+ }
60
+ get componentVisible$() {
61
+ return combineLatest([
62
+ this.autoShow$,
63
+ this.componentLoading$,
64
+ ]).pipe(map(([autoShow, componentLoading]) => {
65
+ return autoShow || !componentLoading;
66
+ }));
67
+ }
68
+ get componentLoading$() {
69
+ return this._componentLoading$.asObservable();
70
+ }
71
+ get componentLoading() {
72
+ return this._componentLoading$.getValue();
73
+ }
74
+ get wrapperClass() {
75
+ return this._wrapperClass;
76
+ }
77
+ get maxWidth() {
78
+ return this._maxWidth;
79
+ }
80
+ show() {
81
+ setTimeout(() => {
82
+ this._componentLoading$.next(false);
83
+ setTimeout(() => {
84
+ this.updatePosition();
85
+ });
86
+ });
87
+ }
88
+ close() {
89
+ this.overlayRef.detach();
90
+ this._componentLoading$.next(true);
91
+ }
92
+ updatePosition() {
93
+ this.overlayRef.updatePosition();
94
+ }
95
+ _init(config) {
96
+ this._wrapperClass = config.wrapperClass;
97
+ this._maxWidth = config.maxWidth;
98
+ this._loading = config.loading;
99
+ this._loadingDiameter = config.loadingDiameter;
100
+ this._size = config.size;
101
+ this._theme = config.theme;
102
+ this._autoShow$.next(config.autoShow);
103
+ this._autoClose$.next(config.autoClose);
104
+ }
105
105
  }
106
106
 
107
- class FsPopoverWrapperComponent extends BasePortalOutlet {
108
- constructor(popoverRef, _el, _zone) {
109
- super();
110
- this.popoverRef = popoverRef;
111
- this._el = _el;
112
- this._zone = _zone;
113
- this.hidden = false;
114
- this._updatePosition = new Subject();
115
- this._destroy$ = new Subject();
116
- this._updateClass();
117
- this.wrapperClass = this.popoverRef.wrapperClass;
118
- this.maxWidth = this.popoverRef.maxWidth;
119
- }
120
- set maxWidth(value) {
121
- this._el.nativeElement.style.maxWidth = value ? value + 'px' : void 0;
122
- }
123
- set wrapperClass(value) {
124
- this._wrapperClass = value;
125
- this._updateClass();
126
- }
127
- ngOnInit() {
128
- if (!this.popoverRef.autoShow && this.popoverRef.componentLoading) {
129
- this._watchMousePosition();
130
- }
131
- this._observeContentChanges();
132
- this._listenUpdatePositionRequests();
133
- }
134
- ngOnDestroy() {
135
- this._contentChangesObserver.disconnect();
136
- this._destroy$.next();
137
- this._destroy$.complete();
138
- }
139
- /**
140
- * Attach a TemplatePortal as content to this popover container.
141
- * @param portal Portal to be attached as the popover content.
142
- */
143
- attachTemplatePortal(portal) {
144
- if (this._portalOutlet.hasAttached()) {
145
- throw Error('Popover template already attached');
146
- }
147
- return this._portalOutlet.attachTemplatePortal(portal);
148
- }
149
- /**
150
- * Attach a ComponentPortal as content to this popover container.
151
- * @param portal Portal to be attached as the popover content.
152
- */
153
- attachComponentPortal(portal) {
154
- if (this._portalOutlet.hasAttached()) {
155
- throw Error('Popover component already attached');
156
- }
157
- return this._portalOutlet.attachComponentPortal(portal);
158
- }
159
- updatePosition() {
160
- this._updatePosition.next();
161
- }
162
- _watchMousePosition() {
163
- const componentVisibilityChange$ = this.popoverRef.componentVisible$
164
- .pipe(filter((value) => value === true));
165
- this._zone.runOutsideAngular(() => {
166
- fromEvent(document, 'mousemove')
167
- .pipe(takeUntil(componentVisibilityChange$), takeUntil(this._destroy$))
168
- .subscribe((e) => {
169
- this.spinner.nativeElement.style.left = e.x + 'px';
170
- this.spinner.nativeElement.style.top = (e.y + 20) + 'px';
171
- });
172
- });
173
- }
174
- _updateClass() {
175
- this.class = ['popover-wrapper', this._wrapperClass].filter(Boolean).join(' ');
176
- }
177
- _observeContentChanges() {
178
- const config = {
179
- childList: true,
180
- subtree: true
181
- };
182
- this._contentChangesObserver = new MutationObserver(() => {
183
- this.updatePosition();
184
- });
185
- this._contentChangesObserver.observe(this._el.nativeElement, config);
186
- }
187
- _listenUpdatePositionRequests() {
188
- this._updatePosition
189
- .pipe(debounceTime(50), takeUntil(this._destroy$))
190
- .subscribe(() => {
191
- this.popoverRef.updatePosition();
192
- });
193
- }
194
- }
195
- FsPopoverWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverWrapperComponent, deps: [{ token: FsPopoverRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
196
- FsPopoverWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsPopoverWrapperComponent, selector: "fs-popover-wrapper", host: { properties: { "class": "this.class" } }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }, { propertyName: "spinner", first: true, predicate: ["spinner"], descendants: true }], usesInheritance: true, ngImport: i0, 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 <svg xmlns=\"http://www.w3.org/2000/svg\" [attr.width]=\"popoverRef.loadingDiameter\" [attr.height]=\"popoverRef.loadingDiameter\" viewBox=\"0 0 42 42\" stroke=\"grey\">\n <g fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1 1)\" stroke-width=\"3\">\n <circle stroke-opacity=\".5\" cx=\"18\" cy=\"18\" r=\"18\"/>\n <path d=\"M36 18c0-9.94-8.06-18-18-18\">\n <animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 18 18\" to=\"360 18 18\" dur=\"1s\" repeatCount=\"indefinite\"/>\n </path>\n </g>\n </g>\n </svg>\n</div>\n", styles: [".wrapper{padding:6px;animation:fadeIn ease .2s}.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:70%}.wrapper .fs-popover-arrow{width:0;height:0;font-size:0;line-height:0;position:absolute;z-index:200;z-index:1}.wrapper .fs-popover-arrow.dark{z-index:0}::ng-deep .fs-popover-top .fs-popover-arrow,::ng-deep .fs-popover-bottom .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:#dfdfdf40;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:#dfdfdf40;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:#dfdfdf40;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:#dfdfdf40;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}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
197
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverWrapperComponent, decorators: [{
198
- type: Component,
199
- args: [{
200
- selector: 'fs-popover-wrapper',
201
- templateUrl: 'popover-wrapper.component.html',
202
- styleUrls: ['popover-wrapper.component.scss'],
203
- changeDetection: ChangeDetectionStrategy.OnPush,
204
- }]
205
- }], ctorParameters: function () { return [{ type: FsPopoverRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { _portalOutlet: [{
206
- type: ViewChild,
207
- args: [CdkPortalOutlet, { static: true }]
208
- }], spinner: [{
209
- type: ViewChild,
210
- args: ['spinner']
211
- }], class: [{
212
- type: HostBinding,
213
- args: ['class']
107
+ class FsPopoverWrapperComponent extends BasePortalOutlet {
108
+ constructor(popoverRef, _el, _zone) {
109
+ super();
110
+ this.popoverRef = popoverRef;
111
+ this._el = _el;
112
+ this._zone = _zone;
113
+ this.hidden = false;
114
+ this._updatePosition = new Subject();
115
+ this._destroy$ = new Subject();
116
+ this._updateClass();
117
+ this.wrapperClass = this.popoverRef.wrapperClass;
118
+ this.maxWidth = this.popoverRef.maxWidth;
119
+ }
120
+ set maxWidth(value) {
121
+ this._el.nativeElement.style.maxWidth = value ? value + 'px' : void 0;
122
+ }
123
+ set wrapperClass(value) {
124
+ this._wrapperClass = value;
125
+ this._updateClass();
126
+ }
127
+ ngOnInit() {
128
+ if (!this.popoverRef.autoShow && this.popoverRef.componentLoading) {
129
+ this._watchMousePosition();
130
+ }
131
+ this._observeContentChanges();
132
+ this._listenUpdatePositionRequests();
133
+ }
134
+ ngOnDestroy() {
135
+ this._contentChangesObserver.disconnect();
136
+ this._destroy$.next();
137
+ this._destroy$.complete();
138
+ }
139
+ /**
140
+ * Attach a TemplatePortal as content to this popover container.
141
+ * @param portal Portal to be attached as the popover content.
142
+ */
143
+ attachTemplatePortal(portal) {
144
+ if (this._portalOutlet.hasAttached()) {
145
+ throw Error('Popover template already attached');
146
+ }
147
+ return this._portalOutlet.attachTemplatePortal(portal);
148
+ }
149
+ /**
150
+ * Attach a ComponentPortal as content to this popover container.
151
+ * @param portal Portal to be attached as the popover content.
152
+ */
153
+ attachComponentPortal(portal) {
154
+ if (this._portalOutlet.hasAttached()) {
155
+ throw Error('Popover component already attached');
156
+ }
157
+ return this._portalOutlet.attachComponentPortal(portal);
158
+ }
159
+ setTextualContent(content) {
160
+ this.content = content;
161
+ }
162
+ updatePosition() {
163
+ this._updatePosition.next();
164
+ }
165
+ _watchMousePosition() {
166
+ const componentVisibilityChange$ = this.popoverRef.componentVisible$
167
+ .pipe(filter((value) => value === true));
168
+ this._zone.runOutsideAngular(() => {
169
+ fromEvent(document, 'mousemove')
170
+ .pipe(takeUntil(componentVisibilityChange$), takeUntil(this._destroy$))
171
+ .subscribe((e) => {
172
+ this.spinner.nativeElement.style.left = e.x + 'px';
173
+ this.spinner.nativeElement.style.top = (e.y + 20) + 'px';
174
+ });
175
+ });
176
+ }
177
+ _updateClass() {
178
+ this.class = ['popover-wrapper', this._wrapperClass].filter(Boolean).join(' ');
179
+ }
180
+ _observeContentChanges() {
181
+ const config = {
182
+ childList: true,
183
+ subtree: true
184
+ };
185
+ this._contentChangesObserver = new MutationObserver(() => {
186
+ this.updatePosition();
187
+ });
188
+ this._contentChangesObserver.observe(this._el.nativeElement, config);
189
+ }
190
+ _listenUpdatePositionRequests() {
191
+ this._updatePosition
192
+ .pipe(debounceTime(50), takeUntil(this._destroy$))
193
+ .subscribe(() => {
194
+ this.popoverRef.updatePosition();
195
+ });
196
+ }
197
+ }
198
+ FsPopoverWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverWrapperComponent, deps: [{ token: FsPopoverRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
199
+ FsPopoverWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsPopoverWrapperComponent, selector: "fs-popover-wrapper", host: { properties: { "class": "this.class" } }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }, { propertyName: "spinner", first: true, predicate: ["spinner"], descendants: true }], usesInheritance: true, ngImport: i0, 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-container *ngIf=\"content\">\n {{content}}\n </ng-container>\n\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 <svg xmlns=\"http://www.w3.org/2000/svg\" [attr.width]=\"popoverRef.loadingDiameter\" [attr.height]=\"popoverRef.loadingDiameter\" viewBox=\"0 0 42 42\" stroke=\"grey\">\n <g fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1 1)\" stroke-width=\"3\">\n <circle stroke-opacity=\".5\" cx=\"18\" cy=\"18\" r=\"18\"/>\n <path d=\"M36 18c0-9.94-8.06-18-18-18\">\n <animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 18 18\" to=\"360 18 18\" dur=\"1s\" repeatCount=\"indefinite\"/>\n </path>\n </g>\n </g>\n </svg>\n</div>\n", styles: [".wrapper{padding:6px;animation:fadeIn ease .2s}.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:70%}.wrapper .fs-popover-arrow{width:0;height:0;font-size:0;line-height:0;position:absolute;z-index:200;z-index:1}.wrapper .fs-popover-arrow.dark{z-index:0}::ng-deep .fs-popover-top .fs-popover-arrow,::ng-deep .fs-popover-bottom .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:#dfdfdf40;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:#dfdfdf40;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:#dfdfdf40;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:#dfdfdf40;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}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverWrapperComponent, decorators: [{
201
+ type: Component,
202
+ args: [{
203
+ selector: 'fs-popover-wrapper',
204
+ templateUrl: 'popover-wrapper.component.html',
205
+ styleUrls: ['popover-wrapper.component.scss'],
206
+ changeDetection: ChangeDetectionStrategy.OnPush,
207
+ }]
208
+ }], ctorParameters: function () { return [{ type: FsPopoverRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { _portalOutlet: [{
209
+ type: ViewChild,
210
+ args: [CdkPortalOutlet, { static: true }]
211
+ }], spinner: [{
212
+ type: ViewChild,
213
+ args: ['spinner']
214
+ }], class: [{
215
+ type: HostBinding,
216
+ args: ['class']
214
217
  }] } });
215
218
 
216
- function createPopupPositionStrategy(el, overlay, position) {
217
- let overlayX = 'center';
218
- let overlayY = 'center';
219
- let originX = 'center';
220
- let originY = 'center';
221
- let offsetX = 0;
222
- let offsetY = 0;
223
- let panelClass = [];
224
- switch (position) {
225
- case Position.North:
226
- originY = 'top';
227
- overlayY = 'bottom';
228
- panelClass = ['fs-popover-top'];
229
- offsetY = -8;
230
- break;
231
- case Position.South:
232
- originY = 'bottom';
233
- overlayY = 'top';
234
- panelClass = ['fs-popover-bottom'];
235
- offsetY = 8;
236
- break;
237
- case Position.East:
238
- overlayX = 'start';
239
- originX = 'end';
240
- panelClass = ['fs-popover-left'];
241
- offsetX = 8;
242
- break;
243
- case Position.West:
244
- overlayX = 'end';
245
- originX = 'start';
246
- panelClass = ['fs-popover-right'];
247
- offsetX = -8;
248
- break;
249
- }
250
- return createBasePopupPositionStrategy(el, overlay)
251
- .withPositions([
252
- {
253
- originX: originX,
254
- originY: originY,
255
- overlayX: overlayX,
256
- overlayY: overlayY,
257
- offsetX: offsetX,
258
- offsetY: offsetY,
259
- panelClass: panelClass,
260
- }
261
- ]);
262
- }
263
- function createBasePopupPositionStrategy(el, overlay) {
264
- return overlay.position()
265
- .flexibleConnectedTo(el)
266
- .withGrowAfterOpen(true)
267
- .withFlexibleDimensions(false)
268
- .withViewportMargin(4);
219
+ function createPopupPositionStrategy(el, overlay, position) {
220
+ let overlayX = 'center';
221
+ let overlayY = 'center';
222
+ let originX = 'center';
223
+ let originY = 'center';
224
+ let offsetX = 0;
225
+ let offsetY = 0;
226
+ let panelClass = [];
227
+ switch (position) {
228
+ case Position.North:
229
+ originY = 'top';
230
+ overlayY = 'bottom';
231
+ panelClass = ['fs-popover-top'];
232
+ offsetY = -8;
233
+ break;
234
+ case Position.South:
235
+ originY = 'bottom';
236
+ overlayY = 'top';
237
+ panelClass = ['fs-popover-bottom'];
238
+ offsetY = 8;
239
+ break;
240
+ case Position.East:
241
+ overlayX = 'start';
242
+ originX = 'end';
243
+ panelClass = ['fs-popover-left'];
244
+ offsetX = 8;
245
+ break;
246
+ case Position.West:
247
+ overlayX = 'end';
248
+ originX = 'start';
249
+ panelClass = ['fs-popover-right'];
250
+ offsetX = -8;
251
+ break;
252
+ }
253
+ return createBasePopupPositionStrategy(el, overlay)
254
+ .withPositions([
255
+ {
256
+ originX: originX,
257
+ originY: originY,
258
+ overlayX: overlayX,
259
+ overlayY: overlayY,
260
+ offsetX: offsetX,
261
+ offsetY: offsetY,
262
+ panelClass: panelClass,
263
+ }
264
+ ]);
265
+ }
266
+ function createBasePopupPositionStrategy(el, overlay) {
267
+ return overlay.position()
268
+ .flexibleConnectedTo(el)
269
+ .withGrowAfterOpen(true)
270
+ .withFlexibleDimensions(false)
271
+ .withViewportMargin(4);
269
272
  }
270
273
 
271
- function createOverlayRef(el, overlay, position) {
272
- const config = {
273
- positionStrategy: createPopupPositionStrategy(el, overlay, position),
274
- scrollStrategy: overlay.scrollStrategies.reposition(),
275
- hasBackdrop: false
276
- };
277
- const overlayConfig = new OverlayConfig(config);
278
- return overlay.create(overlayConfig);
274
+ function createOverlayRef(el, overlay, position) {
275
+ const config = {
276
+ positionStrategy: createPopupPositionStrategy(el, overlay, position),
277
+ scrollStrategy: overlay.scrollStrategies.reposition(),
278
+ hasBackdrop: false
279
+ };
280
+ const overlayConfig = new OverlayConfig(config);
281
+ return overlay.create(overlayConfig);
279
282
  }
280
283
 
281
- function createInjector(popoverRef, parentInjector) {
282
- const injectionTokens = new WeakMap([
283
- [FsPopoverRef, popoverRef],
284
- ]);
285
- return new PortalInjector(parentInjector, injectionTokens);
284
+ function createInjector(popoverRef, parentInjector) {
285
+ const injectionTokens = new WeakMap([
286
+ [FsPopoverRef, popoverRef],
287
+ ]);
288
+ return new PortalInjector(parentInjector, injectionTokens);
286
289
  }
287
290
 
288
- function createTempatePortal(template, popoverRef, data) {
289
- return new TemplatePortal(template, void 0, { data: data, popover: popoverRef });
291
+ function createTempatePortal(template, popoverRef, data) {
292
+ return new TemplatePortal(template, void 0, { data: data, popover: popoverRef });
290
293
  }
291
294
 
292
- class FsPopoverService {
293
- constructor(_injector, _overlay) {
294
- this._injector = _injector;
295
- this._overlay = _overlay;
296
- }
297
- get hasActivePopover() {
298
- return !!this._activeElement;
299
- }
300
- get activeElementGUID() {
301
- return this._activeElementGUID;
302
- }
303
- setActivePopoverGUID(value) {
304
- this._activeElementGUID = value;
305
- }
306
- openPopover(el, template, data, popoverRef, position) {
307
- if (this._activeElement) {
308
- this.close(this._activeElement.popoverRef);
309
- }
310
- const overlayRef = createOverlayRef(el, this._overlay, position);
311
- const containerRef = this._openPortalPreview(FsPopoverWrapperComponent, overlayRef, popoverRef);
312
- const templatePortal = createTempatePortal(template, popoverRef, data);
313
- containerRef.instance.attachTemplatePortal(templatePortal);
314
- popoverRef.overlayRef = overlayRef;
315
- this._activeElement = {
316
- overlayRef,
317
- popoverRef,
318
- };
319
- return containerRef.location.nativeElement;
320
- }
321
- close(popoverRef = null) {
322
- if (this._activeElement.popoverRef === popoverRef) {
323
- popoverRef.close();
324
- this._activeElement = void 0;
325
- this._activeElementGUID = void 0;
326
- }
327
- }
328
- _openPortalPreview(component, overlayRef, popoverRef) {
329
- const containerPortal = new ComponentPortal(component, void 0, createInjector(popoverRef, this._injector));
330
- return overlayRef.attach(containerPortal);
331
- }
332
- }
333
- FsPopoverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverService, deps: [{ token: i0.Injector }, { token: i1.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
334
- FsPopoverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverService, providedIn: 'root' });
335
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverService, decorators: [{
336
- type: Injectable,
337
- args: [{
338
- providedIn: 'root',
339
- }]
295
+ class FsPopoverService {
296
+ constructor(_injector, _overlay) {
297
+ this._injector = _injector;
298
+ this._overlay = _overlay;
299
+ }
300
+ get hasActivePopover() {
301
+ return !!this._activeElement;
302
+ }
303
+ get activeElementGUID() {
304
+ return this._activeElementGUID;
305
+ }
306
+ setActivePopoverGUID(value) {
307
+ this._activeElementGUID = value;
308
+ }
309
+ openPopover(el, content, data, popoverRef, position) {
310
+ if (this._activeElement) {
311
+ this.close(this._activeElement.popoverRef);
312
+ }
313
+ const overlayRef = createOverlayRef(el, this._overlay, position);
314
+ const containerRef = this._openPortalPreview(FsPopoverWrapperComponent, overlayRef, popoverRef);
315
+ if (content instanceof TemplateRef) {
316
+ const templatePortal = createTempatePortal(content, popoverRef, data);
317
+ containerRef.instance.attachTemplatePortal(templatePortal);
318
+ }
319
+ else {
320
+ containerRef.instance.setTextualContent(content);
321
+ }
322
+ popoverRef.overlayRef = overlayRef;
323
+ this._activeElement = {
324
+ overlayRef,
325
+ popoverRef,
326
+ };
327
+ return containerRef.location.nativeElement;
328
+ }
329
+ close(popoverRef = null) {
330
+ if (this._activeElement.popoverRef === popoverRef) {
331
+ popoverRef.close();
332
+ this._activeElement = void 0;
333
+ this._activeElementGUID = void 0;
334
+ }
335
+ }
336
+ _openPortalPreview(component, overlayRef, popoverRef) {
337
+ const containerPortal = new ComponentPortal(component, void 0, createInjector(popoverRef, this._injector));
338
+ return overlayRef.attach(containerPortal);
339
+ }
340
+ }
341
+ FsPopoverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverService, deps: [{ token: i0.Injector }, { token: i1.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
342
+ FsPopoverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverService, providedIn: 'root' });
343
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverService, decorators: [{
344
+ type: Injectable,
345
+ args: [{
346
+ providedIn: 'root',
347
+ }]
340
348
  }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i1.Overlay }]; } });
341
349
 
342
- function pointInRect(x1, y1, x2, y2, px, py) {
343
- return (px > x1 && px < x2) && (py > y1 && py < y2);
350
+ function pointInRect(x1, y1, x2, y2, px, py) {
351
+ return (px > x1 && px < x2) && (py > y1 && py < y2);
344
352
  }
345
353
 
346
- class FsPopoverComponent {
347
- constructor(_elRef, _popoverService, _ngZone, _router) {
348
- this._elRef = _elRef;
349
- this._popoverService = _popoverService;
350
- this._ngZone = _ngZone;
351
- this._router = _router;
352
- this._guid = guid('xxxxxxx');
353
- this.leaveDelay = 100;
354
- this.showDelay = 0;
355
- this.maxWidth = 250;
356
- this.autoShow = true;
357
- this.autoClose = true;
358
- this.loadingDiameter = 20;
359
- this.loading = true;
360
- this.indication = true;
361
- this.position = Position.South;
362
- this.theme = 'light';
363
- this.size = 'normal';
364
- this.trigger = 'mouseover';
365
- this._mouseEnter$ = fromEvent(this._elRef.nativeElement, 'mouseenter');
366
- this._mouseMove$ = fromEvent(document, 'mousemove', { passive: true });
367
- this._mouseLeave$ = fromEvent(this._elRef.nativeElement, 'mouseleave');
368
- this._popoverClosed$ = new Subject();
369
- this._destroy$ = new Subject();
370
- }
371
- get openTimer$() {
372
- return timer(this.showDelay);
373
- }
374
- get closeTimer$() {
375
- return timer(this.leaveDelay);
376
- }
377
- ngOnInit() {
378
- this._popoverRef = new FsPopoverRef({
379
- maxWidth: this.maxWidth,
380
- wrapperClass: this.wrapperClass,
381
- autoShow: this.autoShow,
382
- autoClose: this.autoClose,
383
- loadingDiameter: this.loadingDiameter,
384
- loading: this.loading,
385
- size: this.size,
386
- theme: this.theme,
387
- });
388
- this._ngZone.runOutsideAngular(() => {
389
- if (this.trigger === 'click') {
390
- this._listenMouseHostClick();
391
- }
392
- else {
393
- this._listenMouseHostEnter();
394
- }
395
- });
396
- this._listenRouteChange();
397
- }
398
- ngOnDestroy() {
399
- this._popoverClosed$.next();
400
- this._destroy$.next();
401
- }
402
- _closePopover() {
403
- this._popoverClosed$.next();
404
- this._ngZone.run(() => {
405
- this._wrapperElement = null;
406
- if (this._popoverService.hasActivePopover) {
407
- this._popoverService.close(this._popoverRef);
408
- }
409
- });
410
- }
411
- _listenRouteChange() {
412
- this._router.events
413
- .pipe(filter((event) => {
414
- return event instanceof NavigationEnd;
415
- }), pipe(takeUntil(this._destroy$
416
- .pipe(delay(200)))))
417
- .subscribe(() => {
418
- this._closePopover();
419
- });
420
- }
421
- _listenMouseHostClick() {
422
- fromEvent(this._elRef.nativeElement, 'click', { passive: true })
423
- .pipe(tap((e) => {
424
- e.stopPropagation();
425
- this._openPopover();
426
- }), switchMap(() => this._listenMouseHostLeave$()), switchMap(() => this.closeTimer$), takeUntil(this._destroy$))
427
- .subscribe(() => {
428
- this._closePopover();
429
- });
430
- }
431
- _listenMouseHostEnter() {
432
- const actualMouseState$ = merge(this._mouseLeave$.pipe(mapTo(true)), this._mouseEnter$.pipe(mapTo(false)))
433
- .pipe(startWith(false), distinctUntilChanged());
434
- this._mouseEnter$
435
- .pipe(filter(() => {
436
- return !this._wrapperElement;
437
- }), tap(() => {
438
- this._popoverService.setActivePopoverGUID(this._guid);
439
- }), switchMap(() => this.openTimer$),
440
- // we have to check that after all delays mouse still over an elemen
441
- withLatestFrom(actualMouseState$), filter(([_, mouseLeave]) => {
442
- return !mouseLeave;
443
- }), tap(() => this._openPopover()), switchMap(() => this._listenMouseHostLeave$()), switchMap(() => this.closeTimer$), tap(() => this._closePopover()), finalize(() => this._closePopover()), takeUntil(this._destroy$))
444
- .subscribe();
445
- }
446
- _openPopover() {
447
- if (this.trigger === 'mouseover' && this._popoverService.activeElementGUID !== this._guid) {
448
- return;
449
- }
450
- this._hostBounds = this._elRef.nativeElement.getBoundingClientRect();
451
- this._ngZone.run(() => {
452
- this._wrapperElement = this._popoverService.openPopover(this._elRef, this.template, this.data, this._popoverRef, this.position);
453
- });
454
- }
455
- _listenMouseHostLeave$() {
456
- const mouseMove$ = this._mouseMove$
457
- .pipe(debounceTime(50), filter(() => !!this._wrapperElement), filter((event) => {
458
- return this._popoverRef.autoClose && this._mouseLeftTheTargets(event);
459
- }));
460
- const mouseClick$ = fromEvent(this._elRef.nativeElement, 'click');
461
- return merge(mouseMove$, mouseClick$);
462
- //
463
- // return this._mouseLeave$
464
- // .pipe(
465
- // //
466
- // timeoutWith(200, mouseMove$),
467
- // );
468
- }
469
- // Check if mouse left target or popover rects
470
- _mouseLeftTheTargets(event) {
471
- const hostBounds = this._hostBounds;
472
- const popoverBounds = this._wrapperElement.getBoundingClientRect();
473
- const pointInHostRect = pointInRect(hostBounds.x, hostBounds.y, hostBounds.x + hostBounds.width, hostBounds.y + hostBounds.height, event.x, event.y);
474
- const pointInPopoverRect = pointInRect(popoverBounds.x, popoverBounds.y, popoverBounds.x + popoverBounds.width, popoverBounds.y + popoverBounds.height, event.x, event.y);
475
- return !pointInHostRect && !pointInPopoverRect;
476
- }
477
- }
478
- FsPopoverComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverComponent, deps: [{ token: i0.ElementRef }, { token: FsPopoverService }, { token: i0.NgZone }, { token: i2$1.Router, optional: true }], target: i0.ɵɵFactoryTarget.Component });
479
- FsPopoverComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsPopoverComponent, selector: "fs-popover", inputs: { template: "template", data: "data", leaveDelay: "leaveDelay", showDelay: "showDelay", maxWidth: "maxWidth", wrapperClass: "wrapperClass", autoShow: "autoShow", autoClose: "autoClose", loadingDiameter: "loadingDiameter", loading: "loading", indication: "indication", position: "position", theme: "theme", size: "size", trigger: "trigger" }, host: { properties: { "class.indication": "this.indication" } }, ngImport: i0, template: "<span class=\"popover-container\"><ng-content></ng-content></span>\n", styles: [":host{display:inline-flex;cursor:pointer;position:relative}::ng-deep fs-popover.indication .popover-container{text-decoration:underline;-webkit-text-decoration-style:dashed;text-decoration-style:dashed;-webkit-text-decoration-color:#ccc;text-decoration-color:#ccc;text-underline-offset:3px;text-decoration-thickness:1px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
480
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverComponent, decorators: [{
481
- type: Component,
482
- args: [{
483
- selector: 'fs-popover',
484
- templateUrl: 'popover.component.html',
485
- styleUrls: ['popover.component.scss'],
486
- changeDetection: ChangeDetectionStrategy.OnPush
487
- }]
488
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: FsPopoverService }, { type: i0.NgZone }, { type: i2$1.Router, decorators: [{
489
- type: Optional
490
- }] }]; }, propDecorators: { template: [{
491
- type: Input
492
- }], data: [{
493
- type: Input
494
- }], leaveDelay: [{
495
- type: Input
496
- }], showDelay: [{
497
- type: Input
498
- }], maxWidth: [{
499
- type: Input
500
- }], wrapperClass: [{
501
- type: Input
502
- }], autoShow: [{
503
- type: Input
504
- }], autoClose: [{
505
- type: Input
506
- }], loadingDiameter: [{
507
- type: Input
508
- }], loading: [{
509
- type: Input
510
- }], indication: [{
511
- type: Input
512
- }, {
513
- type: HostBinding,
514
- args: ['class.indication']
515
- }], position: [{
516
- type: Input
517
- }], theme: [{
518
- type: Input
519
- }], size: [{
520
- type: Input
521
- }], trigger: [{
522
- type: Input
354
+ class FsPopoverDirective {
355
+ constructor(_elRef, _popoverService, _ngZone, _router) {
356
+ this._elRef = _elRef;
357
+ this._popoverService = _popoverService;
358
+ this._ngZone = _ngZone;
359
+ this._router = _router;
360
+ this._guid = guid('xxxxxxx');
361
+ this.leaveDelay = 100;
362
+ this.showDelay = 0;
363
+ this.maxWidth = 250;
364
+ this.autoShow = true;
365
+ this.autoClose = true;
366
+ this.loadingDiameter = 20;
367
+ this.loading = true;
368
+ this.indication = true;
369
+ this.position = Position.South;
370
+ this.theme = 'light';
371
+ this.size = 'normal';
372
+ this.trigger = 'mouseover';
373
+ this.enabled = true;
374
+ this._initialized = false;
375
+ this._mouseEnter$ = fromEvent(this._elRef.nativeElement, 'mouseenter');
376
+ this._mouseMove$ = fromEvent(document, 'mousemove', { passive: true });
377
+ this._mouseLeave$ = fromEvent(this._elRef.nativeElement, 'mouseleave');
378
+ this._popoverClosed$ = new Subject();
379
+ this._destroy$ = new Subject();
380
+ }
381
+ get openTimer$() {
382
+ return timer(this.showDelay);
383
+ }
384
+ get closeTimer$() {
385
+ return timer(this.leaveDelay);
386
+ }
387
+ ngOnInit() {
388
+ if (this.enabled) {
389
+ this._initialize();
390
+ }
391
+ }
392
+ ngOnChanges(changes) {
393
+ var _a, _b;
394
+ if (((_a = changes.enabled) === null || _a === void 0 ? void 0 : _a.currentValue) !== ((_b = changes.enabled) === null || _b === void 0 ? void 0 : _b.previousValue)) {
395
+ if (this.enabled && !this._initialized) {
396
+ this._initialize();
397
+ }
398
+ }
399
+ }
400
+ ngOnDestroy() {
401
+ this._popoverClosed$.next();
402
+ this._destroy$.next();
403
+ }
404
+ _closePopover() {
405
+ this._popoverClosed$.next();
406
+ this._ngZone.run(() => {
407
+ this._wrapperElement = null;
408
+ if (this._popoverService.hasActivePopover) {
409
+ this._popoverService.close(this._popoverRef);
410
+ }
411
+ });
412
+ }
413
+ _initialize() {
414
+ if (this._initialized) {
415
+ return;
416
+ }
417
+ this._popoverRef = new FsPopoverRef({
418
+ maxWidth: this.maxWidth,
419
+ wrapperClass: this.wrapperClass,
420
+ autoShow: this.autoShow,
421
+ autoClose: this.autoClose,
422
+ loadingDiameter: this.loadingDiameter,
423
+ loading: this.loading,
424
+ size: this.size,
425
+ theme: this.theme,
426
+ });
427
+ this._ngZone.runOutsideAngular(() => {
428
+ if (this.trigger === 'click') {
429
+ this._listenMouseHostClick();
430
+ }
431
+ else {
432
+ this._listenMouseHostEnter();
433
+ }
434
+ });
435
+ this._listenRouteChange();
436
+ this._initialized = true;
437
+ }
438
+ _listenRouteChange() {
439
+ this._router.events
440
+ .pipe(filter((event) => {
441
+ return event instanceof NavigationEnd;
442
+ }), pipe(takeUntil(this._destroy$
443
+ .pipe(delay(200)))))
444
+ .subscribe(() => {
445
+ this._closePopover();
446
+ });
447
+ }
448
+ _listenMouseHostClick() {
449
+ fromEvent(this._elRef.nativeElement, 'click', { passive: true })
450
+ .pipe(filter(() => this.enabled), tap((e) => {
451
+ e.stopPropagation();
452
+ this._openPopover();
453
+ }), switchMap(() => this._listenMouseHostLeave$()), switchMap(() => this.closeTimer$), takeUntil(this._destroy$))
454
+ .subscribe(() => {
455
+ this._closePopover();
456
+ });
457
+ }
458
+ _listenMouseHostEnter() {
459
+ const actualMouseState$ = merge(this._mouseLeave$.pipe(mapTo(true)), this._mouseEnter$.pipe(mapTo(false)))
460
+ .pipe(startWith(false), distinctUntilChanged());
461
+ this._mouseEnter$
462
+ .pipe(filter(() => this.enabled), filter(() => {
463
+ return !this._wrapperElement;
464
+ }), tap(() => {
465
+ this._popoverService.setActivePopoverGUID(this._guid);
466
+ }), switchMap(() => this.openTimer$),
467
+ // we have to check that after all delays mouse still over an elemen
468
+ withLatestFrom(actualMouseState$), filter(([_, mouseLeave]) => {
469
+ return !mouseLeave;
470
+ }), tap(() => this._openPopover()), switchMap(() => this._listenMouseHostLeave$()), switchMap(() => this.closeTimer$), tap(() => this._closePopover()), finalize(() => this._closePopover()), takeUntil(this._destroy$))
471
+ .subscribe();
472
+ }
473
+ _openPopover() {
474
+ if (this.trigger === 'mouseover' && this._popoverService.activeElementGUID !== this._guid) {
475
+ return;
476
+ }
477
+ this._hostBounds = this._elRef.nativeElement.getBoundingClientRect();
478
+ this._ngZone.run(() => {
479
+ if (this.template) {
480
+ this._wrapperElement = this._popoverService.openPopover(this._elRef, this.template, this.data, this._popoverRef, this.position);
481
+ }
482
+ else {
483
+ this._wrapperElement = this._popoverService.openPopover(this._elRef, this.text, this.data, this._popoverRef, this.position);
484
+ }
485
+ });
486
+ }
487
+ _listenMouseHostLeave$() {
488
+ const mouseMove$ = this._mouseMove$
489
+ .pipe(debounceTime(50), filter(() => !!this._wrapperElement), filter((event) => {
490
+ return this._popoverRef.autoClose && this._mouseLeftTheTargets(event);
491
+ }));
492
+ const mouseClick$ = fromEvent(this._elRef.nativeElement, 'click');
493
+ return merge(mouseMove$, mouseClick$);
494
+ //
495
+ // return this._mouseLeave$
496
+ // .pipe(
497
+ // //
498
+ // timeoutWith(200, mouseMove$),
499
+ // );
500
+ }
501
+ // Check if mouse left target or popover rects
502
+ _mouseLeftTheTargets(event) {
503
+ const hostBounds = this._hostBounds;
504
+ const popoverBounds = this._wrapperElement.getBoundingClientRect();
505
+ const pointInHostRect = pointInRect(hostBounds.x, hostBounds.y, hostBounds.x + hostBounds.width, hostBounds.y + hostBounds.height, event.x, event.y);
506
+ const pointInPopoverRect = pointInRect(popoverBounds.x, popoverBounds.y, popoverBounds.x + popoverBounds.width, popoverBounds.y + popoverBounds.height, event.x, event.y);
507
+ return !pointInHostRect && !pointInPopoverRect;
508
+ }
509
+ }
510
+ FsPopoverDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverDirective, deps: [{ token: i0.ElementRef }, { token: FsPopoverService }, { token: i0.NgZone }, { token: i2$1.Router, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
511
+ FsPopoverDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsPopoverDirective, selector: "[fsPopover]", inputs: { text: "text", template: "template", data: "data", leaveDelay: "leaveDelay", showDelay: "showDelay", maxWidth: "maxWidth", wrapperClass: "wrapperClass", autoShow: "autoShow", autoClose: "autoClose", loadingDiameter: "loadingDiameter", loading: "loading", indication: "indication", position: "position", theme: "theme", size: "size", trigger: "trigger", enabled: "enabled" }, host: { properties: { "class.indication": "this.indication" } }, usesOnChanges: true, ngImport: i0 });
512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverDirective, decorators: [{
513
+ type: Directive,
514
+ args: [{
515
+ selector: '[fsPopover]',
516
+ }]
517
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: FsPopoverService }, { type: i0.NgZone }, { type: i2$1.Router, decorators: [{
518
+ type: Optional
519
+ }] }]; }, propDecorators: { text: [{
520
+ type: Input
521
+ }], template: [{
522
+ type: Input
523
+ }], data: [{
524
+ type: Input
525
+ }], leaveDelay: [{
526
+ type: Input
527
+ }], showDelay: [{
528
+ type: Input
529
+ }], maxWidth: [{
530
+ type: Input
531
+ }], wrapperClass: [{
532
+ type: Input
533
+ }], autoShow: [{
534
+ type: Input
535
+ }], autoClose: [{
536
+ type: Input
537
+ }], loadingDiameter: [{
538
+ type: Input
539
+ }], loading: [{
540
+ type: Input
541
+ }], indication: [{
542
+ type: Input
543
+ }, {
544
+ type: HostBinding,
545
+ args: ['class.indication']
546
+ }], position: [{
547
+ type: Input
548
+ }], theme: [{
549
+ type: Input
550
+ }], size: [{
551
+ type: Input
552
+ }], trigger: [{
553
+ type: Input
554
+ }], enabled: [{
555
+ type: Input
523
556
  }] } });
524
557
 
525
- class FsPopoverModule {
526
- }
527
- FsPopoverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
528
- FsPopoverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, declarations: [FsPopoverComponent,
529
- FsPopoverWrapperComponent], imports: [CommonModule,
530
- PortalModule], exports: [FsPopoverComponent] });
531
- FsPopoverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, imports: [[
532
- CommonModule,
533
- PortalModule,
534
- ]] });
535
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, decorators: [{
536
- type: NgModule,
537
- args: [{
538
- imports: [
539
- CommonModule,
540
- PortalModule,
541
- ],
542
- declarations: [
543
- FsPopoverComponent,
544
- FsPopoverWrapperComponent,
545
- ],
546
- exports: [
547
- FsPopoverComponent,
548
- ],
549
- }]
558
+ class FsPopoverComponent extends FsPopoverDirective {
559
+ }
560
+ FsPopoverComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
561
+ FsPopoverComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsPopoverComponent, selector: "fs-popover", usesInheritance: true, ngImport: i0, template: "<span class=\"popover-container\"><ng-content></ng-content></span>\n", styles: [":host{display:inline-flex;cursor:pointer;position:relative}::ng-deep fs-popover.indication .popover-container{text-decoration:underline;-webkit-text-decoration-style:dashed;text-decoration-style:dashed;-webkit-text-decoration-color:#ccc;text-decoration-color:#ccc;text-underline-offset:3px;text-decoration-thickness:1px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
562
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverComponent, decorators: [{
563
+ type: Component,
564
+ args: [{
565
+ selector: 'fs-popover',
566
+ templateUrl: 'popover.component.html',
567
+ styleUrls: ['popover.component.scss'],
568
+ changeDetection: ChangeDetectionStrategy.OnPush
569
+ }]
570
+ }] });
571
+
572
+ class FsPopoverModule {
573
+ }
574
+ FsPopoverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
575
+ FsPopoverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, declarations: [FsPopoverComponent,
576
+ FsPopoverWrapperComponent,
577
+ FsPopoverDirective], imports: [CommonModule,
578
+ PortalModule], exports: [FsPopoverComponent,
579
+ FsPopoverDirective] });
580
+ FsPopoverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, imports: [[
581
+ CommonModule,
582
+ PortalModule,
583
+ ]] });
584
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPopoverModule, decorators: [{
585
+ type: NgModule,
586
+ args: [{
587
+ imports: [
588
+ CommonModule,
589
+ PortalModule,
590
+ ],
591
+ declarations: [
592
+ FsPopoverComponent,
593
+ FsPopoverWrapperComponent,
594
+ FsPopoverDirective,
595
+ ],
596
+ exports: [
597
+ FsPopoverComponent,
598
+ FsPopoverDirective,
599
+ ],
600
+ }]
550
601
  }] });
551
602
 
552
- /*
553
- * Public API Surface of fs-menu
603
+ /*
604
+ * Public API Surface of fs-menu
554
605
  */
555
606
 
556
- /**
557
- * Generated bundle index. Do not edit.
607
+ /**
608
+ * Generated bundle index. Do not edit.
558
609
  */
559
610
 
560
- export { FsPopoverComponent, FsPopoverModule, FsPopoverRef, Position };
611
+ export { FsPopoverComponent, FsPopoverDirective, FsPopoverModule, FsPopoverRef, Position };
561
612
  //# sourceMappingURL=firestitch-popover.js.map