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,179 @@
1
+ import { DomSanitizer } from "@angular/platform-browser";
2
+
3
+ import {
4
+ Component,
5
+ Input,
6
+ OnChanges,
7
+ SimpleChanges,
8
+ SecurityContext
9
+ } from '@angular/core';
10
+
11
+ type Style = Partial<CSSStyleDeclaration>;
12
+
13
+ /**
14
+ * list of default colors
15
+ */
16
+ export const defaultColors = [
17
+ '#1abc9c',
18
+ '#3498db',
19
+ '#f1c40f',
20
+ '#8e44ad',
21
+ '#e74c3c',
22
+ '#d35400',
23
+ '#2c3e50',
24
+ '#7f8c8d'
25
+ ];
26
+
27
+
28
+ @Component({
29
+ selector: 'wm-avatar',
30
+ styleUrls: ['./avatar.scss'],
31
+ templateUrl: './avatar.html'
32
+ })
33
+ export class AvatarComponent implements OnChanges {
34
+
35
+ private _name: string | null;
36
+ public avatarText: string | null = null;
37
+ public get name() { return this._name; }
38
+ @Input() public set name(value: string | null) {
39
+ this._name = value;
40
+ this.avatarText = this.formTextAvatar(value);
41
+ };
42
+ @Input() public size: string | number = 50;;
43
+
44
+ public avatarSrc: string | null = null;
45
+ private _src: string | null;
46
+ public get src() { return this._src };
47
+ @Input() public set src(value: string | null) {
48
+ this._src = value;
49
+ this.avatarSrc = this.transformSrc(value);
50
+ }
51
+ @Input() public value: string | null;
52
+ @Input() public round: boolean = true;
53
+ @Input() public cornerRadius: string | number = 0;
54
+ @Input() public textSizeRatio = 3;
55
+ @Input() public bgColor: string | undefined;
56
+ @Input() public fgColor = '#FFF';
57
+ @Input() public borderColor: string | undefined;
58
+ @Input() public style: Style = {};
59
+
60
+ public avatarColors: string[] = defaultColors;
61
+
62
+ constructor(private sanitizer: DomSanitizer) { }
63
+
64
+ public transformSrc(stringInBase64: string): string {
65
+ if (!stringInBase64) return null;
66
+ return this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(stringInBase64));
67
+
68
+ }
69
+
70
+ public formTextAvatar(val: string) {
71
+ if (!val) return '?';
72
+
73
+ const name = val.trim();
74
+ const splitted = name.split(' ');
75
+
76
+ if (splitted.length === 1) {
77
+ if (name.length === 1) {
78
+ return name[0];
79
+ }
80
+ return name[0] + name[1];
81
+ }
82
+
83
+ const length = Math.min(splitted.length, 3);
84
+
85
+ splitted.length = length; // leave first 3 words top
86
+ return splitted.map(it => it[0]).join('');
87
+ }
88
+
89
+ public avatarStyle: Style = {};
90
+ public hostStyle: Style = {};
91
+
92
+ /**
93
+ * Detect inputs change
94
+ *
95
+ * param {{ [propKey: string]: SimpleChange }} changes
96
+ *
97
+ * memberof AvatarComponent
98
+ */
99
+ public ngOnChanges(changes: SimpleChanges): void {
100
+ // reinitialize the avatar component when a source property value has changed
101
+ // the fallback system must be re-invoked with the new values.
102
+ this.initializeAvatar();
103
+ }
104
+
105
+ public getStyles(): void {
106
+
107
+ if (!this.src) {
108
+ this.avatarStyle = this.getInitialsStyle(this.avatarText);
109
+ } else {
110
+ this.avatarStyle = this.getImageStyle();
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Initialize the avatar component and its fallback system
116
+ */
117
+ private initializeAvatar(): void {
118
+ if (!this.src && !this.name) return
119
+ this.getStyles();
120
+ this.hostStyle = {
121
+ width: this.size + 'px',
122
+ height: this.size + 'px'
123
+ };
124
+ }
125
+
126
+ /**
127
+ *
128
+ * returns initials style
129
+ *
130
+ */
131
+ private getInitialsStyle(avatarValue: string): Style {
132
+ return {
133
+ textAlign: 'center',
134
+ borderRadius: this.round ? '100%' : this.cornerRadius + 'px',
135
+ border: this.borderColor ? '1px solid ' + this.borderColor : '',
136
+ textTransform: 'uppercase',
137
+ color: this.fgColor,
138
+ backgroundColor: this.bgColor
139
+ ? this.bgColor
140
+ : this.getRandomColor(avatarValue),
141
+ font:
142
+ Math.floor(+this.size / this.textSizeRatio) +
143
+ 'px Helvetica, Arial, sans-serif',
144
+ lineHeight: this.size + 'px',
145
+ ...this.style
146
+ };
147
+ }
148
+
149
+ /**
150
+ *
151
+ * returns image style
152
+ */
153
+ private getImageStyle(): Style {
154
+ return {
155
+ maxWidth: '100%',
156
+ borderRadius: this.round ? '50%' : this.cornerRadius + 'px',
157
+ border: this.borderColor ? '1px solid ' + this.borderColor : '',
158
+ width: this.size + 'px',
159
+ height: this.size + 'px',
160
+ ...this.style,
161
+ };
162
+ }
163
+
164
+ private getRandomColor(avatarText: string): string {
165
+ if (!avatarText) {
166
+ return 'transparent';
167
+ }
168
+ const asciiCodeSum = this.calculateAsciiCode(avatarText);
169
+ return this.avatarColors[asciiCodeSum % this.avatarColors.length];
170
+ }
171
+
172
+ private calculateAsciiCode(value: string): number {
173
+ return value
174
+ .split('')
175
+ .map(letter => letter.charCodeAt(0))
176
+ .reduce((previous, current) => previous + current);
177
+ }
178
+
179
+ }
@@ -0,0 +1,13 @@
1
+ <div class="avatar-container" [ngStyle]="hostStyle">
2
+ <img *ngIf="avatarSrc; else textAvatar"
3
+ [src]="avatarSrc"
4
+ [width]="size"
5
+ [height]="size"
6
+ [ngStyle]="avatarStyle"
7
+ class="avatar-content" loading="lazy" />
8
+ <ng-template #textAvatar>
9
+ <div *ngIf="avatarText" class="avatar-content" [ngStyle]="avatarStyle">
10
+ {{ avatarText }}
11
+ </div>
12
+ </ng-template>
13
+ </div>
@@ -0,0 +1,3 @@
1
+ :host {
2
+ border-radius: 50%;
3
+ }
@@ -0,0 +1,19 @@
1
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'wm-back-btn',
5
+ styleUrls: ['./wm-back-btn.scss'],
6
+ templateUrl: './wm-back-btn.html',
7
+ changeDetection: ChangeDetectionStrategy.OnPush
8
+ })
9
+ export class WmBackBtnComponent {
10
+
11
+ @Input() public icon: string = 'arrow-long-left';
12
+ @Input() public disabled: boolean = false;
13
+
14
+ @Output() public iClick: EventEmitter<any> = new EventEmitter<any>();
15
+
16
+ public onClick(event) {
17
+ this.iClick.emit(event);
18
+ }
19
+ }
@@ -0,0 +1,7 @@
1
+ <button class="wm-btn-button-wrap" (click)="onClick($event)" type="button">
2
+ <div class="icon-svg" [ngClass]="{'disabled': disabled}" [ngStyle]="{
3
+ 'mask': 'url(./assets/icon/svg/'+ icon+ '.svg) no-repeat center',
4
+ '-webkit-mask':'url(./assets/icon/svg/'+icon+'.svg) no-repeat center'
5
+ }">
6
+ </div>
7
+ </button>
@@ -0,0 +1,51 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+
3
+ :host {
4
+ display: flex;
5
+ align-self: center;
6
+ }
7
+
8
+ .wm-btn-button-wrap {
9
+ background-color: transparent;
10
+ color: var(--mediumFontColor);
11
+ border: none;
12
+ border-radius: 0px;
13
+ font-size: 14px;
14
+ display: flex;
15
+ justify-content: flex-start;
16
+ align-items: center;
17
+ align-content: center;
18
+ outline: 0;
19
+ cursor: pointer;
20
+ height: 30px;
21
+
22
+
23
+ &:hover {
24
+ color: var(--strongFontColor);
25
+
26
+ .icon-svg {
27
+ background-color: var(--strongFontColor);
28
+ }
29
+ }
30
+ }
31
+
32
+ // back btn icon
33
+
34
+ .icon-svg {
35
+ @include flexJA(center, center);
36
+ background-color: var(--mediumFontColor);
37
+ width: 24px;
38
+ height: 24px;
39
+ }
40
+
41
+ .disabled {
42
+ background-color: var(--disabledColor);
43
+ border-color: var(--disabledColor);
44
+ color: var(--lightFontColor);
45
+ cursor: default;
46
+
47
+ &:hover {
48
+ background-color: var(--disabledColor);
49
+ border-color: var(--disabledColor);
50
+ }
51
+ }
@@ -0,0 +1 @@
1
+ <span class="text-title {{wrapClass}}">{{text}}</span>
@@ -0,0 +1,44 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+
3
+ .text-title {
4
+ color: var(--strongFontColor);
5
+ display: block;
6
+ margin-right: 10px;
7
+ text-align: right;
8
+ transform-origin: center center;
9
+ -webkit-transform: rotate(-6deg);
10
+ -moz-transform: rotate(-6deg);
11
+ -ms-transform: rotate(-6deg);
12
+ -o-transform: rotate(-6deg);
13
+ transform: rotate(-6deg);
14
+ font-family: $fontFamily;
15
+ font-weight: 500;
16
+ font-size: 16px;
17
+ min-width: 50px;
18
+ border-radius: 5px;
19
+ padding: 4px;
20
+ margin: auto 12px auto 28px;
21
+ text-align: center;
22
+ }
23
+
24
+ .text-position {
25
+ position: absolute;
26
+ right: 10px;
27
+ height: 23px;
28
+ }
29
+
30
+ .center-position {
31
+ line-height: 22px;
32
+ height: 22px;
33
+ margin-top: 8px;
34
+ }
35
+
36
+ .red-wrapper {
37
+ background-color: var(--dangerColor);
38
+ color: var(--onBrandTextColor);
39
+ }
40
+
41
+ .warning-wrapper {
42
+ background-color: var(--warningColor);
43
+ color: var(--onBrandTextColor);
44
+ }
@@ -0,0 +1,14 @@
1
+ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'wm-beta-text',
5
+ templateUrl: './wm-beta-text.component.html',
6
+ styleUrls: ['./wm-beta-text.component.scss'],
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ })
9
+ export class WmBetaTextComponent {
10
+
11
+ @Input() public text: string = '';
12
+ @Input() public wrapClass: string = '';
13
+
14
+ }
@@ -0,0 +1,22 @@
1
+ import { OriginConnectionPosition, OverlayConnectionPosition } from "@angular/cdk/overlay";
2
+
3
+ export enum InfoType {
4
+ Error = 0,
5
+ Warning = 1,
6
+ InfoMessage = 2,
7
+ TabError = 3,
8
+ TabWarning = 4,
9
+ InfoSmall = 5,
10
+ Filtered = 6,
11
+ InlineDetails = 7,
12
+ SubNavPanel = 8,
13
+ InfoGold = 9
14
+ }
15
+ export interface IWmInfoPositionPopup {
16
+ origin: OriginConnectionPosition;
17
+ overlay: OverlayConnectionPosition;
18
+ arrow: {
19
+ bottom: boolean;
20
+ left: boolean;
21
+ };
22
+ }
@@ -0,0 +1,238 @@
1
+ import { ConnectionPositionPair, Overlay, OverlayRef } from '@angular/cdk/overlay';
2
+ import { TemplatePortal } from '@angular/cdk/portal';
3
+ import { Component, Input, OnInit, ChangeDetectionStrategy, TemplateRef, ElementRef, OnDestroy, ViewContainerRef } from '@angular/core';
4
+ import { InfoType, IWmInfoPositionPopup } from './info-models';
5
+
6
+ const DEFAULT_TOOLTIP_POSITIONS = ['bottom-right', 'bottom-center', 'bottom-left', 'top-right', 'top-center', 'top-left'];
7
+
8
+ @Component({
9
+ selector: 'wm-info',
10
+ styleUrls: ['./wm-info.scss'],
11
+ templateUrl: './wm-info.html',
12
+ changeDetection: ChangeDetectionStrategy.OnPush
13
+ })
14
+
15
+ export class WmInfoComponent implements OnInit, OnDestroy {
16
+
17
+ @Input() preText: string = '';
18
+ @Input() postText: string = '';
19
+ @Input() header: string;
20
+ @Input() type: InfoType = InfoType.Error;
21
+ @Input() popupPosition: string = 'bottom-right';
22
+ @Input() iconAsTemplate: boolean;
23
+ @Input() useThemeForIconTemplate: boolean = false;
24
+ @Input() smallIcon: boolean;
25
+ defaultIconSize = 24;
26
+ smallIconSize = 16;
27
+ positionBottom: boolean = true;
28
+ positionLeft: boolean = true;
29
+ currentPositions: string[] = DEFAULT_TOOLTIP_POSITIONS;
30
+
31
+ get imageSize() {
32
+ return (this.smallIcon ? this.smallIconSize : this.defaultIconSize) + 'px';
33
+ }
34
+
35
+ private _overlayRef: OverlayRef;
36
+
37
+ constructor(private _overlay: Overlay,
38
+ private _elementRef: ElementRef, private viewContainerRef: ViewContainerRef) {
39
+
40
+ }
41
+
42
+ public togglePopup(template: TemplateRef<any>) {
43
+ if (this._overlayRef) {
44
+ this.closePopup();
45
+ } else {
46
+ this.openPopup(template);
47
+ }
48
+ }
49
+
50
+ private openPopup(template: TemplateRef<any>) {
51
+ this.closePopup(); // close any old ones.
52
+
53
+ const positionPairs: ConnectionPositionPair[] = this.currentPositions.map(position => {
54
+ const data: IWmInfoPositionPopup = this.checkPopupPosition(position);
55
+ const vertClass = data.arrow.bottom ? 'info-bottom' : 'info-top';
56
+ const horClass = data.arrow.left ? 'info-left' : 'info-right';
57
+ return new ConnectionPositionPair(
58
+ { originX: data.origin.originX, originY: data.origin.originY },
59
+ { overlayX: data.overlay.overlayX, overlayY: data.overlay.overlayY }, 0, 0,
60
+ ['info-popup-wrapper', vertClass, horClass]
61
+ );
62
+ });
63
+ const positionStrategy = this._overlay.position()
64
+ .flexibleConnectedTo(this._elementRef)
65
+ .withPositions(positionPairs)
66
+ .withFlexibleDimensions(true)
67
+ .withPush(true);
68
+
69
+ this._overlayRef = this._overlay.create({
70
+ panelClass: ['mat-tooltip-panel', 'modal', 'is-active'],
71
+ hasBackdrop: true,
72
+ backdropClass: 'modal-background',
73
+ scrollStrategy: this._overlay.scrollStrategies.reposition(),
74
+ positionStrategy
75
+ });
76
+ if (this._overlayRef && !this._overlayRef.hasAttached()) {
77
+ this._overlayRef.attach(new TemplatePortal(template, this.viewContainerRef));
78
+ this._overlayRef.backdropClick().subscribe(() => this.closePopup());
79
+ }
80
+ }
81
+
82
+ private closePopup() {
83
+ if (this._overlayRef) {
84
+ this._overlayRef.detach();
85
+ this._overlayRef = undefined;
86
+ }
87
+ }
88
+
89
+ ngOnInit() {
90
+ if (this.popupPosition !== DEFAULT_TOOLTIP_POSITIONS[0]) {
91
+ const otherPositions = [];
92
+ const filteredByFirstPosition = DEFAULT_TOOLTIP_POSITIONS
93
+ .filter((item) => {
94
+ if (item === this.popupPosition) return false;
95
+ if (item.startsWith(this.popupPosition.split('-')[0])) {
96
+ return true;
97
+ } else {
98
+ otherPositions.push(item);
99
+ return false;
100
+ }
101
+ });
102
+ this.currentPositions = [this.popupPosition].concat(filteredByFirstPosition).concat(otherPositions);
103
+ }
104
+ }
105
+
106
+ public getIconName() {
107
+ switch (this.type) {
108
+ case InfoType.Error:
109
+ return 'error';
110
+ case InfoType.Warning:
111
+ return 'warning';
112
+ case InfoType.TabError:
113
+ return 'bo-error';
114
+ case InfoType.TabWarning:
115
+ return 'bo-warning';
116
+ case InfoType.InfoSmall:
117
+ return 'info-s';
118
+ case InfoType.Filtered:
119
+ return 'filter';
120
+ case InfoType.InlineDetails:
121
+ return 'eye-pick';
122
+ case InfoType.SubNavPanel:
123
+ this.smallIcon = true;
124
+ return 'sub-nav-warning';
125
+ case InfoType.InfoGold:
126
+ return 'info-gold';
127
+ default:
128
+ return 'info';
129
+ }
130
+ }
131
+
132
+ ngOnDestroy(): void {
133
+ this.closePopup();
134
+ }
135
+
136
+ checkPopupPosition(value: string): IWmInfoPositionPopup {
137
+ let currentPosition: IWmInfoPositionPopup;
138
+ switch (value) {
139
+ case 'bottom-left':
140
+ currentPosition = {
141
+ origin: {
142
+ originX: 'end',
143
+ originY: 'bottom'
144
+ },
145
+ overlay: {
146
+ overlayX: 'end',
147
+ overlayY: 'top'
148
+ },
149
+ arrow: {
150
+ bottom: true,
151
+ left: true,
152
+ }
153
+ };
154
+ break;
155
+ case 'top-right':
156
+ currentPosition = {
157
+ origin: {
158
+ originX: 'start',
159
+ originY: 'top',
160
+ },
161
+ overlay: {
162
+ overlayX: 'start',
163
+ overlayY: 'bottom',
164
+ },
165
+ arrow: {
166
+ bottom: false,
167
+ left: true,
168
+ }
169
+ };
170
+ break;
171
+ case 'top-left':
172
+ currentPosition = {
173
+ origin: {
174
+ originX: 'end',
175
+ originY: 'top',
176
+ },
177
+ overlay: {
178
+ overlayX: 'end',
179
+ overlayY: 'bottom',
180
+ },
181
+ arrow: {
182
+ bottom: false,
183
+ left: false,
184
+ }
185
+ };
186
+ break;
187
+ case 'top-center':
188
+ currentPosition = {
189
+ origin: {
190
+ originX: 'center',
191
+ originY: 'top',
192
+ },
193
+ overlay: {
194
+ overlayX: 'center',
195
+ overlayY: 'bottom',
196
+ },
197
+ arrow: {
198
+ bottom: false,
199
+ left: true,
200
+ }
201
+ };
202
+ break;
203
+ case 'bottom-center':
204
+ currentPosition = {
205
+ origin: {
206
+ originX: 'center',
207
+ originY: 'bottom',
208
+ },
209
+ overlay: {
210
+ overlayX: 'center',
211
+ overlayY: 'top',
212
+ },
213
+ arrow: {
214
+ bottom: true,
215
+ left: true,
216
+ }
217
+ };
218
+ break;
219
+ case 'bottom-right':
220
+ default:
221
+ currentPosition = {
222
+ origin: {
223
+ originX: 'start',
224
+ originY: 'bottom',
225
+ },
226
+ overlay: {
227
+ overlayX: 'start',
228
+ overlayY: 'top',
229
+ },
230
+ arrow: {
231
+ bottom: true,
232
+ left: false,
233
+ }
234
+ };
235
+ }
236
+ return currentPosition;
237
+ }
238
+ }
@@ -0,0 +1,19 @@
1
+ <ng-template #popupTemplate>
2
+ <div class="u-arrow">
3
+ </div>
4
+ <div class="u-info-content" [ngClass]="{'p-error': type === 0, 'p-warning': type === 1, 'p-info': type === 2}">
5
+ <span *ngIf="header" [innerHTML]="header"></span>
6
+ <ng-content></ng-content>
7
+ </div>
8
+ </ng-template>
9
+ <div class="info-wrap flex-row" [ngClass]="{'p-error': type === 0, 'p-warning': type === 1, 'p-info': type === 2}">
10
+ <span class="info-label" *ngIf="preText">{{preText}}</span>
11
+ <span class="info-icon" (click)="togglePopup(popupTemplate)">
12
+ <wm-template-image *ngIf="iconAsTemplate" [icon]="getIconName()" [size]="imageSize"
13
+ [active]="useThemeForIconTemplate">
14
+ </wm-template-image>
15
+ <img *ngIf="!iconAsTemplate" [attr.width]="imageSize" [attr.height]="imageSize"
16
+ src="{{'./assets/icon/svg/' + getIconName() + '.svg'}}" alt="{{getIconName()}}" />
17
+ </span>
18
+ <span class="info-label" *ngIf="postText">{{postText}}</span>
19
+ </div>
@@ -0,0 +1,64 @@
1
+ @import './../../assets/theme/wmGlobals.scss';
2
+ .info-wrap {
3
+ @include flexJA(flex-start, center);
4
+ height: 100%;
5
+ text-align: center;
6
+ }
7
+
8
+ .info-label {
9
+ display: inline-block;
10
+ color: inherit;
11
+ font-size: $fontSize;
12
+ }
13
+
14
+ .info-icon {
15
+ cursor: pointer;
16
+ }
17
+
18
+ .info-left {
19
+ margin-left: -10px;
20
+ align-items: flex-start;
21
+ }
22
+
23
+ .info-right {
24
+ align-items: flex-end;
25
+ }
26
+
27
+ .u-arrow {
28
+ margin-left: 4px;
29
+ margin-right: 4px;
30
+ }
31
+
32
+ .u-info-content {
33
+ color: var(--infoColor);
34
+ text-align: left;
35
+ font-size: $fontSize;
36
+ font-weight: 400;
37
+ max-width: 50vw;
38
+ white-space: normal;
39
+ word-wrap: break-word;
40
+ word-break: break-word;
41
+ background: var(--pageBackgroundColor);
42
+ overflow-x: hidden;
43
+ overflow-y: auto;
44
+ border-color: var(--secondaryHover);
45
+ border-radius: 4px;
46
+ padding: 16px;
47
+ box-shadow: 0 16px 16px -1px #051d391a;
48
+
49
+ &::-webkit-scrollbar {
50
+ width: 4px;
51
+ }
52
+ }
53
+
54
+ .p-error {
55
+ color: var(--dangerColor);
56
+ }
57
+
58
+ .p-warning {
59
+ color: var(--warningColor);
60
+ }
61
+
62
+ .p-info {
63
+ color: var(--brandColor);
64
+ }
@@ -0,0 +1,14 @@
1
+ import { Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'wm-info-card',
5
+ styleUrls: ['./wm-info-card.scss'],
6
+ templateUrl: './wm-info-card.html'
7
+ })
8
+
9
+ export class InfoCardComponent {
10
+ @Input() label: string;
11
+ @Input() value: number | string;
12
+ @Input() icon: string;
13
+ @Input() useCustomIcon: boolean = false;
14
+ }