@klippa/ngx-enhancy-forms 14.22.5 → 14.22.7

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.
@@ -668,20 +668,33 @@ class FormElementComponent {
668
668
  return this.getErrorToShow() === error && !this.customErrorHandlers.some((e) => e.error === error);
669
669
  }
670
670
  getScrollableParent(node) {
671
- if (node == null) {
672
- return null;
671
+ if (node === window.document.documentElement) {
672
+ return window.document.documentElement;
673
673
  }
674
- if (node.scrollHeight > node.clientHeight) {
674
+ const overflowY = getComputedStyle(node).overflowY;
675
+ if (node.clientHeight < node.scrollHeight && (overflowY === 'auto' || overflowY === 'scroll')) {
675
676
  return node;
676
677
  }
677
678
  else {
678
679
  return this.getScrollableParent(node.parentNode);
679
680
  }
680
681
  }
682
+ getPageOffset(elem) {
683
+ let topOffset = elem.getBoundingClientRect().top;
684
+ while (elem !== document.documentElement) {
685
+ elem = elem.parentElement;
686
+ topOffset += elem.scrollTop;
687
+ }
688
+ return topOffset;
689
+ }
681
690
  scrollTo() {
682
- this.internalComponentRef.nativeElement.scrollIntoView(true);
683
- // to give some breathing room, we scroll 100px more to the top
684
- this.getScrollableParent(this.internalComponentRef.nativeElement)?.scrollBy(0, -100);
691
+ const parent = this.getScrollableParent(this.internalComponentRef.nativeElement);
692
+ const pageOffsetElement = this.getPageOffset(this.internalComponentRef.nativeElement);
693
+ const pageOffsetParent = parent === window.document.documentElement ? 0 : this.getPageOffset(parent);
694
+ parent.scrollTo({
695
+ top: pageOffsetElement - pageOffsetParent - 30,
696
+ behavior: 'smooth'
697
+ });
685
698
  }
686
699
  isRequired() {
687
700
  if (isValueSet(this.input)) {
@@ -2447,6 +2460,7 @@ class WithTooltipDirective {
2447
2460
  this.el = el;
2448
2461
  this.appRef = appRef;
2449
2462
  this.klpWithTooltip = 'orange';
2463
+ this.position = 'top';
2450
2464
  el.nativeElement.addEventListener('mouseenter', () => {
2451
2465
  let textToDisplay;
2452
2466
  if (!this.templateInstance) {
@@ -2479,8 +2493,14 @@ class WithTooltipDirective {
2479
2493
  this.div.style.color = `${colors[this.klpWithTooltip].noAlpha}`;
2480
2494
  this.div.style.position = 'fixed';
2481
2495
  this.div.style.left = `${el.nativeElement.getBoundingClientRect().x}px`;
2482
- this.div.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2483
- this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(-100% - 0.3rem))`;
2496
+ if (this.position === 'top') {
2497
+ this.div.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2498
+ this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(-100% - 0.3rem))`;
2499
+ }
2500
+ else if (this.position === 'bottom') {
2501
+ this.div.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2502
+ this.div.style.transform = `translate(calc(-100% + ${el.nativeElement.getBoundingClientRect().width}px), calc(0% + 0.3rem))`;
2503
+ }
2484
2504
  this.div.style.maxWidth = '200px';
2485
2505
  this.div.style.whiteSpace = 'break-spaces';
2486
2506
  this.div.style.backgroundColor = 'white';
@@ -2507,8 +2527,14 @@ class WithTooltipDirective {
2507
2527
  this.triangle.style.zIndex = `${zIndexStart + 1}`;
2508
2528
  this.triangle.style.position = 'fixed';
2509
2529
  this.triangle.style.left = `calc(${el.nativeElement.getBoundingClientRect().x + el.nativeElement.getBoundingClientRect().width}px - 2rem)`;
2510
- this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2511
- this.triangle.style.transform = `translate(-50%, calc(-100% + 0.1rem))`;
2530
+ if (this.position === 'top') {
2531
+ this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2532
+ this.triangle.style.transform = `translate(-50%, calc(-100% + 0.1rem))`;
2533
+ }
2534
+ else if (this.position === 'bottom') {
2535
+ this.triangle.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2536
+ this.triangle.style.transform = `translate(-50%, 0rem) rotate(180deg)`;
2537
+ }
2512
2538
  this.triangle.style.width = '0';
2513
2539
  this.triangle.style.height = '0';
2514
2540
  this.triangle.style.borderLeft = `${triangleSize} solid transparent`;
@@ -2519,8 +2545,14 @@ class WithTooltipDirective {
2519
2545
  this.triangleWhite.style.zIndex = `${zIndexStart + 3}`;
2520
2546
  this.triangleWhite.style.position = 'fixed';
2521
2547
  this.triangleWhite.style.left = `calc(${el.nativeElement.getBoundingClientRect().x + el.nativeElement.getBoundingClientRect().width}px - 2rem)`;
2522
- this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2523
- this.triangleWhite.style.transform = `translate(-50%, calc(-100% + 0.1rem - 2px))`;
2548
+ if (this.position === 'top') {
2549
+ this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y}px`;
2550
+ this.triangleWhite.style.transform = `translate(-50%, calc(-100% + 0.1rem - 2px))`;
2551
+ }
2552
+ else if (this.position === 'bottom') {
2553
+ this.triangleWhite.style.top = `${el.nativeElement.getBoundingClientRect().y + el.nativeElement.getBoundingClientRect().height}px`;
2554
+ this.triangleWhite.style.transform = `translate(-50%, -2px) rotate(180deg)`;
2555
+ }
2524
2556
  this.triangleWhite.style.width = '0';
2525
2557
  this.triangleWhite.style.height = '0';
2526
2558
  this.triangleWhite.style.borderLeft = `${triangleSize} solid transparent`;
@@ -2562,7 +2594,7 @@ class WithTooltipDirective {
2562
2594
  }
2563
2595
  }
2564
2596
  WithTooltipDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: WithTooltipDirective, deps: [{ token: i0.ElementRef }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Directive });
2565
- 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 });
2597
+ WithTooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.8", type: WithTooltipDirective, selector: "[klpWithTooltip]", inputs: { klpWithTooltip: "klpWithTooltip", tooltipText: "tooltipText", tooltipTemplate: "tooltipTemplate", position: "position" }, usesOnChanges: true, ngImport: i0 });
2566
2598
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: WithTooltipDirective, decorators: [{
2567
2599
  type: Directive,
2568
2600
  args: [{
@@ -2574,6 +2606,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
2574
2606
  type: Input
2575
2607
  }], tooltipTemplate: [{
2576
2608
  type: Input
2609
+ }], position: [{
2610
+ type: Input
2577
2611
  }] } });
2578
2612
 
2579
2613
  class NgxEnhancyFormsModule {