@seniorsistemas/angular-components 17.10.0 → 17.10.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.
@@ -525,8 +525,8 @@
525
525
  }
526
526
  TooltipComponent = __decorate([
527
527
  core.Component({
528
- template: "<div\n class=\"tooltip\"\n [ngClass]=\"['tooltip--' + position]\"\n [class.tooltip--visible]=\"visible\"\n [ngStyle]=\"{\n 'left': left + 'px',\n 'top': top + 'px'\n }\">\n <ng-template\n *ngIf=\"escape;\n then escapeTemplate;\n else noEscapeTemplate\">\n </ng-template> \n</div>\n\n<ng-template #noEscapeTemplate>\n <span\n class=\"tooltip__content\"\n [innerHTML]=\"tooltip\">\n </span>\n</ng-template>\n\n<ng-template #escapeTemplate>\n <span class=\"tooltip__content\">\n {{ tooltip }}\n </span>\n</ng-template>",
529
- styles: [".tooltip{background-color:#000;border-radius:2px;color:#fff;font-family:\"Open Sans\",sans-serif;font-size:14px;font-weight:400;line-height:21px;margin-top:5px;opacity:0;padding:8px;position:fixed;transform:translateX(-50%);text-align:center;max-width:150px;word-wrap:break-word;z-index:99999}.tooltip--visible{opacity:1;transition:opacity .3s}.tooltip::before{content:\"\";height:0;position:absolute;width:0}.tooltip--bottom{margin-top:8px;transform:translateX(-50%)}.tooltip--bottom::before{border:5px solid transparent;border-bottom:5px solid #000;left:calc(50% - 5px);top:-10px}.tooltip--top{margin-bottom:8px;transform:translate(-50%,-100%)}.tooltip--top::before{border:5px solid transparent;border-top:5px solid #000;left:calc(50% - 5px);bottom:-10px}.tooltip--left{margin-right:28px;transform:translate(calc(-100% - 7px),-50%)}.tooltip--left::before{border:5px solid transparent;border-left:5px solid #000;right:-10px;bottom:calc(50% - 5px)}.tooltip--right{margin-left:7px;transform:translateY(-50%)}.tooltip--right::before{border:5px solid transparent;border-right:5px solid #000;left:-10px;bottom:calc(50% - 5px)}"]
528
+ template: "<div\n id=\"tooltip\"\n class=\"tooltip\"\n [ngClass]=\"['tooltip--' + position]\"\n [class.tooltip--visible]=\"visible\"\n [ngStyle]=\"{\n 'left': left + 'px',\n 'top': top + 'px'\n }\">\n <ng-template\n *ngIf=\"escape;\n then escapeTemplate;\n else noEscapeTemplate\">\n </ng-template> \n</div>\n\n<ng-template #noEscapeTemplate>\n <span\n class=\"tooltip__content\"\n [innerHTML]=\"tooltip\">\n </span>\n</ng-template>\n\n<ng-template #escapeTemplate>\n <span class=\"tooltip__content\">\n {{ tooltip }}\n </span>\n</ng-template>",
529
+ styles: [".tooltip{background-color:#000;border-radius:2px;color:#fff;font-family:\"Open Sans\",sans-serif;font-size:14px;font-weight:400;line-height:21px;margin-top:5px;opacity:0;padding:8px;position:fixed;transform:translateX(-50%);text-align:center;max-width:220px;word-wrap:break-word;z-index:99999}.tooltip--visible{opacity:1;transition:opacity .3s}.tooltip::before{content:\"\";height:0;position:absolute;width:0}.tooltip--bottom{margin-top:8px;transform:translateX(-50%)}.tooltip--bottom::before{border:5px solid transparent;border-bottom:5px solid #000;left:calc(50% - 5px);top:-10px}.tooltip--top{margin-bottom:8px;transform:translate(-50%,-100%)}.tooltip--top::before{border:5px solid transparent;border-top:5px solid #000;left:calc(50% - 5px);bottom:-10px}.tooltip--left{margin-right:28px;transform:translate(calc(-100% - 7px),-50%)}.tooltip--left::before{border:5px solid transparent;border-left:5px solid #000;right:-10px;bottom:calc(50% - 5px)}.tooltip--right{margin-left:7px;transform:translateY(-50%)}.tooltip--right::before{border:5px solid transparent;border-right:5px solid #000;left:-10px;bottom:calc(50% - 5px)}"]
530
530
  })
531
531
  ], TooltipComponent);
532
532
  return TooltipComponent;
@@ -626,7 +626,7 @@
626
626
  top: Math.min(elementRect.top, toolTipRect.top),
627
627
  right: Math.max(elementRect.right, toolTipRect.right),
628
628
  left: Math.min(elementRect.left, toolTipRect.left),
629
- bottom: Math.max(elementRect.bottom, toolTipRect.bottom)
629
+ bottom: Math.max(elementRect.bottom, toolTipRect.bottom),
630
630
  };
631
631
  if (this.isMousePositionOutsideOfElement(event.clientX, event.clientY, totalElementArea)) {
632
632
  this.destroy();
@@ -643,12 +643,12 @@
643
643
  if (this.focusedInputRef) {
644
644
  var inputFocus = this.focusedInputRef;
645
645
  var icon_1 = this.getIconFromFocusedInput();
646
- this.renderer.listen(this.focusedInputRef, 'focus', function () {
646
+ this.renderer.listen(this.focusedInputRef, "focus", function () {
647
647
  if (icon_1 && _this.isMatchingTooltip(icon_1)) {
648
648
  _this.createTootipByFocus(icon_1);
649
649
  }
650
650
  });
651
- this.renderer.listen(inputFocus, 'blur', function () {
651
+ this.renderer.listen(inputFocus, "blur", function () {
652
652
  if (icon_1 && _this.isMatchingTooltip(icon_1)) {
653
653
  _this.removeTooltip(icon_1);
654
654
  _this.destroy();
@@ -669,7 +669,7 @@
669
669
  * @returns true se o tooltip corresponde; caso contrário, false.
670
670
  */
671
671
  TooltipDirective.prototype.isMatchingTooltip = function (icon) {
672
- var tooltipText = icon.getAttribute('ng-reflect-tooltip');
672
+ var tooltipText = icon.getAttribute("ng-reflect-tooltip");
673
673
  return this.tooltip === tooltipText;
674
674
  };
675
675
  /**
@@ -677,7 +677,7 @@
677
677
  * @param icon O ícone do input em focus.
678
678
  */
679
679
  TooltipDirective.prototype.removeTooltip = function (icon) {
680
- var tooltip = icon.querySelector('.tooltip');
680
+ var tooltip = icon.querySelector(".tooltip");
681
681
  if (tooltip) {
682
682
  tooltip.remove();
683
683
  }
@@ -685,9 +685,7 @@
685
685
  // whenever the component with the tooltip is clicked I destroy the tooltip.
686
686
  // whenever a key is pressed on the component with the tooltip I destroy the tooltip.
687
687
  TooltipDirective.prototype.onClick = function () {
688
- if (this.tooltipEvent === TooltipEvent.Hover &&
689
- !navigator.userAgent.match(/Android/i) &&
690
- !navigator.userAgent.match(/iPhone/i)) {
688
+ if (this.tooltipEvent === TooltipEvent.Hover && !navigator.userAgent.match(/Android/i) && !navigator.userAgent.match(/iPhone/i)) {
691
689
  this.destroy();
692
690
  }
693
691
  };
@@ -732,12 +730,7 @@
732
730
  }
733
731
  };
734
732
  TooltipDirective.prototype.validatePosition = function () {
735
- var containsPosition = [
736
- exports.TooltipPosition.Top,
737
- exports.TooltipPosition.Right,
738
- exports.TooltipPosition.Bottom,
739
- exports.TooltipPosition.Left,
740
- ].includes(this.position);
733
+ var containsPosition = [exports.TooltipPosition.Top, exports.TooltipPosition.Right, exports.TooltipPosition.Bottom, exports.TooltipPosition.Left].includes(this.position);
741
734
  if (!containsPosition) {
742
735
  this.position = exports.TooltipPosition.Top;
743
736
  throw new Error("Tooltip " + this.position + " position is unexpected");
@@ -750,7 +743,7 @@
750
743
  document.body.appendChild(domElem);
751
744
  this.setTooltipComponentProperties();
752
745
  this.showTimeout = window.setTimeout(this.showTooltip.bind(this), this.showDelay);
753
- this.tooltipDivElement = domElem.querySelector('.tooltip');
746
+ this.tooltipDivElement = domElem.querySelector(".tooltip");
754
747
  if (this.displayTime) {
755
748
  window.setTimeout(this.destroy.bind(this), this.displayTime);
756
749
  }
@@ -772,142 +765,81 @@
772
765
  var _a;
773
766
  if (this.componentRef === null && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.length)) {
774
767
  var domElem = this.getDomElement();
775
- var tooltip_1 = domElem.querySelector('.tooltip');
768
+ var tooltip_1 = domElem.querySelector(".tooltip");
776
769
  icon.appendChild(tooltip_1);
777
770
  this.setTooltipComponentProperties();
778
771
  setTimeout(function () { return tooltip_1.classList.add("tooltip--visible"); }, 0);
779
- this.renderer.listen(window, 'scroll', function () {
780
- _this.updateTooltipPosition();
772
+ this.renderer.listen(window, "scroll", function () {
773
+ _this.setTooltipPositionProperty();
781
774
  });
782
775
  }
783
776
  };
784
- TooltipDirective.prototype.updateTooltipPosition = function () {
785
- if (this.componentRef) {
786
- var _a = this.elementRef.nativeElement.getBoundingClientRect(), left = _a.left, right = _a.right, top_1 = _a.top, bottom = _a.bottom;
787
- var tooltipWidth = right - left;
788
- var tooltipHeight = bottom - top_1;
789
- switch (this.position) {
790
- case exports.TooltipPosition.Top:
791
- this.componentRef.instance.left = Math.round(tooltipWidth / 2 + left);
792
- this.componentRef.instance.top = Math.round(top_1 - 20 - 5);
793
- break;
794
- case exports.TooltipPosition.Bottom:
795
- this.componentRef.instance.left = Math.round(tooltipWidth / 2 + left);
796
- this.componentRef.instance.top = Math.round(bottom + 20);
797
- break;
798
- case exports.TooltipPosition.Left:
799
- this.componentRef.instance.left = Math.round(left - 20);
800
- this.componentRef.instance.top = Math.round(top_1 + tooltipHeight / 2 - 5);
801
- break;
802
- case exports.TooltipPosition.Right:
803
- this.componentRef.instance.left = Math.round(right + 20);
804
- this.componentRef.instance.top = Math.round(top_1 + tooltipHeight / 2 - 5);
805
- break;
806
- default:
807
- break;
808
- }
809
- }
810
- };
811
777
  TooltipDirective.prototype.showTooltip = function () {
812
778
  if (this.componentRef !== null) {
813
779
  this.componentRef.instance.visible = this.visible;
814
- window.addEventListener('mousemove', this.boundOnWindowMouseMoveFunction);
780
+ this.setTooltipPositionProperty();
781
+ window.addEventListener("mousemove", this.boundOnWindowMouseMoveFunction);
815
782
  }
816
783
  };
817
- TooltipDirective.prototype.setTooltipComponentProperties = function () {
784
+ TooltipDirective.prototype.setTooltipPositionProperty = function () {
785
+ var e_1, _a;
818
786
  var margin = 20;
819
787
  var anchorSize = 5;
788
+ var domElem = this.componentRef.hostView.rootNodes[0].querySelector("#tooltip");
789
+ var _b = domElem.getBoundingClientRect(), height = _b.height, width = _b.width;
790
+ var _c = this.elementRef.nativeElement.getBoundingClientRect(), left = _c.left, right = _c.right, top = _c.top, bottom = _c.bottom;
791
+ var positions = [
792
+ {
793
+ pos: exports.TooltipPosition.Top,
794
+ check: function () { return top > height; },
795
+ set: function () { return ({ left: left + (right - left) / 2, top: top - margin - anchorSize }); },
796
+ },
797
+ {
798
+ pos: exports.TooltipPosition.Bottom,
799
+ check: function () { return document.body.clientHeight - bottom > height; },
800
+ set: function () { return ({ left: left + (right - left) / 2, top: bottom + margin }); },
801
+ },
802
+ {
803
+ pos: exports.TooltipPosition.Left,
804
+ check: function () { return left > width; },
805
+ set: function () { return ({ left: left - margin, top: top + height / 2 - anchorSize }); },
806
+ },
807
+ {
808
+ pos: exports.TooltipPosition.Right,
809
+ check: function () { return document.body.clientWidth - right > width; },
810
+ set: function () { return ({ left: right + margin, top: top + height / 2 - anchorSize }); },
811
+ },
812
+ ];
813
+ try {
814
+ for (var positions_1 = __values(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
815
+ var _d = positions_1_1.value, pos = _d.pos, check = _d.check, set = _d.set;
816
+ if (check()) {
817
+ this.position = pos;
818
+ var _e = set(), left_1 = _e.left, top_1 = _e.top;
819
+ this.componentRef.instance.left = Math.round(left_1);
820
+ this.componentRef.instance.top = Math.round(top_1);
821
+ this.componentRef.instance.position = this.position;
822
+ return;
823
+ }
824
+ }
825
+ }
826
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
827
+ finally {
828
+ try {
829
+ if (positions_1_1 && !positions_1_1.done && (_a = positions_1.return)) _a.call(positions_1);
830
+ }
831
+ finally { if (e_1) throw e_1.error; }
832
+ }
833
+ // Se não conseguir posicionar, mostrar abaixo
834
+ this.position = exports.TooltipPosition.Bottom;
835
+ this.componentRef.instance.left = Math.round(left + (right - left) / 2);
836
+ this.componentRef.instance.top = Math.round(bottom + margin);
837
+ this.componentRef.instance.position = this.position;
838
+ };
839
+ TooltipDirective.prototype.setTooltipComponentProperties = function () {
820
840
  if (this.componentRef !== null) {
821
841
  this.componentRef.instance.tooltip = this.tooltip;
822
842
  this.componentRef.instance.escape = this.escape;
823
- var _a = this.elementRef.nativeElement.getBoundingClientRect(), left = _a.left, right = _a.right, top_2 = _a.top, bottom = _a.bottom;
824
- var tooltipHeight = bottom - top_2;
825
- var tooltipWidth = right - left;
826
- var safeSpace = 150;
827
- var positioned = false;
828
- var invalidOptions = [];
829
- while (!positioned) {
830
- if (invalidOptions.includes(exports.TooltipPosition.Top)
831
- && invalidOptions.includes(exports.TooltipPosition.Bottom)
832
- && invalidOptions.includes(exports.TooltipPosition.Left)
833
- && invalidOptions.includes(exports.TooltipPosition.Right)) {
834
- this.destroy();
835
- throw new Error("No space to show tooltip");
836
- }
837
- switch (this.position) {
838
- case exports.TooltipPosition.Top: {
839
- if (invalidOptions.includes(exports.TooltipPosition.Top)) {
840
- this.position = exports.TooltipPosition.Left;
841
- break;
842
- }
843
- var topShift = top_2;
844
- if (topShift <= tooltipHeight + safeSpace) {
845
- this.position = exports.TooltipPosition.Bottom;
846
- invalidOptions.push(exports.TooltipPosition.Top);
847
- positioned = false;
848
- break;
849
- }
850
- this.componentRef.instance.left = Math.round(tooltipWidth / 2 + left);
851
- this.componentRef.instance.top = Math.round(top_2 - margin - anchorSize);
852
- positioned = true;
853
- break;
854
- }
855
- case exports.TooltipPosition.Bottom: {
856
- if (invalidOptions.includes(exports.TooltipPosition.Bottom)) {
857
- this.position = exports.TooltipPosition.Left;
858
- break;
859
- }
860
- var bottomShift = document.body.clientHeight - bottom;
861
- if (bottomShift <= tooltipHeight + safeSpace) {
862
- this.position = exports.TooltipPosition.Top;
863
- invalidOptions.push(exports.TooltipPosition.Bottom);
864
- break;
865
- }
866
- this.componentRef.instance.left = Math.round(tooltipWidth / 2 + left);
867
- this.componentRef.instance.top = Math.round(bottom + margin);
868
- positioned = true;
869
- break;
870
- }
871
- case exports.TooltipPosition.Left: {
872
- if (invalidOptions.includes(exports.TooltipPosition.Left)) {
873
- this.position = exports.TooltipPosition.Top;
874
- break;
875
- }
876
- var leftShift = left;
877
- if (leftShift <= tooltipWidth + safeSpace) {
878
- this.position = exports.TooltipPosition.Right;
879
- invalidOptions.push(exports.TooltipPosition.Left);
880
- positioned = false;
881
- break;
882
- }
883
- this.componentRef.instance.left = Math.round(left - margin);
884
- this.componentRef.instance.top = Math.round(top_2 + tooltipHeight / 2 - anchorSize);
885
- positioned = true;
886
- break;
887
- }
888
- case exports.TooltipPosition.Right: {
889
- if (invalidOptions.includes(exports.TooltipPosition.Right)) {
890
- this.position = exports.TooltipPosition.Top;
891
- break;
892
- }
893
- var rightShift = document.body.clientWidth - right;
894
- if (rightShift <= tooltipWidth + safeSpace) {
895
- this.position = exports.TooltipPosition.Left;
896
- invalidOptions.push(exports.TooltipPosition.Right);
897
- positioned = false;
898
- break;
899
- }
900
- this.componentRef.instance.left = Math.round(right + margin);
901
- this.componentRef.instance.top = Math.round(top_2 + tooltipHeight / 2 - anchorSize);
902
- positioned = true;
903
- break;
904
- }
905
- default: {
906
- break;
907
- }
908
- }
909
- this.componentRef.instance.position = this.position;
910
- }
911
843
  }
912
844
  };
913
845
  TooltipDirective.prototype.destroy = function () {
@@ -918,7 +850,7 @@
918
850
  this.componentRef = null;
919
851
  this.tooltipDivElement = null;
920
852
  }
921
- window.removeEventListener('mousemove', this.boundOnWindowMouseMoveFunction);
853
+ window.removeEventListener("mousemove", this.boundOnWindowMouseMoveFunction);
922
854
  };
923
855
  TooltipDirective.ctorParameters = function () { return [
924
856
  { type: core.ElementRef },
@@ -9572,7 +9504,7 @@
9572
9504
  ], LookupFieldComponent.prototype, "formControl", void 0);
9573
9505
  LookupFieldComponent = __decorate([
9574
9506
  core.Component({
9575
- template: "<s-field-label [field]=\"field\">\n\n<div [sTooltip]=\"field.tooltip\" tooltipPosition=\"top\" [showDelay]=\"500\">\n <s-lookup\n [id]=\"field.id || field.name\"\n [multiple]=\"field.multiple\"\n [formControl]=\"formControl\"\n [lookupSuggestions]=\"field.lookupSuggestions\"\n [dataKey]=\"field.dataKey\"\n [placeholder]=\"field.placeholder\"\n [showSearch]=\"field.showSearch\"\n [searchFields]=\"field.searchFields\"\n [searchGridFields]=\"field.searchGridFields\"\n [searchGridData]=\"field.gridData\"\n (onLookupRequest)=\"field.onLookupRequest($event)\"\n (onSearchRequest)=\"field.onSearchRequest($event)\"\n [lookupDisplayField]=\"field.lookupDisplayField\"\n [searchTotalRecords]=\"field.searchTotalRecords\"\n [searchTotalRecordsLabel]=\"field.searchTotalRecordsLabel\"\n [searchTitle]=\"field.searchTitle\"\n [selectLabel]=\"field.selectLabel\"\n [searchEmptyTitle]=\"field.searchEmptyTitle\"\n [filterLabel]=\"field.filterLabel\"\n [filterTitle]=\"field.filterTitle\"\n [clearLabel]=\"field.clearLabel\"\n [cancelLabel]=\"field.cancelLabel\"\n [emptyFieldLabel]=\"field.emptyFieldLabel\"\n (onSelect)=\"field.onSelect($event)\"\n (onUnselect)=\"field.onUnselect($event)\"\n (onClear)=\"field.onClear ? field.onClear($event) : null\"\n (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n [lookupAppendTo]=\"field.appendTo\"\n [lookupEmptyMessage]=\"field.emptyMessage\"\n [recordLabel]=\"field.recordLabel\"\n [recordsLabel]=\"field.recordsLabel\"\n [defaultFilter]=\"field.defaultFilter\"\n [autocompleteForceSelection]=\"field.autocompleteForceSelection\"\n [showAddOption]=\"field.showAddOption\"\n [showEditOption]=\"field.showEditOption\"\n [showRemoveOption]=\"field.showRemoveOption\"\n (onAdd)=\"field.onAdd()\"\n (onEdit)=\"field.onEdit($event)\"\n (onRemove)=\"field.onRemove($event)\"\n >\n </s-lookup>\n</div>\n"
9507
+ template: "<s-field-label [field]=\"field\"></s-field-label>\n\n<div [sTooltip]=\"field.tooltip\" tooltipPosition=\"top\" [showDelay]=\"500\">\n <s-lookup\n [id]=\"field.id || field.name\"\n [multiple]=\"field.multiple\"\n [formControl]=\"formControl\"\n [lookupSuggestions]=\"field.lookupSuggestions\"\n [dataKey]=\"field.dataKey\"\n [placeholder]=\"field.placeholder\"\n [showSearch]=\"field.showSearch\"\n [searchFields]=\"field.searchFields\"\n [searchGridFields]=\"field.searchGridFields\"\n [searchGridData]=\"field.gridData\"\n (onLookupRequest)=\"field.onLookupRequest($event)\"\n (onSearchRequest)=\"field.onSearchRequest($event)\"\n [lookupDisplayField]=\"field.lookupDisplayField\"\n [searchTotalRecords]=\"field.searchTotalRecords\"\n [searchTotalRecordsLabel]=\"field.searchTotalRecordsLabel\"\n [searchTitle]=\"field.searchTitle\"\n [selectLabel]=\"field.selectLabel\"\n [searchEmptyTitle]=\"field.searchEmptyTitle\"\n [filterLabel]=\"field.filterLabel\"\n [filterTitle]=\"field.filterTitle\"\n [clearLabel]=\"field.clearLabel\"\n [cancelLabel]=\"field.cancelLabel\"\n [emptyFieldLabel]=\"field.emptyFieldLabel\"\n (onSelect)=\"field.onSelect($event)\"\n (onUnselect)=\"field.onUnselect($event)\"\n (onClear)=\"field.onClear ? field.onClear($event) : null\"\n (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n [lookupAppendTo]=\"field.appendTo\"\n [lookupEmptyMessage]=\"field.emptyMessage\"\n [recordLabel]=\"field.recordLabel\"\n [recordsLabel]=\"field.recordsLabel\"\n [defaultFilter]=\"field.defaultFilter\"\n [autocompleteForceSelection]=\"field.autocompleteForceSelection\"\n [showAddOption]=\"field.showAddOption\"\n [showEditOption]=\"field.showEditOption\"\n [showRemoveOption]=\"field.showRemoveOption\"\n (onAdd)=\"field.onAdd()\"\n (onEdit)=\"field.onEdit($event)\"\n (onRemove)=\"field.onRemove($event)\"\n >\n </s-lookup>\n</div>\n"
9576
9508
  })
9577
9509
  ], LookupFieldComponent);
9578
9510
  return LookupFieldComponent;