@energycap/components 0.26.8 → 0.26.9

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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/router'), require('@ngx-translate/core'), require('@angular/cdk/a11y'), require('rxjs'), require('rxjs/operators'), require('lodash'), require('moment'), require('popper.js'), require('ngx-clipboard')) :
3
- typeof define === 'function' && define.amd ? define('@energycap/components', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/router', '@ngx-translate/core', '@angular/cdk/a11y', 'rxjs', 'rxjs/operators', 'lodash', 'moment', 'popper.js', 'ngx-clipboard'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.energycap = global.energycap || {}, global.energycap.components = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.router, global.i1, global.ng.cdk.a11y, global.rxjs, global.rxjs.operators, global.lodash, global.moment, global.Popper, global.ngxClipboard));
5
- }(this, (function (exports, common, i0, forms, i1$1, i1, a11y, rxjs, operators, lodash, moment, Popper, ngxClipboard) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/router'), require('@ngx-translate/core'), require('@angular/cdk/a11y'), require('@angular/cdk/overlay'), require('rxjs'), require('rxjs/operators'), require('lodash'), require('moment'), require('popper.js'), require('@angular/cdk/portal'), require('ngx-clipboard')) :
3
+ typeof define === 'function' && define.amd ? define('@energycap/components', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/router', '@ngx-translate/core', '@angular/cdk/a11y', '@angular/cdk/overlay', 'rxjs', 'rxjs/operators', 'lodash', 'moment', 'popper.js', '@angular/cdk/portal', 'ngx-clipboard'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.energycap = global.energycap || {}, global.energycap.components = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.router, global.i1, global.ng.cdk.a11y, global.ng.cdk.overlay, global.rxjs, global.rxjs.operators, global.lodash, global.moment, global.Popper, global.ng.cdk.portal, global.ngxClipboard));
5
+ }(this, (function (exports, common, i0, forms, i1$1, i1, a11y, overlay, rxjs, operators, lodash, moment, Popper, portal, ngxClipboard) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -6389,22 +6389,86 @@
6389
6389
  };
6390
6390
 
6391
6391
  var PopoverComponent = /** @class */ (function () {
6392
- function PopoverComponent() {
6392
+ function PopoverComponent(overlay, viewContainerRef, elementRef) {
6393
+ this.overlay = overlay;
6394
+ this.viewContainerRef = viewContainerRef;
6395
+ this.elementRef = elementRef;
6393
6396
  this.icon = '';
6394
6397
  this.contentPosition = 'top-left';
6398
+ this.iconHoverClass = '';
6399
+ this.isVisible = false;
6395
6400
  }
6401
+ PopoverComponent.prototype.ngOnDestroy = function () {
6402
+ this.hide();
6403
+ };
6404
+ PopoverComponent.prototype.show = function () {
6405
+ if (!this.isVisible) {
6406
+ var overlayConfig = this.getOverlayConfig();
6407
+ this.overlayRef = this.overlay.create(overlayConfig);
6408
+ var contentPortal = new portal.TemplatePortal(this.content, this.viewContainerRef);
6409
+ this.contentViewRef = this.overlayRef.attach(contentPortal);
6410
+ this.isVisible = true;
6411
+ }
6412
+ };
6413
+ /**
6414
+ * Hides the popover if the mouse moves outside of the popover content
6415
+ */
6416
+ PopoverComponent.prototype.onMouseMove = function (event) {
6417
+ var _a;
6418
+ if (!this.contentRect) {
6419
+ this.contentRect = (_a = this.contentViewRef) === null || _a === void 0 ? void 0 : _a.rootNodes[0].getBoundingClientRect();
6420
+ }
6421
+ if (this.contentRect) {
6422
+ if (event.clientX > this.contentRect.right
6423
+ || event.clientX < this.contentRect.left
6424
+ || event.clientY > this.contentRect.bottom
6425
+ || event.clientY < this.contentRect.top) {
6426
+ this.hide();
6427
+ }
6428
+ }
6429
+ };
6430
+ PopoverComponent.prototype.hide = function () {
6431
+ var _a;
6432
+ this.contentRect = undefined;
6433
+ (_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.dispose();
6434
+ this.isVisible = false;
6435
+ };
6436
+ PopoverComponent.prototype.getOverlayConfig = function () {
6437
+ var position = this.getPosition();
6438
+ var positionStrategy = this.overlay.position()
6439
+ .flexibleConnectedTo(this.elementRef)
6440
+ .withPositions([position]);
6441
+ var config = new overlay.OverlayConfig({
6442
+ positionStrategy: positionStrategy
6443
+ });
6444
+ return config;
6445
+ };
6446
+ PopoverComponent.prototype.getPosition = function () {
6447
+ var position = this.contentPosition.split('-');
6448
+ var overlayX = (position[1] == 'left' ? 'start' : 'end');
6449
+ var overlayY = position[0];
6450
+ return { originX: overlayX, originY: overlayY, overlayX: overlayX, overlayY: overlayY };
6451
+ };
6396
6452
  return PopoverComponent;
6397
6453
  }());
6398
6454
  PopoverComponent.decorators = [
6399
6455
  { type: i0.Component, args: [{
6400
6456
  selector: 'ec-popover',
6401
- template: "<article class=\"popover-content {{contentPosition}}\">\r\n <ng-content></ng-content>\r\n</article>\r\n<i class=\"ec-icon {{icon}} ec-icon-sm\"></i>\r\n",
6402
- styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{line-height:1;padding:.5rem;position:relative;z-index:1}:host:hover{z-index:2}:host:hover .popover-content{display:block}.popover-content{border-radius:3px;box-shadow:0 3px 6px 0 rgba(26,26,35,.12);display:none;overflow:hidden;position:absolute}.popover-content.top-left{left:0;top:0}.popover-content.top-right{right:0;top:0}.popover-content.bottom-right{bottom:0;right:0}.popover-content.bottom-left{bottom:0;left:0}.ec-icon{position:relative}"]
6457
+ template: "<div class=\"p-2\">\r\n <i class=\"ec-icon {{icon}} ec-icon-sm\"></i>\r\n</div>\r\n\r\n<ng-template #content>\r\n <article class=\"popover-content\"\r\n (document:mousemove)=\"onMouseMove($event)\">\r\n <ng-content></ng-content>\r\n </article>\r\n <div class=\"p-2 {{contentPosition}}\">\r\n <i class=\"ec-icon {{icon}} ec-icon-sm {{iconHoverClass}}\"></i>\r\n </div>\r\n</ng-template>\r\n",
6458
+ styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:inline-block;line-height:1}.popover-content{border-radius:3px;box-shadow:0 3px 6px 0 rgba(26,26,35,.12);overflow:hidden;position:relative}.popover-content+div{line-height:1;position:absolute}.popover-content+div.top-left{left:0;top:0}.popover-content+div.top-right{right:0;top:0}.popover-content+div.bottom-right{bottom:0;right:0}.popover-content+div.bottom-left{bottom:0;left:0}"]
6403
6459
  },] }
6404
6460
  ];
6461
+ PopoverComponent.ctorParameters = function () { return [
6462
+ { type: overlay.Overlay },
6463
+ { type: i0.ViewContainerRef },
6464
+ { type: i0.ElementRef }
6465
+ ]; };
6405
6466
  PopoverComponent.propDecorators = {
6406
6467
  icon: [{ type: i0.Input }],
6407
- contentPosition: [{ type: i0.Input }]
6468
+ contentPosition: [{ type: i0.Input }],
6469
+ iconHoverClass: [{ type: i0.Input }],
6470
+ content: [{ type: i0.ViewChild, args: ['content',] }],
6471
+ show: [{ type: i0.HostListener, args: ['mouseover',] }]
6408
6472
  };
6409
6473
 
6410
6474
  var CopyButtonDirective = /** @class */ (function () {
@@ -8024,7 +8088,8 @@
8024
8088
  forms.ReactiveFormsModule,
8025
8089
  i1$1.RouterModule,
8026
8090
  i1.TranslateModule,
8027
- a11y.A11yModule
8091
+ a11y.A11yModule,
8092
+ overlay.OverlayModule
8028
8093
  ],
8029
8094
  providers: [
8030
8095
  FormGroupHelper,