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