-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathpopover-container.component.ts
More file actions
58 lines (51 loc) · 1.58 KB
/
popover-container.component.ts
File metadata and controls
58 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { ChangeDetectionStrategy, Input, Component } from '@angular/core';
import { PopoverConfig } from './popover.config';
import { getBsVer, IBsVersion } from 'ngx-bootstrap/utils';
import { PlacementForBs5, checkMargins, AvailableBSPositions } from 'ngx-bootstrap/positioning';
@Component({
selector: 'popover-container',
changeDetection: ChangeDetectionStrategy.OnPush,
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
host: {
'[attr.id]': 'popoverId',
'[class]':
'"popover in popover-" + _placement + " " + "bs-popover-" + _placement + " " + _placement + " " + containerClass + " " + checkMarginNecessity()',
'[class.show]': '!_bsVersions.isBs3',
'[class.bs3]': '_bsVersions.isBs3',
role: 'tooltip',
style: 'display:block; position:absolute'
},
styles: [
`
:host.popover.bottom>.arrow {
margin-left: -4px;
}
:host .popover-arrow {
position: absolute;
}
`
],
templateUrl: './popover-container.component.html'
})
export class PopoverContainerComponent {
@Input() set placement(value: AvailableBSPositions) {
if (!this._bsVersions.isBs5) {
this._placement = value;
} else {
this._placement = PlacementForBs5[value as keyof typeof PlacementForBs5];
}
};
@Input() title?: string;
containerClass?: string;
popoverId?: string;
_placement = 'top';
get _bsVersions(): IBsVersion {
return getBsVer();
}
constructor(config: PopoverConfig) {
Object.assign(this, config);
}
checkMarginNecessity(): string {
return checkMargins(this._placement);
}
}