@klippa/ngx-enhancy-forms 14.21.0 → 14.22.0
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/esm2020/lib/withTooltip.component.mjs +42 -6
- package/fesm2015/klippa-ngx-enhancy-forms.mjs +42 -5
- package/fesm2015/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/fesm2020/klippa-ngx-enhancy-forms.mjs +41 -5
- package/fesm2020/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/lib/withTooltip.component.d.ts +7 -3
- package/package.json +1 -1
|
@@ -2426,13 +2426,17 @@ const colors = {
|
|
|
2426
2426
|
};
|
|
2427
2427
|
class WithTooltipDirective {
|
|
2428
2428
|
constructor(el) {
|
|
2429
|
+
this.el = el;
|
|
2429
2430
|
this.klpWithTooltip = 'orange';
|
|
2430
2431
|
el.nativeElement.addEventListener('mouseenter', () => {
|
|
2431
|
-
|
|
2432
|
+
let textToDisplay;
|
|
2433
|
+
if (!this.templateInstance) {
|
|
2434
|
+
textToDisplay = this.tooltipText || el.nativeElement.innerText.trim();
|
|
2435
|
+
}
|
|
2432
2436
|
if (!stringIsSetAndFilled(this.klpWithTooltip)) {
|
|
2433
2437
|
return;
|
|
2434
2438
|
}
|
|
2435
|
-
if (textToDisplay
|
|
2439
|
+
if (!stringIsSetAndFilled(textToDisplay) && !this.tooltipTemplate) {
|
|
2436
2440
|
return;
|
|
2437
2441
|
}
|
|
2438
2442
|
if (stringIsSetAndFilled(this.tooltipText)) {
|
|
@@ -2440,6 +2444,9 @@ class WithTooltipDirective {
|
|
|
2440
2444
|
return;
|
|
2441
2445
|
}
|
|
2442
2446
|
}
|
|
2447
|
+
else if (this.tooltipTemplate) {
|
|
2448
|
+
// no need to check here, just render the template
|
|
2449
|
+
}
|
|
2443
2450
|
else {
|
|
2444
2451
|
if (el.nativeElement.offsetWidth >= el.nativeElement.scrollWidth) {
|
|
2445
2452
|
return;
|
|
@@ -2463,7 +2470,18 @@ class WithTooltipDirective {
|
|
|
2463
2470
|
this.div.style.padding = '0.3rem 0.5rem';
|
|
2464
2471
|
this.div.style.boxSizing = 'border-box';
|
|
2465
2472
|
this.div.style.borderRadius = '3px';
|
|
2466
|
-
|
|
2473
|
+
if (stringIsSetAndFilled(textToDisplay)) {
|
|
2474
|
+
this.div.textContent = textToDisplay;
|
|
2475
|
+
}
|
|
2476
|
+
else if (this.templateInstance) {
|
|
2477
|
+
this.div.style.visibility = 'hidden';
|
|
2478
|
+
this.div.appendChild(this.templateInstance);
|
|
2479
|
+
setTimeout(() => {
|
|
2480
|
+
const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
|
|
2481
|
+
this.div.style.backgroundColor = color;
|
|
2482
|
+
this.div.style.visibility = 'visible';
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2467
2485
|
el.nativeElement.prepend(this.div);
|
|
2468
2486
|
this.triangle = document.createElement('div');
|
|
2469
2487
|
this.triangle.style.zIndex = `${zIndexStart + 1}`;
|
|
@@ -2487,7 +2505,17 @@ class WithTooltipDirective {
|
|
|
2487
2505
|
this.triangleWhite.style.height = '0';
|
|
2488
2506
|
this.triangleWhite.style.borderLeft = `${triangleSize} solid transparent`;
|
|
2489
2507
|
this.triangleWhite.style.borderRight = `${triangleSize} solid transparent`;
|
|
2490
|
-
|
|
2508
|
+
if (stringIsSetAndFilled(textToDisplay)) {
|
|
2509
|
+
this.triangleWhite.style.borderTop = `${triangleSize} solid white`;
|
|
2510
|
+
}
|
|
2511
|
+
else if (this.templateInstance) {
|
|
2512
|
+
this.div.style.visibility = 'hidden';
|
|
2513
|
+
setTimeout(() => {
|
|
2514
|
+
const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
|
|
2515
|
+
this.triangleWhite.style.borderTop = `${triangleSize} solid ${color}`;
|
|
2516
|
+
this.div.style.visibility = 'visible';
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2491
2519
|
el.nativeElement.prepend(this.triangleWhite);
|
|
2492
2520
|
});
|
|
2493
2521
|
el.nativeElement.addEventListener('mouseleave', () => {
|
|
@@ -2505,9 +2533,15 @@ class WithTooltipDirective {
|
|
|
2505
2533
|
catch (ex) { }
|
|
2506
2534
|
});
|
|
2507
2535
|
}
|
|
2536
|
+
ngOnChanges(simpleChanges) {
|
|
2537
|
+
if (simpleChanges.tooltipTemplate?.currentValue) {
|
|
2538
|
+
const viewRef = this.tooltipTemplate.createEmbeddedView(null);
|
|
2539
|
+
this.templateInstance = viewRef.rootNodes[0];
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2508
2542
|
}
|
|
2509
2543
|
WithTooltipDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: WithTooltipDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2510
|
-
WithTooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.8", type: WithTooltipDirective, selector: "[klpWithTooltip]", inputs: { klpWithTooltip: "klpWithTooltip", tooltipText: "tooltipText" }, ngImport: i0 });
|
|
2544
|
+
WithTooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.8", type: WithTooltipDirective, selector: "[klpWithTooltip]", inputs: { klpWithTooltip: "klpWithTooltip", tooltipText: "tooltipText", tooltipTemplate: "tooltipTemplate" }, usesOnChanges: true, ngImport: i0 });
|
|
2511
2545
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: WithTooltipDirective, decorators: [{
|
|
2512
2546
|
type: Directive,
|
|
2513
2547
|
args: [{
|
|
@@ -2517,6 +2551,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
|
|
|
2517
2551
|
type: Input
|
|
2518
2552
|
}], tooltipText: [{
|
|
2519
2553
|
type: Input
|
|
2554
|
+
}], tooltipTemplate: [{
|
|
2555
|
+
type: Input
|
|
2520
2556
|
}] } });
|
|
2521
2557
|
|
|
2522
2558
|
class NgxEnhancyFormsModule {
|