btv-base-controls 0.1.27 → 0.1.29

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 (136) hide show
  1. package/.browserslistrc +16 -0
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +7 -0
  4. package/package.json +10 -24
  5. package/src/assets/icon/state-icons.png +0 -0
  6. package/src/assets/theme/wmGlobals.scss +181 -0
  7. package/src/lib/basic.module.ts +48 -0
  8. package/src/lib/blink-message/blink-message.component.html +1 -0
  9. package/src/lib/blink-message/blink-message.component.scss +4 -0
  10. package/src/lib/blink-message/blink-message.component.ts +54 -0
  11. package/src/lib/btv-icon-button/btv-counter-button.html +18 -0
  12. package/src/lib/btv-icon-button/btv-counter-button.ts +34 -0
  13. package/src/lib/btv-icon-button/btv-icon-button.component.ts +64 -0
  14. package/src/lib/btv-icon-button/btv-icon-button.html +14 -0
  15. package/src/lib/btv-icon-button/btv-icon-button.scss +124 -0
  16. package/src/lib/btv-icon-button/index.ts +1 -0
  17. package/src/lib/btv-progress/btv-progress.component.ts +65 -0
  18. package/src/lib/btv-progress/btv-progress.html +11 -0
  19. package/src/lib/btv-progress/btv-progress.scss +24 -0
  20. package/src/lib/btv-search/btv-search.component.ts +78 -0
  21. package/src/lib/btv-search/btv-search.html +15 -0
  22. package/src/lib/btv-search/btv-search.scss +97 -0
  23. package/{lib/btv-search/index.d.ts → src/lib/btv-search/index.ts} +1 -1
  24. package/src/lib/busy-indicator/busy-indicator.component.ts +13 -0
  25. package/src/lib/busy-indicator/busy-indicator.html +6 -0
  26. package/src/lib/busy-indicator/busy-indicator.scss +86 -0
  27. package/src/lib/custom-tool-tip/custom-tool-tip.component.html +9 -0
  28. package/src/lib/custom-tool-tip/custom-tool-tip.component.scss +47 -0
  29. package/src/lib/custom-tool-tip/custom-tool-tip.component.ts +44 -0
  30. package/src/lib/custom-tool-tip/tool-tip-renderer.directive.ts +111 -0
  31. package/src/lib/illustration/illustration.component.html +412 -0
  32. package/src/lib/illustration/illustration.component.scss +48 -0
  33. package/src/lib/illustration/illustration.component.ts +21 -0
  34. package/src/lib/wm-avatar/avatar.component.ts +179 -0
  35. package/src/lib/wm-avatar/avatar.html +13 -0
  36. package/src/lib/wm-avatar/avatar.scss +3 -0
  37. package/src/lib/wm-back-btn/wm-back-btn.component.ts +19 -0
  38. package/src/lib/wm-back-btn/wm-back-btn.html +7 -0
  39. package/src/lib/wm-back-btn/wm-back-btn.scss +51 -0
  40. package/src/lib/wm-beta-text/wm-beta-text.component.html +1 -0
  41. package/src/lib/wm-beta-text/wm-beta-text.component.scss +44 -0
  42. package/src/lib/wm-beta-text/wm-beta-text.component.ts +14 -0
  43. package/src/lib/wm-info/info-models.ts +22 -0
  44. package/src/lib/wm-info/wm-info.component.ts +238 -0
  45. package/src/lib/wm-info/wm-info.html +19 -0
  46. package/src/lib/wm-info/wm-info.scss +64 -0
  47. package/src/lib/wm-info-card/wm-info-card.component.ts +14 -0
  48. package/src/lib/wm-info-card/wm-info-card.html +13 -0
  49. package/src/lib/wm-info-card/wm-info-card.scss +56 -0
  50. package/src/lib/wm-no-content/wm-no-content.component.ts +17 -0
  51. package/src/lib/wm-no-content/wm-no-content.html +13 -0
  52. package/src/lib/wm-no-content/wm-no-content.scss +60 -0
  53. package/src/lib/wm-panel-bar/wm-panel-bar.component.ts +60 -0
  54. package/src/lib/wm-panel-bar/wm-panel-bar.html +43 -0
  55. package/src/lib/wm-panel-bar/wm-panel-bar.scss +114 -0
  56. package/src/lib/wm-scalable-div/scalable-div.component.ts +106 -0
  57. package/src/lib/wm-scalable-div/scalable-div.html +1 -0
  58. package/src/lib/wm-scalable-div/scalable-div.scss +11 -0
  59. package/src/lib/wm-spinner/wm-spinner.component.ts +129 -0
  60. package/src/lib/wm-spinner/wm-spinner.html +37 -0
  61. package/src/lib/wm-spinner/wm-spinner.scss +72 -0
  62. package/src/lib/wm-state-icon/wm-state-icon.component.html +4 -0
  63. package/src/lib/wm-state-icon/wm-state-icon.component.scss +26 -0
  64. package/src/lib/wm-state-icon/wm-state-icon.component.ts +18 -0
  65. package/src/lib/wm-tag/wm-tag.component.html +8 -0
  66. package/src/lib/wm-tag/wm-tag.component.scss +48 -0
  67. package/src/lib/wm-tag/wm-tag.component.ts +17 -0
  68. package/src/lib/wm-tamplate-image/wm-template-image.component.ts +56 -0
  69. package/src/lib/wm-tamplate-image/wm-template-image.html +3 -0
  70. package/src/lib/wm-tamplate-image/wm-template-image.scss +31 -0
  71. package/src/lib/wm-toggle/wm-toggle.component.ts +20 -0
  72. package/src/lib/wm-toggle/wm-toggle.html +5 -0
  73. package/src/lib/wm-toggle/wm-toggle.scss +33 -0
  74. package/src/models/guidExtension.ts +16 -0
  75. package/src/public-api.ts +29 -0
  76. package/src/test.ts +15 -0
  77. package/tsconfig.lib.json +15 -0
  78. package/tsconfig.lib.prod.json +10 -0
  79. package/tsconfig.spec.json +17 -0
  80. package/esm2022/btv-base-controls.mjs +0 -5
  81. package/esm2022/lib/basic.module.mjs +0 -64
  82. package/esm2022/lib/blink-message/blink-message.component.mjs +0 -54
  83. package/esm2022/lib/btv-icon-button/btv-counter-button.mjs +0 -47
  84. package/esm2022/lib/btv-icon-button/btv-icon-button.component.mjs +0 -91
  85. package/esm2022/lib/btv-progress/btv-progress.component.mjs +0 -71
  86. package/esm2022/lib/btv-search/btv-search.component.mjs +0 -82
  87. package/esm2022/lib/btv-search/index.mjs +0 -2
  88. package/esm2022/lib/busy-indicator/busy-indicator.component.mjs +0 -16
  89. package/esm2022/lib/custom-tool-tip/custom-tool-tip.component.mjs +0 -34
  90. package/esm2022/lib/custom-tool-tip/tool-tip-renderer.directive.mjs +0 -113
  91. package/esm2022/lib/illustration/illustration.component.mjs +0 -17
  92. package/esm2022/lib/wm-avatar/avatar.component.mjs +0 -175
  93. package/esm2022/lib/wm-back-btn/wm-back-btn.component.mjs +0 -26
  94. package/esm2022/lib/wm-beta-text/wm-beta-text.component.mjs +0 -19
  95. package/esm2022/lib/wm-info/info-models.mjs +0 -14
  96. package/esm2022/lib/wm-info/wm-info.component.mjs +0 -239
  97. package/esm2022/lib/wm-info-card/wm-info-card.component.mjs +0 -23
  98. package/esm2022/lib/wm-no-content/wm-no-content.component.mjs +0 -30
  99. package/esm2022/lib/wm-panel-bar/wm-panel-bar.component.mjs +0 -78
  100. package/esm2022/lib/wm-scalable-div/scalable-div.component.mjs +0 -105
  101. package/esm2022/lib/wm-spinner/wm-spinner.component.mjs +0 -135
  102. package/esm2022/lib/wm-state-icon/wm-state-icon.component.mjs +0 -18
  103. package/esm2022/lib/wm-tag/wm-tag.component.mjs +0 -28
  104. package/esm2022/lib/wm-tamplate-image/wm-template-image.component.mjs +0 -71
  105. package/esm2022/lib/wm-toggle/wm-toggle.component.mjs +0 -31
  106. package/esm2022/models/guidExtension.mjs +0 -15
  107. package/esm2022/public-api.mjs +0 -28
  108. package/fesm2022/btv-base-controls.mjs +0 -1500
  109. package/fesm2022/btv-base-controls.mjs.map +0 -1
  110. package/index.d.ts +0 -5
  111. package/lib/basic.module.d.ts +0 -33
  112. package/lib/blink-message/blink-message.component.d.ts +0 -20
  113. package/lib/btv-icon-button/btv-counter-button.d.ts +0 -12
  114. package/lib/btv-icon-button/btv-icon-button.component.d.ts +0 -32
  115. package/lib/btv-progress/btv-progress.component.d.ts +0 -20
  116. package/lib/btv-search/btv-search.component.d.ts +0 -31
  117. package/lib/busy-indicator/busy-indicator.component.d.ts +0 -7
  118. package/lib/custom-tool-tip/custom-tool-tip.component.d.ts +0 -35
  119. package/lib/custom-tool-tip/tool-tip-renderer.directive.d.ts +0 -49
  120. package/lib/illustration/illustration.component.d.ts +0 -10
  121. package/lib/wm-avatar/avatar.component.d.ts +0 -63
  122. package/lib/wm-back-btn/wm-back-btn.component.d.ts +0 -10
  123. package/lib/wm-beta-text/wm-beta-text.component.d.ts +0 -7
  124. package/lib/wm-info/info-models.d.ts +0 -21
  125. package/lib/wm-info/wm-info.component.d.ts +0 -34
  126. package/lib/wm-info-card/wm-info-card.component.d.ts +0 -9
  127. package/lib/wm-no-content/wm-no-content.component.d.ts +0 -11
  128. package/lib/wm-panel-bar/wm-panel-bar.component.d.ts +0 -25
  129. package/lib/wm-scalable-div/scalable-div.component.d.ts +0 -24
  130. package/lib/wm-spinner/wm-spinner.component.d.ts +0 -37
  131. package/lib/wm-state-icon/wm-state-icon.component.d.ts +0 -9
  132. package/lib/wm-tag/wm-tag.component.d.ts +0 -10
  133. package/lib/wm-tamplate-image/wm-template-image.component.d.ts +0 -49
  134. package/lib/wm-toggle/wm-toggle.component.d.ts +0 -11
  135. package/models/guidExtension.d.ts +0 -5
  136. package/public-api.d.ts +0 -24
@@ -0,0 +1,65 @@
1
+ import { Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'btv-progress',
5
+ styleUrls: ['./btv-progress.scss'],
6
+ templateUrl: './btv-progress.html'
7
+ })
8
+ export class BtvProgressComponent {
9
+
10
+ relativeValue: number = 0;
11
+
12
+ private _val: number = 0;
13
+
14
+ @Input() height: number = 8;
15
+ get val() {
16
+ return this._val;
17
+ }
18
+
19
+ @Input() set val(val: number) {
20
+ this._val = val;
21
+ this.relativeValue = this.calcRelativeValue(val, this.max);
22
+ }
23
+
24
+ private _max: number = 0;
25
+ get max() {
26
+ return this._max;
27
+ }
28
+
29
+ @Input() set max(m: number) {
30
+ this._max = m;
31
+ this.relativeValue = this.calcRelativeValue(this._val, m);
32
+ }
33
+
34
+
35
+ @Input() color: string = '#ffffff';
36
+
37
+ public _backColor: string = '#4e5a6b';
38
+
39
+ @Input() set backColor(value: string) {
40
+ if (value) {
41
+ this._backColor = value;
42
+ } else {
43
+ this._backColor = '#4e5a6b';
44
+ }
45
+ }
46
+
47
+ get backColor() {
48
+ return this._backColor;
49
+ }
50
+
51
+ @Input() showFlag: boolean = false;
52
+
53
+ getFlagPosition(): string {
54
+ const max = this.max;
55
+ const val = this.val;
56
+ if (!max) return '0';
57
+ const percent = val / max * 100;
58
+ return percent + '%';
59
+ }
60
+
61
+ calcRelativeValue(value, max) {
62
+ if (!max) return 100;
63
+ return (value / max) * 100;
64
+ }
65
+ }
@@ -0,0 +1,11 @@
1
+ <div class="progress-wrap" [ngStyle]="{'height': height + 'px'}">
2
+ <div class="progress" [ngStyle]="{'background-color': backColor}">
3
+ <div class="progress-fill" [ngStyle]="{'width': relativeValue + '%', 'background-color': color}"></div>
4
+ <!--workaround for css image resolve plugin-->
5
+ <div *ngIf="showFlag" class="flag" [ngStyle]="{
6
+ 'margin-left': getFlagPosition(),
7
+ 'background-image': 'url(./assets/img/flag.png)'
8
+ }">
9
+ </div>
10
+ </div>
11
+ </div>
@@ -0,0 +1,24 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+ .progress-wrap {
3
+ display: block;
4
+ width: 100%;
5
+ height: 8px;
6
+ }
7
+ .progress {
8
+ width: 100%;
9
+ height: 100%;
10
+ position: relative;
11
+ }
12
+ .progress-fill {
13
+ position: absolute;
14
+ height: 100%;
15
+ }
16
+ .flag {
17
+ position: absolute;
18
+ height: 14px;
19
+ width: 8px;
20
+ margin-top: -4px;
21
+ position: absolute;
22
+ background-repeat: no-repeat;
23
+ transform: scale(1, 0.7);
24
+ }
@@ -0,0 +1,78 @@
1
+ import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
2
+ import { fromEvent, Subscription } from 'rxjs';
3
+ import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
4
+
5
+ export class ViewState {
6
+ get isLaptop() { return window.innerWidth <= 1440; }
7
+ get isMobile() { return window.innerWidth <= 1024; }
8
+ get isPhone() { return window.innerWidth <= 767; }
9
+ public isWidthLessOrEqualTo(width: number) { return window.innerWidth <= width; }
10
+ }
11
+
12
+ @Component({
13
+ selector: 'btv-search',
14
+ styleUrls: ['./btv-search.scss'],
15
+ templateUrl: './btv-search.html'
16
+ })
17
+
18
+ export class BtvSearch implements OnInit, OnDestroy {
19
+ @Input() widthAuto: boolean = false;
20
+ @Input() isSmall: boolean = false;
21
+ @Input() searchRight: string;
22
+ @Input() placeholder: string = 'Search';
23
+ @Input() keepExpanded: boolean = false;
24
+ searchFocus: boolean = false;
25
+ view: ViewState = new ViewState();
26
+ @ViewChild('searchBox', { static: true }) box: ElementRef;
27
+ @Output() searchTextChange: EventEmitter<string> = new EventEmitter<string>();
28
+ public expanded: boolean;
29
+ private _searchSubscription: Subscription;
30
+
31
+ private _searchText: string;
32
+
33
+ @Input() set searchText(value: string) {
34
+ if (value === this._searchText) return;
35
+ this._searchText = value;
36
+ if (value) {
37
+ this.expanded = true;
38
+ }
39
+ }
40
+
41
+ get searchText(): string {
42
+ return this._searchText || '';
43
+ }
44
+
45
+ constructor() {
46
+ this.expanded = false;
47
+ }
48
+
49
+ ngOnInit() {
50
+ let box = this.box.nativeElement;
51
+ let observable = fromEvent(box, 'keyup').pipe(
52
+ debounceTime(400),
53
+ distinctUntilChanged(),
54
+ map(x => <string>(<any>x).target.value)
55
+ );
56
+ this._searchSubscription = observable.subscribe(it => {
57
+ this.searchTextChange.emit(it);
58
+ });
59
+ }
60
+
61
+ ngOnDestroy(): void {
62
+ if (this._searchSubscription) this._searchSubscription.unsubscribe();
63
+ }
64
+ toggleSearch() {
65
+ this.expanded = !this.expanded;
66
+ if (this.box && this.expanded) {
67
+ this.box.nativeElement.focus();
68
+ }
69
+ }
70
+
71
+ onFocusOut() {
72
+ if (!this.box.nativeElement.value && this.expanded && !this.keepExpanded) {
73
+ this.expanded = false;
74
+ }
75
+ this.searchFocus = false;
76
+ }
77
+
78
+ }
@@ -0,0 +1,15 @@
1
+ <div class="wm-search flex-row" [ngClass]="{'search-reverse': searchRight == 'right', 'always-opened': keepExpanded, 'small': isSmall}">
2
+ <div class="search-icon inline-col" [ngClass]="{'search-toggle-disabled': keepExpanded || !searchFocus}"
3
+ (click)="toggleSearch()">
4
+ <wm-template-image class="marginXA" icon="search" [light]="(!expanded && !searchFocus) || keepExpanded">
5
+ </wm-template-image>
6
+ </div>
7
+ <div class="search-wrap flex-col"
8
+ [ngClass]="{'search-open': keepExpanded || expanded, 'search-focused': (expanded && searchFocus) || (keepExpanded && searchFocus),
9
+ 'width-auto': widthAuto}">
10
+ <input class="search-field" #searchBox
11
+ [value]="searchText"
12
+ [placeholder]="placeholder"
13
+ (focus)="searchFocus = true" (focusout)="onFocusOut()">
14
+ </div>
15
+ </div>
@@ -0,0 +1,97 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+
3
+ .wm-search,
4
+ .search-wrap,
5
+ .search-field {
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ .wm-search {
10
+ &:hover {
11
+ border-color: var(--brandColor);
12
+ }
13
+ }
14
+
15
+ .wm-search {
16
+ background: var(--pageBackgroundColor);
17
+ height: 36px;
18
+ max-width: 280px;
19
+ border-radius: 4px;
20
+ align-items: center;
21
+ flex: 1 0 100%;
22
+ flex-shrink: 0;
23
+ border: 1px solid var(--secondaryHover);
24
+
25
+ &.small {
26
+ max-width: 140px;
27
+ .search-open {
28
+ width:auto;
29
+ }
30
+ }
31
+ }
32
+
33
+ .search-icon {
34
+ width: 36px;
35
+ height: 100%;
36
+ flex-shrink: 0;
37
+ cursor: pointer;
38
+
39
+ &.search-toggle-disabled {
40
+ cursor: text;
41
+ }
42
+ }
43
+
44
+ .search-wrap {
45
+ width: 0px;
46
+ height: 100%;
47
+ color: var(--mediumFontColor);
48
+ direction: ltr;
49
+ }
50
+
51
+ .search-open {
52
+ width: 280px;
53
+ max-width: 100%;
54
+ flex-grow: 1;
55
+ flex-shrink: 1;
56
+ &.width-auto {
57
+ width: auto;
58
+ }
59
+ }
60
+
61
+ .search-open:hover,
62
+ .search-focused {
63
+ color: var(--strongFontColor);
64
+ }
65
+
66
+
67
+ .search-field {
68
+ width: 100%;
69
+ height: 100%;
70
+ color: inherit;
71
+ text-indent: 0.1em;
72
+ font-size: $fontSize + 2;
73
+ padding: 0;
74
+ background-color: transparent;
75
+ border: none;
76
+ outline: none;
77
+ padding: 0px 8px 0 0;
78
+
79
+ &::placeholder {
80
+ color: var(--disabledTextColor);
81
+ }
82
+
83
+ }
84
+
85
+ .search-reverse {
86
+ display: flex;
87
+ flex-direction: row-reverse;
88
+
89
+ .search-wrap {
90
+ direction: rtl;
91
+ }
92
+
93
+ .search-field {
94
+ direction: ltr;
95
+ padding: 0px 8px;
96
+ }
97
+ }
@@ -1 +1 @@
1
- export * from './btv-search.component';
1
+ export * from './btv-search.component';
@@ -0,0 +1,13 @@
1
+ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'wm-busy-indicator',
5
+ styleUrls: ['./busy-indicator.scss'],
6
+ templateUrl: './busy-indicator.html',
7
+ changeDetection: ChangeDetectionStrategy.OnPush
8
+ })
9
+ export class BusyIndicatorComponent {
10
+
11
+ @Input() public busy: boolean;
12
+ @Input() public long: boolean;
13
+ }
@@ -0,0 +1,6 @@
1
+ <div class="load-snake-wrap" *ngIf="busy" [ngClass]="{'long-snake-wrap': long}">
2
+ <span class="snake-field" ></span>
3
+ <span class="snake" [ngClass]="{'longSnake': long}">
4
+ <span class="snake-shadow" [ngClass]="{'longRotate': long}"></span>
5
+ </span>
6
+ </div>
@@ -0,0 +1,86 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+ .load-snake-wrap {
3
+ width: 120px;
4
+ height: 12px;
5
+ overflow: hidden;
6
+ align-self: flex-end;
7
+ }
8
+
9
+ .snake-field {
10
+ display: block;
11
+ width: 100%;
12
+ height: 2px;
13
+ background: #22252C;
14
+ top: 5px;
15
+ position: relative;
16
+ }
17
+
18
+ .snake {
19
+ display: inline-block;
20
+ width: 80px;
21
+ height: 2px;
22
+ background: #7F868C;
23
+ animation-play-state: running;
24
+ position: relative;
25
+ top: -9px;
26
+ animation: snakeMove 2s linear 0s infinite;
27
+ }
28
+
29
+ .snake-shadow {
30
+ display: inline-block;
31
+ width: 40px;
32
+ height: 8px;
33
+ position: absolute;
34
+ margin-top: -3px;
35
+ animation: rotate 2s linear 0s infinite;
36
+ animation-play-state: running;
37
+ border-radius: 25%;
38
+ }
39
+
40
+ .long-snake-wrap {
41
+ width: 400px;
42
+ }
43
+
44
+ .longSnake {
45
+ animation: snakeLongMove 3s linear 0s infinite;
46
+ }
47
+
48
+ .longRotate {
49
+ animation: rotate 3s linear 0s infinite;
50
+ }
51
+
52
+ @keyframes snakeMove {
53
+ 0% {
54
+ left: -80px;
55
+ }
56
+ 50% {
57
+ left: 200px;
58
+ }
59
+ 100% {
60
+ left: -200px;
61
+ }
62
+ }
63
+
64
+ @keyframes snakeLongMove {
65
+ 0% {
66
+ left: -80px;
67
+ }
68
+ 50% {
69
+ left: 440px;
70
+ }
71
+ 100% {
72
+ left: -200px;
73
+ }
74
+ }
75
+
76
+ @keyframes rotate {
77
+ 0% {
78
+ background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(152, 141, 103, 0.4) 100%);
79
+ right: 0px;
80
+ }
81
+ 100% {
82
+ background: linear-gradient(to left, rgba(0, 0, 0, 0) 0%, rgba(152, 141, 103, 0.4) 100%);
83
+ left: 0px;
84
+ right: unset;
85
+ }
86
+ }
@@ -0,0 +1,9 @@
1
+ <div class="tooltip-container">
2
+ <div class="mat-tooltip">
3
+ <ng-template #simpleText >
4
+ {{text}}
5
+ </ng-template>
6
+ <ng-container *ngTemplateOutlet="contentTemplate || simpleText">
7
+ </ng-container>
8
+ </div>
9
+ </div>
@@ -0,0 +1,47 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+
3
+ .tooltip-container {
4
+ position: relative;
5
+ box-sizing: border-box;
6
+ box-shadow: 0px 16px 16px -1px rgb(5 29 57 / 10%);
7
+ border-radius: 4px;
8
+ -webkit-appearance: none;
9
+
10
+ &:before {
11
+ content: '';
12
+ display: block;
13
+ width: 0;
14
+ height: 0;
15
+ border-style: solid;
16
+ border-width: 6px;
17
+ border-color: transparent;
18
+ left: 50%;
19
+ bottom: -12px;
20
+ margin-left: -6.0625px;
21
+ border-top-color: var(--pageBackgroundColor);
22
+ position: absolute;
23
+ }
24
+ }
25
+
26
+ .mat-tooltip {
27
+ font-family: $fontFamily;
28
+ margin: 0;
29
+ transform-origin: center top;
30
+ box-shadow: none;
31
+ background: var(--pageBackgroundColor);
32
+ color: var(--strongFontColor);
33
+ border-radius: 2px;
34
+ z-index: 1001;
35
+ border-style: solid;
36
+ border-width: 0;
37
+ padding: 5px 5px 5px 6px;
38
+ background-repeat: repeat-x;
39
+ min-width: 20px;
40
+ text-align: center;
41
+ font-size: 14px;
42
+ transform: scale(1)!important;
43
+
44
+ &.mat-tooltip-show {
45
+ animation:none
46
+ }
47
+ }
@@ -0,0 +1,44 @@
1
+ import { Component, OnInit, Input, TemplateRef } from '@angular/core';
2
+
3
+ /**
4
+ * This component will be used to show custom tooltip
5
+ *
6
+ * This component will be rendered using OverlayModule of angular material
7
+ * This component will be rendered by directive on an Overlay
8
+ *
9
+ * CONSUMER will not be using this component directly
10
+ * This component will be hosted in an overlay by ToolTipRenderer directive
11
+ * This component exposes two properties. These two properties will be filled by ToolTipRenderer directive
12
+ * 1. text - This is a simple string which is to be shown in the tooltip; This will be injected in the ToolTipRenderer directive
13
+ * by the consumer
14
+ * 2. contentTemplate - This gives finer control on the content to be shown in the tooltip
15
+ *
16
+ * NOTE - ONLY one should be specified; If BOTH are specified then "template" will be rendered and "text" will be ignored
17
+ */
18
+ @Component({
19
+ selector: 'app-custom-tool-tip',
20
+ templateUrl: './custom-tool-tip.component.html',
21
+ styleUrls: ['./custom-tool-tip.component.scss']
22
+ })
23
+ export class CustomToolTipComponent implements OnInit {
24
+
25
+ /**
26
+ * This is simple text which is to be shown in the tooltip
27
+ */
28
+ @Input() text: string;
29
+
30
+ /**
31
+ * This provides finer control on the content to be visible on the tooltip
32
+ * This template will be injected in McToolTipRenderer directive in the consumer template
33
+ * <ng-template #template>
34
+ * content.....
35
+ * </ng-template>
36
+ */
37
+ @Input() contentTemplate: TemplateRef<any>;
38
+
39
+ constructor() { }
40
+
41
+ ngOnInit() {
42
+ }
43
+
44
+ }
@@ -0,0 +1,111 @@
1
+ import { Directive, Input, TemplateRef, ElementRef, OnInit, HostListener, ComponentRef } from '@angular/core';
2
+ import { ConnectionPositionPair, Overlay, OverlayRef } from '@angular/cdk/overlay';
3
+ import { CustomToolTipComponent } from './custom-tool-tip.component';
4
+ import { ComponentPortal } from '@angular/cdk/portal';
5
+
6
+ @Directive({
7
+ selector: '[customToolTip]'
8
+ })
9
+
10
+ export class ToolTipRendererDirective implements OnInit {
11
+ /**
12
+ * This will be used to show tooltip or not
13
+ * This can be used to show the tooltip conditionally
14
+ */
15
+ @Input() showToolTip: boolean = true;
16
+
17
+ //If this is specified then specified text will be shown in the tooltip
18
+ @Input(`customToolTip`) text: string;
19
+
20
+ //If this is specified then specified template will be rendered in the tooltip
21
+ @Input() contentTemplate: TemplateRef<any>;
22
+ private _overlayRef: OverlayRef;
23
+ @Input() customAnchor?: any;
24
+ @Input() useCustom?: boolean = false;
25
+
26
+ constructor(private _overlay: Overlay,
27
+ private _elementRef: ElementRef) { }
28
+
29
+ /**
30
+ * Init life cycle event handler
31
+ */
32
+ ngOnInit() { }
33
+
34
+ get refElement() {
35
+ if (this.useCustom || this.customAnchor) return this.customAnchor;
36
+ return this._elementRef;
37
+ }
38
+ /**
39
+ * This method will be called whenever mouse enters in the Host element
40
+ * i.e. where this directive is applied
41
+ * This method will show the tooltip by instantiating the McToolTipComponent and attaching to the overlay
42
+ */
43
+ @HostListener('mousemove', ['$event'])
44
+ show() {
45
+ if (this.refElement) this.closeToolTip();
46
+ if (!this.showToolTip || (this.useCustom && !this.customAnchor)) {
47
+ return;
48
+ }
49
+
50
+ const positionPairs: ConnectionPositionPair[] = [
51
+ new ConnectionPositionPair(
52
+ { originX: 'center', originY: 'top' },
53
+ { overlayX: 'center', overlayY: 'bottom' }, 0, 0,
54
+ 'mat-tooltip-panel-above'),
55
+ new ConnectionPositionPair(
56
+ { originX: 'center', originY: 'bottom' },
57
+ { overlayX: 'center', overlayY: 'top' }, 0, 0,
58
+ 'mat-tooltip-panel-below')
59
+
60
+ ];
61
+ const positionStrategy = this._overlay.position()
62
+ .flexibleConnectedTo(this.refElement)
63
+ .withPositions(positionPairs)
64
+ .withFlexibleDimensions(true)
65
+ .withPush(true);
66
+
67
+ this._overlayRef = this._overlay.create({
68
+ panelClass: 'mat-tooltip-panel',
69
+ scrollStrategy: this._overlay.scrollStrategies.close(),
70
+ positionStrategy
71
+ });
72
+ // attach the component if it has not already attached to the overlay
73
+ if (this._overlayRef && !this._overlayRef.hasAttached()) {
74
+ const content = new ComponentPortal(CustomToolTipComponent);
75
+ // todo check this
76
+ const tooltipRef: ComponentRef<CustomToolTipComponent> = this._overlayRef.attach(content) as any;
77
+ tooltipRef.instance.text = this.text;
78
+ tooltipRef.instance.contentTemplate = this.contentTemplate;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * This method will be called when mouse goes out of the host element
84
+ * i.e. where this directive is applied
85
+ * This method will close the tooltip by detaching the overlay from the view
86
+ */
87
+ @HostListener('mouseleave')
88
+ hide() {
89
+ this.closeToolTip();
90
+ }
91
+
92
+ /**
93
+ * Destroy lifecycle event handler
94
+ * This method will make sure to close the tooltip
95
+ * It will be needed in case when app is navigating to different page
96
+ * and user is still seeing the tooltip; In that case we do not want to hang around the
97
+ * tooltip after the page [on which tooltip visible] is destroyed
98
+ */
99
+ ngOnDestroy() {
100
+ this.closeToolTip();
101
+ }
102
+
103
+ /**
104
+ * This method will close the tooltip by detaching the component from the overlay
105
+ */
106
+ private closeToolTip() {
107
+ if (this._overlayRef) {
108
+ this._overlayRef.detach();
109
+ }
110
+ }
111
+ }