@seniorsistemas/angular-components 17.9.0 → 17.9.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.
@@ -591,13 +591,14 @@
591
591
  })(TooltipEvent || (TooltipEvent = {}));
592
592
 
593
593
  var TooltipDirective = /** @class */ (function () {
594
- function TooltipDirective(elementRef, appRef, componentFactoryResolver, injector, debounceUtils) {
594
+ function TooltipDirective(elementRef, appRef, componentFactoryResolver, injector, debounceUtils, renderer) {
595
595
  var _this = this;
596
596
  this.elementRef = elementRef;
597
597
  this.appRef = appRef;
598
598
  this.componentFactoryResolver = componentFactoryResolver;
599
599
  this.injector = injector;
600
600
  this.debounceUtils = debounceUtils;
601
+ this.renderer = renderer;
601
602
  this.position = exports.TooltipPosition.Top;
602
603
  this.showDelay = 500;
603
604
  this.tooltipEvent = TooltipEvent.Hover;
@@ -610,6 +611,7 @@
610
611
  }
611
612
  TooltipDirective.prototype.ngOnInit = function () {
612
613
  this.validatePosition();
614
+ this.updateTooltipVisibilityWhenFocusOnInput();
613
615
  };
614
616
  TooltipDirective.prototype.ngOnDestroy = function () {
615
617
  this.destroy();
@@ -633,6 +635,59 @@
633
635
  TooltipDirective.prototype.isMousePositionOutsideOfElement = function (mouseX, mouseY, elementArea) {
634
636
  return mouseX < elementArea.left || mouseX >= elementArea.right || mouseY < elementArea.top || mouseY >= elementArea.bottom;
635
637
  };
638
+ /**
639
+ * Manipula a visibilidade do tooltip quando houver uma referência de input.
640
+ */
641
+ TooltipDirective.prototype.updateTooltipVisibilityWhenFocusOnInput = function () {
642
+ var _this = this;
643
+ if (this.focusedInputRef) {
644
+ var inputFocus = this.focusedInputRef;
645
+ var icon_1 = this.getIconFromFocusedInput(inputFocus);
646
+ this.renderer.listen(inputFocus, 'focus', function () {
647
+ if (icon_1 && _this.isMatchingTooltip(icon_1)) {
648
+ _this.createTootipByFocus(icon_1);
649
+ }
650
+ });
651
+ this.renderer.listen(inputFocus, 'blur', function () {
652
+ if (icon_1 && _this.isMatchingTooltip(icon_1)) {
653
+ _this.removeTooltip(icon_1);
654
+ _this.destroy();
655
+ }
656
+ });
657
+ }
658
+ };
659
+ /**
660
+ * Obtém o elemento do ícone associado ao label do input em focus.
661
+ * @param focusedInput O input em focus.
662
+ * @returns O ícone do input em focus ou null.
663
+ */
664
+ TooltipDirective.prototype.getIconFromFocusedInput = function (focusedInput) {
665
+ var label = document.querySelector("label[for='" + focusedInput.id + "']");
666
+ if (label) {
667
+ var icon = label.nextElementSibling;
668
+ return (icon === null || icon === void 0 ? void 0 : icon.classList.contains('info-sign__icon')) ? icon : null;
669
+ }
670
+ return null;
671
+ };
672
+ /**
673
+ * Verifica se o ícone tem o tooltip correspondente ao atual.
674
+ * @param icon O ícone do input em focus.
675
+ * @returns true se o tooltip corresponde; caso contrário, false.
676
+ */
677
+ TooltipDirective.prototype.isMatchingTooltip = function (icon) {
678
+ var tooltipText = icon.getAttribute('ng-reflect-tooltip');
679
+ return this.tooltip === tooltipText;
680
+ };
681
+ /**
682
+ * Remove o tooltip associado ao ícone do input em focus.
683
+ * @param icon O ícone do input em focus.
684
+ */
685
+ TooltipDirective.prototype.removeTooltip = function (icon) {
686
+ var tooltip = icon.querySelector('.tooltip');
687
+ if (tooltip) {
688
+ tooltip.remove();
689
+ }
690
+ };
636
691
  // whenever the component with the tooltip is clicked I destroy the tooltip.
637
692
  // whenever a key is pressed on the component with the tooltip I destroy the tooltip.
638
693
  TooltipDirective.prototype.onClick = function () {
@@ -697,10 +752,7 @@
697
752
  TooltipDirective.prototype.createTootip = function () {
698
753
  var _a;
699
754
  if (this.componentRef === null && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.length)) {
700
- var componentFactory = this.componentFactoryResolver.resolveComponentFactory(TooltipComponent);
701
- this.componentRef = componentFactory.create(this.injector);
702
- this.appRef.attachView(this.componentRef.hostView);
703
- var domElem = this.componentRef.hostView.rootNodes[0];
755
+ var domElem = this.getDomElement();
704
756
  document.body.appendChild(domElem);
705
757
  this.setTooltipComponentProperties();
706
758
  this.showTimeout = window.setTimeout(this.showTooltip.bind(this), this.showDelay);
@@ -710,6 +762,27 @@
710
762
  }
711
763
  }
712
764
  };
765
+ TooltipDirective.prototype.getDomElement = function () {
766
+ var componentFactory = this.componentFactoryResolver.resolveComponentFactory(TooltipComponent);
767
+ this.componentRef = componentFactory.create(this.injector);
768
+ this.appRef.attachView(this.componentRef.hostView);
769
+ return this.componentRef.hostView.rootNodes[0];
770
+ };
771
+ /**
772
+ * Cria um tooltip para o icone do input em focus.
773
+ *
774
+ * @param icon O ícone do input em focus.
775
+ */
776
+ TooltipDirective.prototype.createTootipByFocus = function (icon) {
777
+ var _a;
778
+ if (this.componentRef === null && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.length)) {
779
+ var domElem = this.getDomElement();
780
+ var tooltip_1 = domElem.querySelector('.tooltip');
781
+ icon.appendChild(tooltip_1);
782
+ this.setTooltipComponentProperties();
783
+ setTimeout(function () { return tooltip_1.classList.add("tooltip--visible"); }, 0);
784
+ }
785
+ };
713
786
  TooltipDirective.prototype.showTooltip = function () {
714
787
  if (this.componentRef !== null) {
715
788
  this.componentRef.instance.visible = this.visible;
@@ -827,7 +900,8 @@
827
900
  { type: core.ApplicationRef },
828
901
  { type: core.ComponentFactoryResolver },
829
902
  { type: core.Injector },
830
- { type: DebounceUtils }
903
+ { type: DebounceUtils },
904
+ { type: core.Renderer2 }
831
905
  ]; };
832
906
  __decorate([
833
907
  core.Input("sTooltip")
@@ -853,6 +927,9 @@
853
927
  __decorate([
854
928
  core.Input()
855
929
  ], TooltipDirective.prototype, "mobileBehavior", void 0);
930
+ __decorate([
931
+ core.Input()
932
+ ], TooltipDirective.prototype, "focusedInputRef", void 0);
856
933
  __decorate([
857
934
  core.HostListener("click"),
858
935
  core.HostListener("keydown")
@@ -6718,7 +6795,7 @@
6718
6795
  InfoSignComponent = __decorate([
6719
6796
  core.Component({
6720
6797
  selector: "s-info-sign-component",
6721
- template: "<span class=\"info-sign\">\n <span *ngTemplateOutlet=\"templateRef\"></span>\n <i\n class=\"info-sign__icon fa fa-info-circle\"\n aria-hidden=\"true\"\n [sTooltip]=\"tooltip\"\n [escape]=\"false\"\n tooltipPosition=\"top\"\n [displayTime]=\"displayTime\"\n mobileBehavior=\"tap\"\n showDelay=\"0\">\n </i>\n</span>",
6798
+ template: "<span class=\"info-sign\">\n <span *ngTemplateOutlet=\"templateRef\"></span>\n <i\n class=\"info-sign__icon fa fa-info-circle\"\n aria-hidden=\"true\"\n [sTooltip]=\"tooltip\"\n [escape]=\"false\"\n tooltipPosition=\"top\"\n [displayTime]=\"displayTime\"\n mobileBehavior=\"tap\"\n showDelay=\"0\"\n [focusedInputRef]=\"focusedInputRef\">\n </i>\n</span>\n",
6722
6799
  styles: [".info-sign{-ms-flex-align:baseline;align-items:baseline;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:start;justify-content:flex-start}.info-sign .info-sign__icon{padding:0 12px}"]
6723
6800
  })
6724
6801
  ], InfoSignComponent);
@@ -6740,6 +6817,7 @@
6740
6817
  this.componentRef.instance.templateRef = this.templateRef;
6741
6818
  this.componentRef.instance.tooltip = this.sInfoSign;
6742
6819
  this.componentRef.instance.displayTime = this.displayTime;
6820
+ this.componentRef.instance.focusedInputRef = this.focusedInputRef;
6743
6821
  }
6744
6822
  else if (this.componentRef && this.sInfoSign) {
6745
6823
  this.componentRef.instance.tooltip = this.sInfoSign;
@@ -6765,6 +6843,9 @@
6765
6843
  __decorate([
6766
6844
  core.Input('sInfoSignDisplayTime')
6767
6845
  ], InfoSignDirective.prototype, "displayTime", void 0);
6846
+ __decorate([
6847
+ core.Input('sInfoSignFocusedInputRef')
6848
+ ], InfoSignDirective.prototype, "focusedInputRef", void 0);
6768
6849
  InfoSignDirective = __decorate([
6769
6850
  core.Directive({
6770
6851
  selector: "[sInfoSign]",