@klippa/ngx-enhancy-forms 18.22.4 → 18.22.6

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.
@@ -2516,151 +2516,162 @@ const colors = {
2516
2516
  black: { noAlpha: 'rgb(40, 40, 40)', withAlpha: 'rgba(40, 40, 40, 0.1254901961)' },
2517
2517
  };
2518
2518
  class WithTooltipDirective {
2519
- constructor(el, appRef) {
2519
+ constructor(el, appRef, ngZone) {
2520
2520
  this.el = el;
2521
2521
  this.appRef = appRef;
2522
+ this.ngZone = ngZone;
2522
2523
  this.klpWithTooltip = 'orange';
2523
2524
  this.position = 'top';
2524
- el.nativeElement.addEventListener('mouseenter', () => {
2525
- let textToDisplay;
2526
- if (!this.templateInstance) {
2527
- textToDisplay = this.tooltipText || el.nativeElement.innerText.trim();
2528
- }
2529
- if (!stringIsSetAndFilled(this.klpWithTooltip)) {
2530
- return;
2531
- }
2532
- if (!stringIsSetAndFilled(textToDisplay) && !this.tooltipTemplate) {
2533
- return;
2534
- }
2535
- if (stringIsSetAndFilled(this.tooltipText)) {
2536
- if (this.tooltipText === el.nativeElement.innerText) {
2525
+ this.ngZone.runOutsideAngular(() => {
2526
+ el.nativeElement.addEventListener('mouseenter', () => {
2527
+ if (this.tooltipTemplate) {
2528
+ this.hookUpTemplate();
2529
+ }
2530
+ let textToDisplay;
2531
+ if (!this.templateInstance) {
2532
+ textToDisplay = this.tooltipText || el.nativeElement.innerText.trim();
2533
+ }
2534
+ if (!stringIsSetAndFilled(this.klpWithTooltip)) {
2537
2535
  return;
2538
2536
  }
2539
- }
2540
- else if (this.tooltipTemplate) {
2541
- // no need to check here, just render the template
2542
- }
2543
- else {
2544
- if (el.nativeElement.offsetWidth >= el.nativeElement.scrollWidth) {
2537
+ if (!stringIsSetAndFilled(textToDisplay) && !this.tooltipTemplate) {
2545
2538
  return;
2546
2539
  }
2547
- }
2548
- if (getComputedStyle(el.nativeElement).position === 'static') {
2549
- el.nativeElement.style.position = 'relative';
2550
- }
2551
- this.div = document.createElement('div');
2552
- this.div.style.zIndex = `${zIndexStart + 2}`;
2553
- this.div.style.color = `${colors[this.klpWithTooltip].noAlpha}`;
2554
- this.div.style.position = 'fixed';
2555
- this.div.style.left = `${el.nativeElement.getBoundingClientRect().x}px`;
2556
- if (this.position === 'top') {
2557
- this.div.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2558
- this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(-100% - 0.3rem))`;
2559
- }
2560
- else if (this.position === 'bottom') {
2561
- this.div.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2562
- this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(0% + 0.3rem))`;
2563
- }
2564
- this.div.style.maxWidth = '200px';
2565
- this.div.style.whiteSpace = 'break-spaces';
2566
- this.div.style.backgroundColor = 'white';
2567
- this.div.style.border = `1px solid ${colors[this.klpWithTooltip].withAlpha}`;
2568
- this.div.style.boxShadow = `2px 3px 10px 0px ${colors[this.klpWithTooltip].withAlpha}`;
2569
- this.div.style.padding = '0.3rem 0.5rem';
2570
- this.div.style.boxSizing = 'border-box';
2571
- this.div.style.borderRadius = '3px';
2572
- if (stringIsSetAndFilled(textToDisplay)) {
2573
- this.div.textContent = textToDisplay;
2574
- }
2575
- else if (this.templateInstance) {
2576
- this.div.style.maxWidth = 'none';
2577
- this.div.style.visibility = 'hidden';
2578
- this.div.appendChild(this.templateInstance);
2579
- setTimeout(() => {
2580
- const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
2581
- this.div.style.backgroundColor = color;
2582
- this.div.style.visibility = 'visible';
2583
- });
2584
- }
2585
- el.nativeElement.prepend(this.div);
2586
- this.triangle = document.createElement('div');
2587
- this.triangle.style.zIndex = `${zIndexStart + 1}`;
2588
- this.triangle.style.position = 'fixed';
2589
- this.triangle.style.left = `calc(${el.nativeElement.getBoundingClientRect().x + el.nativeElement.getBoundingClientRect().width}px - 2rem)`;
2590
- if (this.position === 'top') {
2591
- this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2592
- this.triangle.style.transform = `translate(-50%, calc(-100% + 0.1rem))`;
2593
- }
2594
- else if (this.position === 'bottom') {
2595
- this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2596
- this.triangle.style.transform = `translate(-50%, 0rem) rotate(180deg)`;
2597
- }
2598
- this.triangle.style.width = '0';
2599
- this.triangle.style.height = '0';
2600
- this.triangle.style.borderLeft = `${triangleSize} solid transparent`;
2601
- this.triangle.style.borderRight = `${triangleSize} solid transparent`;
2602
- this.triangle.style.borderTop = `${triangleSize} solid ${colors[this.klpWithTooltip].withAlpha}`;
2603
- el.nativeElement.prepend(this.triangle);
2604
- this.triangleWhite = document.createElement('div');
2605
- this.triangleWhite.style.zIndex = `${zIndexStart + 3}`;
2606
- this.triangleWhite.style.position = 'fixed';
2607
- this.triangleWhite.style.left = `calc(${el.nativeElement.getBoundingClientRect().x + el.nativeElement.getBoundingClientRect().width}px - 2rem)`;
2608
- if (this.position === 'top') {
2609
- this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2610
- this.triangleWhite.style.transform = `translate(-50%, calc(-100% + 0.1rem - 2px))`;
2611
- }
2612
- else if (this.position === 'bottom') {
2613
- this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2614
- this.triangleWhite.style.transform = `translate(-50%, -2px) rotate(180deg)`;
2615
- }
2616
- this.triangleWhite.style.width = '0';
2617
- this.triangleWhite.style.height = '0';
2618
- this.triangleWhite.style.borderLeft = `${triangleSize} solid transparent`;
2619
- this.triangleWhite.style.borderRight = `${triangleSize} solid transparent`;
2620
- if (stringIsSetAndFilled(textToDisplay)) {
2621
- this.triangleWhite.style.borderTop = `${triangleSize} solid white`;
2622
- }
2623
- else if (this.templateInstance) {
2624
- this.div.style.visibility = 'hidden';
2625
- setTimeout(() => {
2626
- const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
2627
- this.triangleWhite.style.borderTop = `${triangleSize} solid ${color}`;
2628
- this.div.style.visibility = 'visible';
2629
- });
2630
- }
2631
- el.nativeElement.prepend(this.triangleWhite);
2632
- });
2633
- el.nativeElement.addEventListener('mouseleave', () => {
2634
- try {
2635
- el.nativeElement.removeChild(this.div);
2636
- }
2637
- catch (ex) { }
2638
- try {
2639
- el.nativeElement.removeChild(this.triangle);
2640
- }
2641
- catch (ex) { }
2642
- try {
2643
- el.nativeElement.removeChild(this.triangleWhite);
2644
- }
2645
- catch (ex) { }
2540
+ if (stringIsSetAndFilled(this.tooltipText)) {
2541
+ if (this.tooltipText === el.nativeElement.innerText) {
2542
+ return;
2543
+ }
2544
+ }
2545
+ else if (this.tooltipTemplate) {
2546
+ // no need to check here, just render the template
2547
+ }
2548
+ else {
2549
+ if (el.nativeElement.offsetWidth >= el.nativeElement.scrollWidth) {
2550
+ return;
2551
+ }
2552
+ }
2553
+ if (getComputedStyle(el.nativeElement).position === 'static') {
2554
+ el.nativeElement.style.position = 'relative';
2555
+ }
2556
+ this.div = document.createElement('div');
2557
+ this.div.style.zIndex = `${zIndexStart + 2}`;
2558
+ this.div.style.color = `${colors[this.klpWithTooltip].noAlpha}`;
2559
+ this.div.style.position = 'fixed';
2560
+ this.div.style.left = `${el.nativeElement.getBoundingClientRect().x}px`;
2561
+ if (this.position === 'top') {
2562
+ this.div.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2563
+ this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(-100% - 0.3rem))`;
2564
+ }
2565
+ else if (this.position === 'bottom') {
2566
+ this.div.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2567
+ this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(0% + 0.3rem))`;
2568
+ }
2569
+ this.div.style.maxWidth = '200px';
2570
+ this.div.style.whiteSpace = 'break-spaces';
2571
+ this.div.style.backgroundColor = 'white';
2572
+ this.div.style.border = `1px solid ${colors[this.klpWithTooltip].withAlpha}`;
2573
+ this.div.style.boxShadow = `2px 3px 10px 0px ${colors[this.klpWithTooltip].withAlpha}`;
2574
+ this.div.style.padding = '0.3rem 0.5rem';
2575
+ this.div.style.boxSizing = 'border-box';
2576
+ this.div.style.borderRadius = '3px';
2577
+ if (stringIsSetAndFilled(textToDisplay)) {
2578
+ this.div.textContent = textToDisplay;
2579
+ }
2580
+ else if (this.templateInstance) {
2581
+ this.div.style.maxWidth = 'none';
2582
+ this.div.style.visibility = 'hidden';
2583
+ this.div.appendChild(this.templateInstance);
2584
+ setTimeout(() => {
2585
+ const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
2586
+ this.div.style.backgroundColor = color;
2587
+ this.div.style.visibility = 'visible';
2588
+ });
2589
+ }
2590
+ el.nativeElement.prepend(this.div);
2591
+ this.triangle = document.createElement('div');
2592
+ this.triangle.style.zIndex = `${zIndexStart + 1}`;
2593
+ this.triangle.style.position = 'fixed';
2594
+ this.triangle.style.left = `calc(${el.nativeElement.getBoundingClientRect().x + el.nativeElement.getBoundingClientRect().width}px - 2rem)`;
2595
+ if (this.position === 'top') {
2596
+ this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2597
+ this.triangle.style.transform = `translate(-50%, calc(-100% + 0.1rem))`;
2598
+ }
2599
+ else if (this.position === 'bottom') {
2600
+ this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2601
+ this.triangle.style.transform = `translate(-50%, 0rem) rotate(180deg)`;
2602
+ }
2603
+ this.triangle.style.width = '0';
2604
+ this.triangle.style.height = '0';
2605
+ this.triangle.style.borderLeft = `${triangleSize} solid transparent`;
2606
+ this.triangle.style.borderRight = `${triangleSize} solid transparent`;
2607
+ this.triangle.style.borderTop = `${triangleSize} solid ${colors[this.klpWithTooltip].withAlpha}`;
2608
+ el.nativeElement.prepend(this.triangle);
2609
+ this.triangleWhite = document.createElement('div');
2610
+ this.triangleWhite.style.zIndex = `${zIndexStart + 3}`;
2611
+ this.triangleWhite.style.position = 'fixed';
2612
+ this.triangleWhite.style.left = `calc(${el.nativeElement.getBoundingClientRect().x + el.nativeElement.getBoundingClientRect().width}px - 2rem)`;
2613
+ if (this.position === 'top') {
2614
+ this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2615
+ this.triangleWhite.style.transform = `translate(-50%, calc(-100% + 0.1rem - 2px))`;
2616
+ }
2617
+ else if (this.position === 'bottom') {
2618
+ this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2619
+ this.triangleWhite.style.transform = `translate(-50%, -2px) rotate(180deg)`;
2620
+ }
2621
+ this.triangleWhite.style.width = '0';
2622
+ this.triangleWhite.style.height = '0';
2623
+ this.triangleWhite.style.borderLeft = `${triangleSize} solid transparent`;
2624
+ this.triangleWhite.style.borderRight = `${triangleSize} solid transparent`;
2625
+ if (stringIsSetAndFilled(textToDisplay)) {
2626
+ this.triangleWhite.style.borderTop = `${triangleSize} solid white`;
2627
+ }
2628
+ else if (this.templateInstance) {
2629
+ this.div.style.visibility = 'hidden';
2630
+ setTimeout(() => {
2631
+ const color = getComputedStyle(this.templateInstance).backgroundColor || getComputedStyle(this.templateInstance).background;
2632
+ this.triangleWhite.style.borderTop = `${triangleSize} solid ${color}`;
2633
+ this.div.style.visibility = 'visible';
2634
+ });
2635
+ }
2636
+ el.nativeElement.prepend(this.triangleWhite);
2637
+ });
2638
+ el.nativeElement.addEventListener('mouseleave', () => {
2639
+ if (this.tooltipTemplate) {
2640
+ this.cleanUpTemplate();
2641
+ }
2642
+ try {
2643
+ el.nativeElement.removeChild(this.div);
2644
+ }
2645
+ catch (ex) { }
2646
+ try {
2647
+ el.nativeElement.removeChild(this.triangle);
2648
+ }
2649
+ catch (ex) { }
2650
+ try {
2651
+ el.nativeElement.removeChild(this.triangleWhite);
2652
+ }
2653
+ catch (ex) { }
2654
+ });
2646
2655
  });
2647
2656
  }
2648
- ngOnChanges(simpleChanges) {
2649
- if (simpleChanges.tooltipTemplate?.currentValue) {
2650
- const viewRef = this.tooltipTemplate.createEmbeddedView(null);
2651
- this.appRef.attachView(viewRef);
2652
- this.templateInstance = viewRef.rootNodes[0];
2653
- }
2657
+ hookUpTemplate() {
2658
+ this.viewRefForTemplate = this.tooltipTemplate.createEmbeddedView(null);
2659
+ this.appRef.attachView(this.viewRefForTemplate);
2660
+ this.templateInstance = this.viewRefForTemplate.rootNodes[0];
2661
+ }
2662
+ cleanUpTemplate() {
2663
+ this.appRef.detachView(this.viewRefForTemplate);
2664
+ this.viewRefForTemplate.destroy();
2654
2665
  }
2655
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: WithTooltipDirective, deps: [{ token: i0.ElementRef }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Directive }); }
2656
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.0", type: WithTooltipDirective, selector: "[klpWithTooltip]", inputs: { klpWithTooltip: "klpWithTooltip", tooltipText: "tooltipText", tooltipTemplate: "tooltipTemplate", position: "position" }, usesOnChanges: true, ngImport: i0 }); }
2666
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: WithTooltipDirective, deps: [{ token: i0.ElementRef }, { token: i0.ApplicationRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2667
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.0", type: WithTooltipDirective, selector: "[klpWithTooltip]", inputs: { klpWithTooltip: "klpWithTooltip", tooltipText: "tooltipText", tooltipTemplate: "tooltipTemplate", position: "position" }, ngImport: i0 }); }
2657
2668
  }
2658
2669
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: WithTooltipDirective, decorators: [{
2659
2670
  type: Directive,
2660
2671
  args: [{
2661
2672
  selector: '[klpWithTooltip]'
2662
2673
  }]
2663
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ApplicationRef }], propDecorators: { klpWithTooltip: [{
2674
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ApplicationRef }, { type: i0.NgZone }], propDecorators: { klpWithTooltip: [{
2664
2675
  type: Input
2665
2676
  }], tooltipText: [{
2666
2677
  type: Input