@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.
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __assign, __extends, __spread, __awaiter, __generator, __param, __values, __rest, __read } from 'tslib';
2
- import { EventEmitter, Input, Output, Component, ContentChildren, ViewChild, HostListener, forwardRef, NgModule, ɵɵdefineInjectable, Injectable, ElementRef, ApplicationRef, ComponentFactoryResolver, Injector, Directive, KeyValueDiffers, HostBinding, Renderer2, TemplateRef, InjectionToken, Inject, ViewEncapsulation, ViewContainerRef, ChangeDetectorRef, Pipe, ɵɵinject, ContentChild, Optional, ViewChildren } from '@angular/core';
2
+ import { EventEmitter, Input, Output, Component, ContentChildren, ViewChild, HostListener, forwardRef, NgModule, ɵɵdefineInjectable, Injectable, ElementRef, ApplicationRef, ComponentFactoryResolver, Injector, Renderer2, Directive, KeyValueDiffers, HostBinding, TemplateRef, InjectionToken, Inject, ViewEncapsulation, ViewContainerRef, ChangeDetectorRef, Pipe, ɵɵinject, ContentChild, Optional, ViewChildren } from '@angular/core';
3
3
  import { trigger, transition, style as style$7, animate, state, group, query, animateChild } from '@angular/animations';
4
4
  import { Subject, of, from, ReplaySubject, throwError, forkJoin } from 'rxjs';
5
5
  import { takeUntil, tap, map, switchMap, catchError, first, filter, take, delay, debounceTime, repeat, finalize } from 'rxjs/operators';
@@ -445,13 +445,14 @@ var TooltipEvent;
445
445
  })(TooltipEvent || (TooltipEvent = {}));
446
446
 
447
447
  var TooltipDirective = /** @class */ (function () {
448
- function TooltipDirective(elementRef, appRef, componentFactoryResolver, injector, debounceUtils) {
448
+ function TooltipDirective(elementRef, appRef, componentFactoryResolver, injector, debounceUtils, renderer) {
449
449
  var _this = this;
450
450
  this.elementRef = elementRef;
451
451
  this.appRef = appRef;
452
452
  this.componentFactoryResolver = componentFactoryResolver;
453
453
  this.injector = injector;
454
454
  this.debounceUtils = debounceUtils;
455
+ this.renderer = renderer;
455
456
  this.position = TooltipPosition.Top;
456
457
  this.showDelay = 500;
457
458
  this.tooltipEvent = TooltipEvent.Hover;
@@ -464,6 +465,7 @@ var TooltipDirective = /** @class */ (function () {
464
465
  }
465
466
  TooltipDirective.prototype.ngOnInit = function () {
466
467
  this.validatePosition();
468
+ this.updateTooltipVisibilityWhenFocusOnInput();
467
469
  };
468
470
  TooltipDirective.prototype.ngOnDestroy = function () {
469
471
  this.destroy();
@@ -487,6 +489,59 @@ var TooltipDirective = /** @class */ (function () {
487
489
  TooltipDirective.prototype.isMousePositionOutsideOfElement = function (mouseX, mouseY, elementArea) {
488
490
  return mouseX < elementArea.left || mouseX >= elementArea.right || mouseY < elementArea.top || mouseY >= elementArea.bottom;
489
491
  };
492
+ /**
493
+ * Manipula a visibilidade do tooltip quando houver uma referência de input.
494
+ */
495
+ TooltipDirective.prototype.updateTooltipVisibilityWhenFocusOnInput = function () {
496
+ var _this = this;
497
+ if (this.focusedInputRef) {
498
+ var inputFocus = this.focusedInputRef;
499
+ var icon_1 = this.getIconFromFocusedInput(inputFocus);
500
+ this.renderer.listen(inputFocus, 'focus', function () {
501
+ if (icon_1 && _this.isMatchingTooltip(icon_1)) {
502
+ _this.createTootipByFocus(icon_1);
503
+ }
504
+ });
505
+ this.renderer.listen(inputFocus, 'blur', function () {
506
+ if (icon_1 && _this.isMatchingTooltip(icon_1)) {
507
+ _this.removeTooltip(icon_1);
508
+ _this.destroy();
509
+ }
510
+ });
511
+ }
512
+ };
513
+ /**
514
+ * Obtém o elemento do ícone associado ao label do input em focus.
515
+ * @param focusedInput O input em focus.
516
+ * @returns O ícone do input em focus ou null.
517
+ */
518
+ TooltipDirective.prototype.getIconFromFocusedInput = function (focusedInput) {
519
+ var label = document.querySelector("label[for='" + focusedInput.id + "']");
520
+ if (label) {
521
+ var icon = label.nextElementSibling;
522
+ return (icon === null || icon === void 0 ? void 0 : icon.classList.contains('info-sign__icon')) ? icon : null;
523
+ }
524
+ return null;
525
+ };
526
+ /**
527
+ * Verifica se o ícone tem o tooltip correspondente ao atual.
528
+ * @param icon O ícone do input em focus.
529
+ * @returns true se o tooltip corresponde; caso contrário, false.
530
+ */
531
+ TooltipDirective.prototype.isMatchingTooltip = function (icon) {
532
+ var tooltipText = icon.getAttribute('ng-reflect-tooltip');
533
+ return this.tooltip === tooltipText;
534
+ };
535
+ /**
536
+ * Remove o tooltip associado ao ícone do input em focus.
537
+ * @param icon O ícone do input em focus.
538
+ */
539
+ TooltipDirective.prototype.removeTooltip = function (icon) {
540
+ var tooltip = icon.querySelector('.tooltip');
541
+ if (tooltip) {
542
+ tooltip.remove();
543
+ }
544
+ };
490
545
  // whenever the component with the tooltip is clicked I destroy the tooltip.
491
546
  // whenever a key is pressed on the component with the tooltip I destroy the tooltip.
492
547
  TooltipDirective.prototype.onClick = function () {
@@ -551,10 +606,7 @@ var TooltipDirective = /** @class */ (function () {
551
606
  TooltipDirective.prototype.createTootip = function () {
552
607
  var _a;
553
608
  if (this.componentRef === null && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.length)) {
554
- var componentFactory = this.componentFactoryResolver.resolveComponentFactory(TooltipComponent);
555
- this.componentRef = componentFactory.create(this.injector);
556
- this.appRef.attachView(this.componentRef.hostView);
557
- var domElem = this.componentRef.hostView.rootNodes[0];
609
+ var domElem = this.getDomElement();
558
610
  document.body.appendChild(domElem);
559
611
  this.setTooltipComponentProperties();
560
612
  this.showTimeout = window.setTimeout(this.showTooltip.bind(this), this.showDelay);
@@ -564,6 +616,27 @@ var TooltipDirective = /** @class */ (function () {
564
616
  }
565
617
  }
566
618
  };
619
+ TooltipDirective.prototype.getDomElement = function () {
620
+ var componentFactory = this.componentFactoryResolver.resolveComponentFactory(TooltipComponent);
621
+ this.componentRef = componentFactory.create(this.injector);
622
+ this.appRef.attachView(this.componentRef.hostView);
623
+ return this.componentRef.hostView.rootNodes[0];
624
+ };
625
+ /**
626
+ * Cria um tooltip para o icone do input em focus.
627
+ *
628
+ * @param icon O ícone do input em focus.
629
+ */
630
+ TooltipDirective.prototype.createTootipByFocus = function (icon) {
631
+ var _a;
632
+ if (this.componentRef === null && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.length)) {
633
+ var domElem = this.getDomElement();
634
+ var tooltip_1 = domElem.querySelector('.tooltip');
635
+ icon.appendChild(tooltip_1);
636
+ this.setTooltipComponentProperties();
637
+ setTimeout(function () { return tooltip_1.classList.add("tooltip--visible"); }, 0);
638
+ }
639
+ };
567
640
  TooltipDirective.prototype.showTooltip = function () {
568
641
  if (this.componentRef !== null) {
569
642
  this.componentRef.instance.visible = this.visible;
@@ -681,7 +754,8 @@ var TooltipDirective = /** @class */ (function () {
681
754
  { type: ApplicationRef },
682
755
  { type: ComponentFactoryResolver },
683
756
  { type: Injector },
684
- { type: DebounceUtils }
757
+ { type: DebounceUtils },
758
+ { type: Renderer2 }
685
759
  ]; };
686
760
  __decorate([
687
761
  Input("sTooltip")
@@ -707,6 +781,9 @@ var TooltipDirective = /** @class */ (function () {
707
781
  __decorate([
708
782
  Input()
709
783
  ], TooltipDirective.prototype, "mobileBehavior", void 0);
784
+ __decorate([
785
+ Input()
786
+ ], TooltipDirective.prototype, "focusedInputRef", void 0);
710
787
  __decorate([
711
788
  HostListener("click"),
712
789
  HostListener("keydown")
@@ -6572,7 +6649,7 @@ var InfoSignComponent = /** @class */ (function () {
6572
6649
  InfoSignComponent = __decorate([
6573
6650
  Component({
6574
6651
  selector: "s-info-sign-component",
6575
- 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>",
6652
+ 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",
6576
6653
  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}"]
6577
6654
  })
6578
6655
  ], InfoSignComponent);
@@ -6594,6 +6671,7 @@ var InfoSignDirective = /** @class */ (function () {
6594
6671
  this.componentRef.instance.templateRef = this.templateRef;
6595
6672
  this.componentRef.instance.tooltip = this.sInfoSign;
6596
6673
  this.componentRef.instance.displayTime = this.displayTime;
6674
+ this.componentRef.instance.focusedInputRef = this.focusedInputRef;
6597
6675
  }
6598
6676
  else if (this.componentRef && this.sInfoSign) {
6599
6677
  this.componentRef.instance.tooltip = this.sInfoSign;
@@ -6619,6 +6697,9 @@ var InfoSignDirective = /** @class */ (function () {
6619
6697
  __decorate([
6620
6698
  Input('sInfoSignDisplayTime')
6621
6699
  ], InfoSignDirective.prototype, "displayTime", void 0);
6700
+ __decorate([
6701
+ Input('sInfoSignFocusedInputRef')
6702
+ ], InfoSignDirective.prototype, "focusedInputRef", void 0);
6622
6703
  InfoSignDirective = __decorate([
6623
6704
  Directive({
6624
6705
  selector: "[sInfoSign]",