@agorapulse/ui-components 13.0.0 → 13.0.1
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/agorapulse-ui-components-13.0.1.tgz +0 -0
- package/esm2020/src/lib/tooltip-neo/tooltip-neo.directive.mjs +61 -53
- package/fesm2015/agorapulse-ui-components.mjs +57 -49
- package/fesm2015/agorapulse-ui-components.mjs.map +1 -1
- package/fesm2020/agorapulse-ui-components.mjs +57 -49
- package/fesm2020/agorapulse-ui-components.mjs.map +1 -1
- package/package.json +2 -1
- package/src/lib/tooltip-neo/tooltip-neo.directive.d.ts +17 -17
- package/agorapulse-ui-components-13.0.0.tgz +0 -0
|
@@ -762,85 +762,93 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
|
|
|
762
762
|
}] } });
|
|
763
763
|
|
|
764
764
|
class TooltipNeoDirective {
|
|
765
|
-
constructor(
|
|
766
|
-
this.
|
|
767
|
-
this.
|
|
768
|
-
this.
|
|
769
|
-
this.
|
|
770
|
-
this.
|
|
771
|
-
this.
|
|
772
|
-
this.
|
|
773
|
-
this.
|
|
765
|
+
constructor(elementRef, overlay, overlayPositionBuilder, tooltipNeoService) {
|
|
766
|
+
this.elementRef = elementRef;
|
|
767
|
+
this.overlay = overlay;
|
|
768
|
+
this.overlayPositionBuilder = overlayPositionBuilder;
|
|
769
|
+
this.tooltipNeoService = tooltipNeoService;
|
|
770
|
+
this.destroy$ = new Subject();
|
|
771
|
+
this.hide$ = new Subject();
|
|
772
|
+
this.mouseEntered = false;
|
|
773
|
+
this.show$ = new Subject();
|
|
774
774
|
}
|
|
775
775
|
static enableTooltip(content, contentType, display) {
|
|
776
776
|
return !!content && !!contentType && !!display;
|
|
777
777
|
}
|
|
778
778
|
ngOnChanges(changes) {
|
|
779
|
-
if ((changes?.apTooltipNeo?.currentValue?.display || changes?.apTooltipNeo?.currentValue?.position) && this.
|
|
780
|
-
this.
|
|
781
|
-
this.
|
|
779
|
+
if ((changes?.apTooltipNeo?.currentValue?.display || changes?.apTooltipNeo?.currentValue?.position) && this.mouseEntered) {
|
|
780
|
+
this.setSettings();
|
|
781
|
+
this.allowDisplay ? this.show$.next(true) : this.hide$.next(false);
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
784
|
ngOnInit() {
|
|
785
|
-
this.
|
|
785
|
+
this.initiateTooltip();
|
|
786
786
|
}
|
|
787
787
|
ngOnDestroy() {
|
|
788
|
-
this.
|
|
789
|
-
this.
|
|
790
|
-
this.
|
|
788
|
+
this.detach();
|
|
789
|
+
this.destroy$.next();
|
|
790
|
+
this.destroy$.complete();
|
|
791
791
|
}
|
|
792
|
-
|
|
792
|
+
setSettings() {
|
|
793
793
|
if (typeof this.apTooltipNeo === 'object') {
|
|
794
|
-
const { content
|
|
795
|
-
this.
|
|
796
|
-
this.
|
|
794
|
+
const { content, backgroundColor = '#ffffff', borderColor, contentType = 'text', display = true, displayArrow = true, maxWidth = 'full', position = 'top', title = '' } = this.apTooltipNeo;
|
|
795
|
+
this.params = { content, backgroundColor, borderColor, contentType, display, displayArrow, maxWidth, position, title };
|
|
796
|
+
this.allowDisplay = TooltipNeoDirective.enableTooltip(content, contentType, display);
|
|
797
797
|
}
|
|
798
798
|
if (typeof this.apTooltipNeo === 'string') {
|
|
799
|
-
const content = this.apTooltipNeo
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
799
|
+
const content = this.apTooltipNeo;
|
|
800
|
+
const backgroundColor = '#ffffff';
|
|
801
|
+
const borderColor = undefined;
|
|
802
|
+
const contentType = 'text';
|
|
803
|
+
const display = true;
|
|
804
|
+
const displayArrow = true;
|
|
805
|
+
const maxWidth = 'full';
|
|
806
|
+
const position = 'top';
|
|
807
|
+
const title = '';
|
|
808
|
+
this.params = { content, backgroundColor, borderColor, contentType, position, display, displayArrow, title, maxWidth };
|
|
809
|
+
this.allowDisplay = TooltipNeoDirective.enableTooltip(content, contentType, display);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
initiateTooltip() {
|
|
813
|
+
merge(this.hide$, this.show$)
|
|
806
814
|
.pipe(switchMap(bool => {
|
|
807
815
|
if (!bool) {
|
|
808
816
|
return of(bool);
|
|
809
817
|
}
|
|
810
818
|
return of(bool).pipe(delay(200));
|
|
811
|
-
}), takeUntil(this.
|
|
819
|
+
}), takeUntil(this.destroy$))
|
|
812
820
|
.subscribe(bool => {
|
|
813
821
|
if (bool) {
|
|
814
|
-
this.
|
|
815
|
-
.subscribe(() => this.
|
|
816
|
-
const positionStrategy = this.
|
|
817
|
-
.flexibleConnectedTo(this.
|
|
818
|
-
.withPositions([tooltipNeoPositions[this.
|
|
819
|
-
const scrollStrategy = this.
|
|
820
|
-
this.
|
|
821
|
-
const tooltipRef = this.
|
|
822
|
-
tooltipRef.instance.params = this.
|
|
822
|
+
this.elementRefMouseLeave$ = fromEvent(this.elementRef.nativeElement, 'mouseleave')
|
|
823
|
+
.subscribe(() => this.detach());
|
|
824
|
+
const positionStrategy = this.overlayPositionBuilder
|
|
825
|
+
.flexibleConnectedTo(this.elementRef)
|
|
826
|
+
.withPositions([tooltipNeoPositions[this.params.position]]);
|
|
827
|
+
const scrollStrategy = this.overlay.scrollStrategies.close();
|
|
828
|
+
this.overlayRef = this.overlay.create({ positionStrategy, scrollStrategy });
|
|
829
|
+
const tooltipRef = this.overlayRef.attach(new ComponentPortal(TooltipNeoComponent));
|
|
830
|
+
tooltipRef.instance.params = this.params;
|
|
823
831
|
}
|
|
824
832
|
else {
|
|
825
|
-
this.
|
|
833
|
+
this.detach();
|
|
826
834
|
}
|
|
827
835
|
});
|
|
828
|
-
this.
|
|
829
|
-
.pipe(takeUntil(this.
|
|
830
|
-
.subscribe(() => this.
|
|
836
|
+
this.tooltipNeoService.clickOutside$
|
|
837
|
+
.pipe(takeUntil(this.destroy$))
|
|
838
|
+
.subscribe(() => this.hide$.next(false));
|
|
831
839
|
}
|
|
832
|
-
|
|
833
|
-
this.
|
|
834
|
-
this.
|
|
840
|
+
detach() {
|
|
841
|
+
this.overlayRef && this.overlayRef.hasAttached() && this.overlayRef.detach();
|
|
842
|
+
this.elementRefMouseLeave$ && this.elementRefMouseLeave$.unsubscribe();
|
|
835
843
|
}
|
|
836
844
|
onMouseEnter() {
|
|
837
|
-
this.
|
|
838
|
-
this.
|
|
839
|
-
this.
|
|
845
|
+
this.setSettings();
|
|
846
|
+
this.mouseEntered = true;
|
|
847
|
+
this.allowDisplay && this.params && this.show$.next(true);
|
|
840
848
|
}
|
|
841
849
|
onMouseLeave() {
|
|
842
|
-
this.
|
|
843
|
-
this.
|
|
850
|
+
this.mouseEntered = false;
|
|
851
|
+
this.hide$.next(false);
|
|
844
852
|
}
|
|
845
853
|
}
|
|
846
854
|
/** @nocollapse */ /** @nocollapse */ TooltipNeoDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: TooltipNeoDirective, deps: [{ token: i0.ElementRef }, { token: i1$3.Overlay }, { token: i1$3.OverlayPositionBuilder }, { token: TooltipNeoService }], target: i0.ɵɵFactoryTarget.Directive });
|