@colijnit/corecomponents_v12 262.1.16 → 262.1.18
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/fesm2022/colijnit-corecomponents_v12.mjs +223 -40
- package/fesm2022/colijnit-corecomponents_v12.mjs.map +1 -1
- package/index.d.ts +30 -6
- package/lib/components/tooltip/style/_layout.scss +57 -14
- package/lib/components/tooltip/style/_material-definition.scss +30 -4
- package/lib/components/tooltip/style/_theme.scss +32 -13
- package/lib/style/_variables.scss +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Input, Injectable, HostBinding, ViewEncapsulation, Component, Directive, ElementRef, Pipe, EventEmitter, Output, ViewChildren, ViewContainerRef, HostListener, ViewChild, Optional, NgModule, SkipSelf, InjectionToken, Inject, forwardRef, ChangeDetectionStrategy, ContentChildren, LOCALE_ID, NO_ERRORS_SCHEMA, Injector, QueryList } from '@angular/core';
|
|
3
|
+
import { Input, Injectable, HostBinding, ViewEncapsulation, Component, Directive, ElementRef, Pipe, EventEmitter, Output, ViewChildren, ViewContainerRef, HostListener, ViewChild, Optional, NgModule, SkipSelf, InjectionToken, Inject, forwardRef, ChangeDetectionStrategy, ContentChildren, LOCALE_ID, NO_ERRORS_SCHEMA, Injector, RendererStyleFlags2, QueryList } from '@angular/core';
|
|
4
4
|
import * as i5 from '@angular/forms';
|
|
5
5
|
import { NgModel, UntypedFormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
6
6
|
import * as i1 from '@angular/platform-browser';
|
|
@@ -11432,6 +11432,7 @@ class BaseSimpleGridComponent {
|
|
|
11432
11432
|
}
|
|
11433
11433
|
set data(value) {
|
|
11434
11434
|
this._data = value;
|
|
11435
|
+
this.repeatSortOnDataChange();
|
|
11435
11436
|
this._prepareData();
|
|
11436
11437
|
this._currentDataJSON = JSON.stringify(this._data);
|
|
11437
11438
|
this.dataChanged.next();
|
|
@@ -11539,6 +11540,14 @@ class BaseSimpleGridComponent {
|
|
|
11539
11540
|
}
|
|
11540
11541
|
async prepareDataRow(row, index) {
|
|
11541
11542
|
}
|
|
11543
|
+
repeatSortOnDataChange() {
|
|
11544
|
+
}
|
|
11545
|
+
setData(value) {
|
|
11546
|
+
this._data = value;
|
|
11547
|
+
this._prepareData();
|
|
11548
|
+
this._currentDataJSON = JSON.stringify(this._data);
|
|
11549
|
+
this.dataChanged.next();
|
|
11550
|
+
}
|
|
11542
11551
|
_setColumns(columns) {
|
|
11543
11552
|
this.columns.push(...columns);
|
|
11544
11553
|
this.columns.sort((a, b) => a.order < b.order ? -1 : 1);
|
|
@@ -12252,6 +12261,7 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
|
|
|
12252
12261
|
_formMaster;
|
|
12253
12262
|
defaultTextAlign = ColumnAlign.Left;
|
|
12254
12263
|
scrollDirections = ScrollDirection;
|
|
12264
|
+
_previouslySortedColumn;
|
|
12255
12265
|
set headerCells(cells) {
|
|
12256
12266
|
const headerElements = cells.toArray();
|
|
12257
12267
|
for (let i = 0; i < headerElements.length; i++) {
|
|
@@ -12560,14 +12570,18 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
|
|
|
12560
12570
|
return obj !== col;
|
|
12561
12571
|
});
|
|
12562
12572
|
}
|
|
12563
|
-
sortColumn(col, columnValue) {
|
|
12573
|
+
sortColumn(col, columnValue, preserveSortDirection) {
|
|
12564
12574
|
col.isSelected = false;
|
|
12565
12575
|
if (this.sortColumnValue === columnValue) {
|
|
12566
|
-
|
|
12576
|
+
if (!preserveSortDirection) {
|
|
12577
|
+
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
12578
|
+
}
|
|
12567
12579
|
}
|
|
12568
12580
|
else {
|
|
12569
12581
|
this.sortColumnValue = columnValue;
|
|
12570
|
-
|
|
12582
|
+
if (!preserveSortDirection) {
|
|
12583
|
+
this.sortDirection = 'asc';
|
|
12584
|
+
}
|
|
12571
12585
|
}
|
|
12572
12586
|
const direction = this.sortDirection === 'asc' ? 1 : -1;
|
|
12573
12587
|
const sorted = [...this.data].sort((a, b) => {
|
|
@@ -12596,9 +12610,15 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
|
|
|
12596
12610
|
}
|
|
12597
12611
|
return (valA > valB ? 1 : valA < valB ? -1 : 0) * direction;
|
|
12598
12612
|
});
|
|
12599
|
-
this.
|
|
12613
|
+
this.setData(sorted);
|
|
12614
|
+
this._previouslySortedColumn = col;
|
|
12600
12615
|
this._detectChanges();
|
|
12601
12616
|
}
|
|
12617
|
+
repeatSortOnDataChange() {
|
|
12618
|
+
if (this._previouslySortedColumn) {
|
|
12619
|
+
this.sortColumn(this._previouslySortedColumn, this.sortColumnValue, true);
|
|
12620
|
+
}
|
|
12621
|
+
}
|
|
12602
12622
|
showAllColumns() {
|
|
12603
12623
|
this.isSettingsMenuOpen = false;
|
|
12604
12624
|
this.headerColumnsCopy = this.headerColumns;
|
|
@@ -18110,6 +18130,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
18110
18130
|
}]
|
|
18111
18131
|
}] });
|
|
18112
18132
|
|
|
18133
|
+
const ARROW_CENTER_PROPERTY = '--co-tooltip-arrow-center';
|
|
18134
|
+
const ARROW_EDGE_INSET_PX = 15;
|
|
18135
|
+
const VIEWPORT_MARGIN_PX = 5;
|
|
18136
|
+
const ORIENTATIONS = [CoDirection.Up, CoDirection.Down, CoDirection.Left, CoDirection.Right];
|
|
18137
|
+
const OPPOSITE_ORIENTATION = new Map([
|
|
18138
|
+
[CoDirection.Up, CoDirection.Down],
|
|
18139
|
+
[CoDirection.Down, CoDirection.Up],
|
|
18140
|
+
[CoDirection.Left, CoDirection.Right],
|
|
18141
|
+
[CoDirection.Right, CoDirection.Left]
|
|
18142
|
+
]);
|
|
18113
18143
|
class TooltipComponent {
|
|
18114
18144
|
_elementRef;
|
|
18115
18145
|
_changeDetector;
|
|
@@ -18122,14 +18152,27 @@ class TooltipComponent {
|
|
|
18122
18152
|
return this._hostElement;
|
|
18123
18153
|
}
|
|
18124
18154
|
toolTip;
|
|
18155
|
+
orientation = CoDirection.Up;
|
|
18125
18156
|
tooltipClosed = new EventEmitter();
|
|
18126
18157
|
showClass() {
|
|
18127
18158
|
return true;
|
|
18128
18159
|
}
|
|
18129
18160
|
top = -100;
|
|
18130
18161
|
left = -100;
|
|
18131
|
-
|
|
18162
|
+
get isTop() {
|
|
18163
|
+
return this._resolvedOrientation === CoDirection.Up;
|
|
18164
|
+
}
|
|
18165
|
+
get isBottom() {
|
|
18166
|
+
return this._resolvedOrientation === CoDirection.Down;
|
|
18167
|
+
}
|
|
18168
|
+
get isLeft() {
|
|
18169
|
+
return this._resolvedOrientation === CoDirection.Left;
|
|
18170
|
+
}
|
|
18171
|
+
get isRight() {
|
|
18172
|
+
return this._resolvedOrientation === CoDirection.Right;
|
|
18173
|
+
}
|
|
18132
18174
|
animate = true;
|
|
18175
|
+
_resolvedOrientation = CoDirection.Up;
|
|
18133
18176
|
_hostElement;
|
|
18134
18177
|
_documentClickListener;
|
|
18135
18178
|
constructor(_elementRef, _changeDetector, _renderer) {
|
|
@@ -18154,31 +18197,103 @@ class TooltipComponent {
|
|
|
18154
18197
|
}
|
|
18155
18198
|
}
|
|
18156
18199
|
_positionTooltip() {
|
|
18157
|
-
if (this.hostElement
|
|
18158
|
-
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
|
|
18167
|
-
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
|
|
18171
|
-
|
|
18172
|
-
|
|
18200
|
+
if (!this.hostElement || !this._elementRef || !this._elementRef.nativeElement) {
|
|
18201
|
+
return;
|
|
18202
|
+
}
|
|
18203
|
+
const element = this._elementRef.nativeElement;
|
|
18204
|
+
const hostRect = this.hostElement.getBoundingClientRect();
|
|
18205
|
+
this._resolvedOrientation = this._resolveOrientation(hostRect, element.getBoundingClientRect());
|
|
18206
|
+
// Apply the horizontal position first: it determines the available width, and therefore the height.
|
|
18207
|
+
this.left = this._calculateLeft(hostRect, element.getBoundingClientRect());
|
|
18208
|
+
this._changeDetector.detectChanges();
|
|
18209
|
+
const ownRect = element.getBoundingClientRect();
|
|
18210
|
+
this.top = this._calculateTop(hostRect, ownRect);
|
|
18211
|
+
this._positionArrow(hostRect, ownRect);
|
|
18212
|
+
this._changeDetector.markForCheck();
|
|
18213
|
+
this._changeDetector.detectChanges();
|
|
18214
|
+
}
|
|
18215
|
+
_resolveOrientation(hostRect, ownRect) {
|
|
18216
|
+
const preferred = ORIENTATIONS.indexOf(this.orientation) < 0 ? CoDirection.Up : this.orientation;
|
|
18217
|
+
const opposite = OPPOSITE_ORIENTATION.get(preferred);
|
|
18218
|
+
const candidates = [
|
|
18219
|
+
preferred,
|
|
18220
|
+
opposite,
|
|
18221
|
+
...ORIENTATIONS.filter((orientation) => orientation !== preferred && orientation !== opposite)
|
|
18222
|
+
];
|
|
18223
|
+
const fitting = candidates.find((orientation) => this._fits(orientation, hostRect, ownRect));
|
|
18224
|
+
if (fitting) {
|
|
18225
|
+
return fitting;
|
|
18226
|
+
}
|
|
18227
|
+
// Nothing fits: fall back to the side with the most room, so the tooltip overlaps the host as little as possible.
|
|
18228
|
+
return candidates.reduce((best, orientation) => this._availableSpace(orientation, hostRect) > this._availableSpace(best, hostRect) ? orientation : best, preferred);
|
|
18229
|
+
}
|
|
18230
|
+
_fits(orientation, hostRect, ownRect) {
|
|
18231
|
+
switch (orientation) {
|
|
18232
|
+
case CoDirection.Up:
|
|
18233
|
+
return (hostRect.top - ownRect.height) >= VIEWPORT_MARGIN_PX;
|
|
18234
|
+
case CoDirection.Down:
|
|
18235
|
+
return (hostRect.bottom + ownRect.height) <= (document.documentElement.clientHeight - VIEWPORT_MARGIN_PX);
|
|
18236
|
+
case CoDirection.Left:
|
|
18237
|
+
return (hostRect.left - ownRect.width) >= VIEWPORT_MARGIN_PX;
|
|
18238
|
+
default:
|
|
18239
|
+
return (hostRect.right + ownRect.width) <= (document.documentElement.clientWidth - VIEWPORT_MARGIN_PX);
|
|
18240
|
+
}
|
|
18241
|
+
}
|
|
18242
|
+
_availableSpace(orientation, hostRect) {
|
|
18243
|
+
switch (orientation) {
|
|
18244
|
+
case CoDirection.Up:
|
|
18245
|
+
return hostRect.top;
|
|
18246
|
+
case CoDirection.Down:
|
|
18247
|
+
return document.documentElement.clientHeight - hostRect.bottom;
|
|
18248
|
+
case CoDirection.Left:
|
|
18249
|
+
return hostRect.left;
|
|
18250
|
+
default:
|
|
18251
|
+
return document.documentElement.clientWidth - hostRect.right;
|
|
18173
18252
|
}
|
|
18174
18253
|
}
|
|
18254
|
+
_calculateLeft(hostRect, ownRect) {
|
|
18255
|
+
let wantedLeft = hostRect.left; // aligned with the host for the vertical orientations
|
|
18256
|
+
if (this._resolvedOrientation === CoDirection.Left) {
|
|
18257
|
+
wantedLeft = hostRect.left - ownRect.width;
|
|
18258
|
+
}
|
|
18259
|
+
else if (this._resolvedOrientation === CoDirection.Right) {
|
|
18260
|
+
wantedLeft = hostRect.right;
|
|
18261
|
+
}
|
|
18262
|
+
const maxLeft = document.documentElement.clientWidth - ownRect.width - VIEWPORT_MARGIN_PX;
|
|
18263
|
+
return Math.max(VIEWPORT_MARGIN_PX, Math.min(wantedLeft, maxLeft));
|
|
18264
|
+
}
|
|
18265
|
+
_calculateTop(hostRect, ownRect) {
|
|
18266
|
+
// Centred on the host for the horizontal orientations, so the arrow lands halfway up the edge
|
|
18267
|
+
// instead of being clamped against the top corner by hosts that are shorter than the tooltip.
|
|
18268
|
+
let wantedTop = hostRect.top + ((hostRect.height - ownRect.height) / 2);
|
|
18269
|
+
if (this._resolvedOrientation === CoDirection.Up) {
|
|
18270
|
+
wantedTop = hostRect.top - ownRect.height;
|
|
18271
|
+
}
|
|
18272
|
+
else if (this._resolvedOrientation === CoDirection.Down) {
|
|
18273
|
+
wantedTop = hostRect.bottom;
|
|
18274
|
+
}
|
|
18275
|
+
const maxTop = document.documentElement.clientHeight - ownRect.height - VIEWPORT_MARGIN_PX;
|
|
18276
|
+
return Math.max(VIEWPORT_MARGIN_PX, Math.min(wantedTop, maxTop));
|
|
18277
|
+
}
|
|
18278
|
+
_positionArrow(hostRect, ownRect) {
|
|
18279
|
+
const element = this._elementRef.nativeElement;
|
|
18280
|
+
const alongVerticalEdge = this.isLeft || this.isRight;
|
|
18281
|
+
const borderWidth = alongVerticalEdge ? element.clientTop : element.clientLeft;
|
|
18282
|
+
const paddingBoxSize = (alongVerticalEdge ? ownRect.height : ownRect.width) - (2 * borderWidth);
|
|
18283
|
+
const hostCenter = alongVerticalEdge
|
|
18284
|
+
? (hostRect.top + (hostRect.height / 2)) - this.top - borderWidth
|
|
18285
|
+
: (hostRect.left + (hostRect.width / 2)) - this.left - borderWidth;
|
|
18286
|
+
const maxCenter = Math.max(ARROW_EDGE_INSET_PX, paddingBoxSize - ARROW_EDGE_INSET_PX);
|
|
18287
|
+
const arrowCenter = Math.min(Math.max(hostCenter, ARROW_EDGE_INSET_PX), maxCenter);
|
|
18288
|
+
this._renderer.setStyle(element, ARROW_CENTER_PROPERTY, `${arrowCenter}px`, RendererStyleFlags2.DashCase);
|
|
18289
|
+
}
|
|
18175
18290
|
closeTooltip() {
|
|
18176
18291
|
this.tooltipClosed.emit();
|
|
18177
18292
|
}
|
|
18178
18293
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TooltipComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
|
|
18179
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: TooltipComponent, isStandalone: false, selector: "co-tooltip", inputs: { hostElement: "hostElement", toolTip: "toolTip" }, outputs: { tooltipClosed: "tooltipClosed" }, host: { properties: { "class.co-tooltip": "this.showClass", "style.top.px": "this.top", "style.left.px": "this.left", "class.
|
|
18180
|
-
|
|
18181
|
-
|
|
18294
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: TooltipComponent, isStandalone: false, selector: "co-tooltip", inputs: { hostElement: "hostElement", toolTip: "toolTip", orientation: "orientation" }, outputs: { tooltipClosed: "tooltipClosed" }, host: { properties: { "class.co-tooltip": "this.showClass", "style.top.px": "this.top", "style.left.px": "this.left", "class.top": "this.isTop", "class.bottom": "this.isBottom", "class.left": "this.isLeft", "class.right": "this.isRight", "@showHide": "this.animate" } }, ngImport: i0, template: `
|
|
18295
|
+
<div class="tooltip" [innerHTML]="toolTip"></div>
|
|
18296
|
+
`, isInline: true, animations: [
|
|
18182
18297
|
trigger("showHide", [
|
|
18183
18298
|
state("void", style({ opacity: 0 })),
|
|
18184
18299
|
state("*", style({ opacity: 1 })),
|
|
@@ -18191,8 +18306,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
18191
18306
|
args: [{
|
|
18192
18307
|
selector: 'co-tooltip',
|
|
18193
18308
|
template: `
|
|
18194
|
-
|
|
18195
|
-
|
|
18309
|
+
<div class="tooltip" [innerHTML]="toolTip"></div>
|
|
18310
|
+
`,
|
|
18196
18311
|
animations: [
|
|
18197
18312
|
trigger("showHide", [
|
|
18198
18313
|
state("void", style({ opacity: 0 })),
|
|
@@ -18208,6 +18323,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
18208
18323
|
type: Input
|
|
18209
18324
|
}], toolTip: [{
|
|
18210
18325
|
type: Input
|
|
18326
|
+
}], orientation: [{
|
|
18327
|
+
type: Input
|
|
18211
18328
|
}], tooltipClosed: [{
|
|
18212
18329
|
type: Output
|
|
18213
18330
|
}], showClass: [{
|
|
@@ -18219,14 +18336,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
18219
18336
|
}], left: [{
|
|
18220
18337
|
type: HostBinding,
|
|
18221
18338
|
args: ["style.left.px"]
|
|
18222
|
-
}],
|
|
18339
|
+
}], isTop: [{
|
|
18340
|
+
type: HostBinding,
|
|
18341
|
+
args: ["class.top"]
|
|
18342
|
+
}], isBottom: [{
|
|
18223
18343
|
type: HostBinding,
|
|
18224
18344
|
args: ["class.bottom"]
|
|
18345
|
+
}], isLeft: [{
|
|
18346
|
+
type: HostBinding,
|
|
18347
|
+
args: ["class.left"]
|
|
18348
|
+
}], isRight: [{
|
|
18349
|
+
type: HostBinding,
|
|
18350
|
+
args: ["class.right"]
|
|
18225
18351
|
}], animate: [{
|
|
18226
18352
|
type: HostBinding,
|
|
18227
18353
|
args: ['@showHide']
|
|
18228
18354
|
}] } });
|
|
18229
18355
|
|
|
18356
|
+
const SHOW_DELAY_PROPERTY = '--co-tooltip-show-delay';
|
|
18357
|
+
const AUTO_HIDE_DELAY_PROPERTY = '--co-tooltip-auto-hide-delay';
|
|
18358
|
+
const DEFAULT_SHOW_DELAY_MS = 400;
|
|
18359
|
+
const DEFAULT_AUTO_HIDE_DELAY_MS = 10000;
|
|
18230
18360
|
class TooltipDirective {
|
|
18231
18361
|
_compFactoryResolver;
|
|
18232
18362
|
_appRef;
|
|
@@ -18235,9 +18365,15 @@ class TooltipDirective {
|
|
|
18235
18365
|
set tooltip(str) {
|
|
18236
18366
|
this._tooltipMessage = str;
|
|
18237
18367
|
}
|
|
18368
|
+
orientation = CoDirection.Up;
|
|
18238
18369
|
_elementRef;
|
|
18239
18370
|
_tooltipMessage;
|
|
18240
18371
|
_componentRef;
|
|
18372
|
+
_showTimeoutId = undefined;
|
|
18373
|
+
_autoHideTimeoutId = undefined;
|
|
18374
|
+
_mouseEnterHandler = () => this._startShowTimeout();
|
|
18375
|
+
_mouseLeaveHandler = () => this._removeTooltip();
|
|
18376
|
+
_scrollHandler = () => this._handleScroll();
|
|
18241
18377
|
constructor(elementRef, _compFactoryResolver, _appRef, _injector, _sanitizer) {
|
|
18242
18378
|
this._compFactoryResolver = _compFactoryResolver;
|
|
18243
18379
|
this._appRef = _appRef;
|
|
@@ -18246,37 +18382,79 @@ class TooltipDirective {
|
|
|
18246
18382
|
this._elementRef = elementRef;
|
|
18247
18383
|
}
|
|
18248
18384
|
ngOnDestroy() {
|
|
18385
|
+
this._removeTooltip();
|
|
18249
18386
|
if (this._elementRef && this._elementRef.nativeElement) {
|
|
18250
|
-
this._elementRef.nativeElement.removeEventListener('mouseenter',
|
|
18251
|
-
this._elementRef.nativeElement.removeEventListener('mouseleave',
|
|
18387
|
+
this._elementRef.nativeElement.removeEventListener('mouseenter', this._mouseEnterHandler);
|
|
18388
|
+
this._elementRef.nativeElement.removeEventListener('mouseleave', this._mouseLeaveHandler);
|
|
18252
18389
|
}
|
|
18253
|
-
window.removeEventListener("scroll",
|
|
18390
|
+
window.removeEventListener("scroll", this._scrollHandler);
|
|
18254
18391
|
this._elementRef = undefined;
|
|
18255
18392
|
}
|
|
18256
18393
|
ngOnInit() {
|
|
18257
|
-
window.addEventListener("scroll",
|
|
18394
|
+
window.addEventListener("scroll", this._scrollHandler);
|
|
18258
18395
|
if (this._elementRef && this._elementRef.nativeElement) {
|
|
18259
|
-
this._elementRef.nativeElement.addEventListener('mouseenter',
|
|
18260
|
-
this._elementRef.nativeElement.addEventListener('mouseleave',
|
|
18396
|
+
this._elementRef.nativeElement.addEventListener('mouseenter', this._mouseEnterHandler);
|
|
18397
|
+
this._elementRef.nativeElement.addEventListener('mouseleave', this._mouseLeaveHandler);
|
|
18261
18398
|
}
|
|
18262
18399
|
}
|
|
18263
18400
|
_handleScroll() {
|
|
18264
18401
|
this._removeTooltip();
|
|
18265
18402
|
}
|
|
18266
|
-
|
|
18267
|
-
this.
|
|
18403
|
+
_startShowTimeout() {
|
|
18404
|
+
this._clearShowTimeout();
|
|
18405
|
+
this._showTimeoutId = window.setTimeout(() => {
|
|
18406
|
+
this._showTimeoutId = undefined;
|
|
18407
|
+
this._createTooltipComponent();
|
|
18408
|
+
}, this._resolveDelay(SHOW_DELAY_PROPERTY, DEFAULT_SHOW_DELAY_MS));
|
|
18268
18409
|
}
|
|
18269
|
-
|
|
18270
|
-
|
|
18410
|
+
// Delays come from custom properties, read from the host so a scoped override wins over the
|
|
18411
|
+
// :root default; falls back when the stylesheet is absent. A bare number is read as milliseconds.
|
|
18412
|
+
_resolveDelay(property, fallback) {
|
|
18413
|
+
if (!this._elementRef || !this._elementRef.nativeElement) {
|
|
18414
|
+
return fallback;
|
|
18415
|
+
}
|
|
18416
|
+
const raw = window.getComputedStyle(this._elementRef.nativeElement)
|
|
18417
|
+
.getPropertyValue(property)
|
|
18418
|
+
.trim();
|
|
18419
|
+
const value = parseFloat(raw);
|
|
18420
|
+
if (isNaN(value)) {
|
|
18421
|
+
return fallback;
|
|
18422
|
+
}
|
|
18423
|
+
return Math.max(0, raw.endsWith('ms') || !raw.endsWith('s') ? value : value * 1000);
|
|
18424
|
+
}
|
|
18425
|
+
_clearShowTimeout() {
|
|
18426
|
+
if (this._showTimeoutId !== undefined) {
|
|
18427
|
+
window.clearTimeout(this._showTimeoutId);
|
|
18428
|
+
this._showTimeoutId = undefined;
|
|
18429
|
+
}
|
|
18271
18430
|
}
|
|
18272
18431
|
_removeTooltip() {
|
|
18432
|
+
this._clearShowTimeout();
|
|
18433
|
+
this._clearAutoHideTimeout();
|
|
18273
18434
|
if (this._componentRef) {
|
|
18274
18435
|
this._appRef.detachView(this._componentRef.hostView);
|
|
18275
18436
|
this._componentRef.destroy();
|
|
18276
18437
|
this._componentRef = undefined;
|
|
18277
18438
|
}
|
|
18278
18439
|
}
|
|
18279
|
-
|
|
18440
|
+
_startAutoHideTimeout() {
|
|
18441
|
+
this._clearAutoHideTimeout();
|
|
18442
|
+
const delay = this._resolveDelay(AUTO_HIDE_DELAY_PROPERTY, DEFAULT_AUTO_HIDE_DELAY_MS);
|
|
18443
|
+
if (delay <= 0) { // guard switched off by the consumer
|
|
18444
|
+
return;
|
|
18445
|
+
}
|
|
18446
|
+
this._autoHideTimeoutId = window.setTimeout(() => {
|
|
18447
|
+
this._autoHideTimeoutId = undefined;
|
|
18448
|
+
this._removeTooltip();
|
|
18449
|
+
}, delay);
|
|
18450
|
+
}
|
|
18451
|
+
_clearAutoHideTimeout() {
|
|
18452
|
+
if (this._autoHideTimeoutId !== undefined) {
|
|
18453
|
+
window.clearTimeout(this._autoHideTimeoutId);
|
|
18454
|
+
this._autoHideTimeoutId = undefined;
|
|
18455
|
+
}
|
|
18456
|
+
}
|
|
18457
|
+
_createTooltipComponent() {
|
|
18280
18458
|
if (!this._tooltipMessage) {
|
|
18281
18459
|
return;
|
|
18282
18460
|
}
|
|
@@ -18287,13 +18465,15 @@ class TooltipDirective {
|
|
|
18287
18465
|
.resolveComponentFactory(TooltipComponent)
|
|
18288
18466
|
.create(this._injector);
|
|
18289
18467
|
this._componentRef.instance.hostElement = this._elementRef.nativeElement;
|
|
18468
|
+
this._componentRef.instance.orientation = this.orientation;
|
|
18290
18469
|
this._componentRef.instance.toolTip = this._sanitizer.bypassSecurityTrustHtml(this._tooltipMessage);
|
|
18291
18470
|
this._appRef.attachView(this._componentRef.hostView);
|
|
18292
18471
|
const domElem = this._componentRef.hostView.rootNodes[0];
|
|
18293
18472
|
document.body.appendChild(domElem);
|
|
18473
|
+
this._startAutoHideTimeout();
|
|
18294
18474
|
}
|
|
18295
18475
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TooltipDirective, deps: [{ token: i0.ElementRef }, { token: i0.ComponentFactoryResolver }, { token: i0.ApplicationRef }, { token: i0.Injector }, { token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Directive });
|
|
18296
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: TooltipDirective, isStandalone: false, selector: "[tooltip]", inputs: { tooltip: "tooltip" }, ngImport: i0 });
|
|
18476
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: TooltipDirective, isStandalone: false, selector: "[tooltip]", inputs: { tooltip: "tooltip", orientation: ["tooltipOrientation", "orientation"] }, ngImport: i0 });
|
|
18297
18477
|
}
|
|
18298
18478
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TooltipDirective, decorators: [{
|
|
18299
18479
|
type: Directive,
|
|
@@ -18304,6 +18484,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
18304
18484
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ComponentFactoryResolver }, { type: i0.ApplicationRef }, { type: i0.Injector }, { type: i1.DomSanitizer }], propDecorators: { tooltip: [{
|
|
18305
18485
|
type: Input,
|
|
18306
18486
|
args: ["tooltip"]
|
|
18487
|
+
}], orientation: [{
|
|
18488
|
+
type: Input,
|
|
18489
|
+
args: ["tooltipOrientation"]
|
|
18307
18490
|
}] } });
|
|
18308
18491
|
|
|
18309
18492
|
class TooltipModule {
|