@klippa/ngx-enhancy-forms 14.21.0 → 14.22.1
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 +43 -6
- package/fesm2015/klippa-ngx-enhancy-forms.mjs +43 -5
- package/fesm2015/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/fesm2020/klippa-ngx-enhancy-forms.mjs +42 -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,19 @@ 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.maxWidth = 'none';
|
|
2478
|
+
this.div.style.visibility = 'hidden';
|
|
2479
|
+
this.div.appendChild(this.templateInstance);
|
|
2480
|
+
setTimeout(() => {
|
|
2481
|
+
const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
|
|
2482
|
+
this.div.style.backgroundColor = color;
|
|
2483
|
+
this.div.style.visibility = 'visible';
|
|
2484
|
+
});
|
|
2485
|
+
}
|
|
2467
2486
|
el.nativeElement.prepend(this.div);
|
|
2468
2487
|
this.triangle = document.createElement('div');
|
|
2469
2488
|
this.triangle.style.zIndex = `${zIndexStart + 1}`;
|
|
@@ -2487,7 +2506,17 @@ class WithTooltipDirective {
|
|
|
2487
2506
|
this.triangleWhite.style.height = '0';
|
|
2488
2507
|
this.triangleWhite.style.borderLeft = `${triangleSize} solid transparent`;
|
|
2489
2508
|
this.triangleWhite.style.borderRight = `${triangleSize} solid transparent`;
|
|
2490
|
-
|
|
2509
|
+
if (stringIsSetAndFilled(textToDisplay)) {
|
|
2510
|
+
this.triangleWhite.style.borderTop = `${triangleSize} solid white`;
|
|
2511
|
+
}
|
|
2512
|
+
else if (this.templateInstance) {
|
|
2513
|
+
this.div.style.visibility = 'hidden';
|
|
2514
|
+
setTimeout(() => {
|
|
2515
|
+
const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
|
|
2516
|
+
this.triangleWhite.style.borderTop = `${triangleSize} solid ${color}`;
|
|
2517
|
+
this.div.style.visibility = 'visible';
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2491
2520
|
el.nativeElement.prepend(this.triangleWhite);
|
|
2492
2521
|
});
|
|
2493
2522
|
el.nativeElement.addEventListener('mouseleave', () => {
|
|
@@ -2505,9 +2534,15 @@ class WithTooltipDirective {
|
|
|
2505
2534
|
catch (ex) { }
|
|
2506
2535
|
});
|
|
2507
2536
|
}
|
|
2537
|
+
ngOnChanges(simpleChanges) {
|
|
2538
|
+
if (simpleChanges.tooltipTemplate?.currentValue) {
|
|
2539
|
+
const viewRef = this.tooltipTemplate.createEmbeddedView(null);
|
|
2540
|
+
this.templateInstance = viewRef.rootNodes[0];
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2508
2543
|
}
|
|
2509
2544
|
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 });
|
|
2545
|
+
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
2546
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: WithTooltipDirective, decorators: [{
|
|
2512
2547
|
type: Directive,
|
|
2513
2548
|
args: [{
|
|
@@ -2517,6 +2552,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
|
|
|
2517
2552
|
type: Input
|
|
2518
2553
|
}], tooltipText: [{
|
|
2519
2554
|
type: Input
|
|
2555
|
+
}], tooltipTemplate: [{
|
|
2556
|
+
type: Input
|
|
2520
2557
|
}] } });
|
|
2521
2558
|
|
|
2522
2559
|
class NgxEnhancyFormsModule {
|