@energycap/components 0.26.8 → 0.26.9-ECAPID-284-App-Bar-Error.20211220-1043

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
 
@@ -5390,10 +5390,74 @@
5390
5390
  textboxInput: [{ type: i0.ViewChild, args: ['textbox', { static: true },] }]
5391
5391
  };
5392
5392
 
5393
+ var AvatarService = /** @class */ (function () {
5394
+ function AvatarService() {
5395
+ }
5396
+ /**
5397
+ * Return the full and abbreviated labels based on the users first name, email, or username. If the user has a first or last name use
5398
+ * either a combination of the first and last name, or the first two characters of the name that is defined. If the user does
5399
+ * not have a first or last name, trying using the first two characters of the email, or the first two characters of the
5400
+ * username as a last ditch effort.
5401
+ * @param user
5402
+ * @returns
5403
+ */
5404
+ AvatarService.prototype.getAvatarLabels = function (user) {
5405
+ var full = undefined;
5406
+ var abbreviation = 'HI';
5407
+ var trimmedUser = this.trimUser(user);
5408
+ if (trimmedUser.firstName || trimmedUser.lastName) {
5409
+ if (trimmedUser.firstName) {
5410
+ abbreviation = trimmedUser.firstName.slice(0, 1);
5411
+ full = trimmedUser.firstName;
5412
+ if (trimmedUser.lastName) {
5413
+ full += " " + trimmedUser.lastName;
5414
+ }
5415
+ }
5416
+ else {
5417
+ abbreviation = trimmedUser.lastName.slice(0, 1);
5418
+ full = trimmedUser.lastName;
5419
+ }
5420
+ }
5421
+ else if (trimmedUser.email) {
5422
+ abbreviation = trimmedUser.email.slice(0, 1);
5423
+ full = trimmedUser.email;
5424
+ }
5425
+ else if (trimmedUser.username) {
5426
+ abbreviation = trimmedUser.username.slice(0, 1);
5427
+ full = trimmedUser.username;
5428
+ }
5429
+ return {
5430
+ abbreviation: abbreviation,
5431
+ full: full
5432
+ };
5433
+ };
5434
+ /**
5435
+ * Return a new user object that has all of the properties of the existing user
5436
+ * with any null, undefined, or whitespace values removed
5437
+ */
5438
+ AvatarService.prototype.trimUser = function (user) {
5439
+ var trimmedUser = {
5440
+ email: (user.email || '').trim(),
5441
+ firstName: (user.firstName || '').trim(),
5442
+ lastName: (user.lastName || '').trim(),
5443
+ username: (user.username || '').trim()
5444
+ };
5445
+ return trimmedUser;
5446
+ };
5447
+ return AvatarService;
5448
+ }());
5449
+ AvatarService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AvatarService_Factory() { return new AvatarService(); }, token: AvatarService, providedIn: "root" });
5450
+ AvatarService.decorators = [
5451
+ { type: i0.Injectable, args: [{
5452
+ providedIn: 'root'
5453
+ },] }
5454
+ ];
5455
+
5393
5456
  var AvatarComponent = /** @class */ (function () {
5394
- function AvatarComponent(el, renderer) {
5457
+ function AvatarComponent(el, renderer, avatarService) {
5395
5458
  this.el = el;
5396
5459
  this.renderer = renderer;
5460
+ this.avatarService = avatarService;
5397
5461
  /** Color map base on the first let of the label */
5398
5462
  this.colors = {
5399
5463
  abcde01: 'red',
@@ -5416,49 +5480,14 @@
5416
5480
  this.updateColor();
5417
5481
  };
5418
5482
  /**
5419
- * Update the Avatar label based on the users first name, email, or username. If the user has a first or last name use
5420
- * either a combination of the first and last name, or the first two characters of the name that is defined. If the user does
5421
- * not have a first or last name, trying using the first two characters of the email, or the first two characters of the
5422
- * username as a last ditch effort.
5483
+ * Update the Avatar label
5484
+ *
5423
5485
  */
5424
5486
  AvatarComponent.prototype.updateLabel = function () {
5425
5487
  if (this.user) {
5426
- var trimmedUser = this.trimUser(this.user);
5427
- if (trimmedUser.firstName || trimmedUser.lastName) {
5428
- if (trimmedUser.firstName) {
5429
- this.label = trimmedUser.firstName.slice(0, 1);
5430
- this.user.userMenuTitle = trimmedUser.firstName;
5431
- if (trimmedUser.lastName) {
5432
- this.user.userMenuTitle += " " + trimmedUser.lastName;
5433
- }
5434
- }
5435
- else {
5436
- this.label = trimmedUser.lastName.slice(0, 1);
5437
- this.user.userMenuTitle = trimmedUser.lastName;
5438
- }
5439
- }
5440
- else if (trimmedUser.email) {
5441
- this.label = trimmedUser.email.slice(0, 1);
5442
- this.user.userMenuTitle = trimmedUser.email;
5443
- }
5444
- else if (trimmedUser.username) {
5445
- this.label = trimmedUser.username.slice(0, 1);
5446
- this.user.userMenuTitle = trimmedUser.username;
5447
- }
5488
+ this.label = this.avatarService.getAvatarLabels(this.user).abbreviation;
5448
5489
  }
5449
5490
  };
5450
- /** Return a new user object that has all of the properties of the existing user
5451
- * with any null, undefined, or whitespace values removed
5452
- */
5453
- AvatarComponent.prototype.trimUser = function (user) {
5454
- var trimmedUser = {
5455
- email: (user.email || '').trim(),
5456
- firstName: (user.firstName || '').trim(),
5457
- lastName: (user.lastName || '').trim(),
5458
- username: (user.username || '').trim()
5459
- };
5460
- return trimmedUser;
5461
- };
5462
5491
  /**
5463
5492
  * Sets the color of the Avatar based on the first letter of the label. If the label is HI or is not
5464
5493
  * a letter, default to gray.
@@ -5489,14 +5518,16 @@
5489
5518
  ];
5490
5519
  AvatarComponent.ctorParameters = function () { return [
5491
5520
  { type: i0.ElementRef },
5492
- { type: i0.Renderer2 }
5521
+ { type: i0.Renderer2 },
5522
+ { type: AvatarService }
5493
5523
  ]; };
5494
5524
  AvatarComponent.propDecorators = {
5495
5525
  user: [{ type: i0.Input }]
5496
5526
  };
5497
5527
 
5498
5528
  var AppBarComponent = /** @class */ (function () {
5499
- function AppBarComponent() {
5529
+ function AppBarComponent(avatarService) {
5530
+ this.avatarService = avatarService;
5500
5531
  this.user = {};
5501
5532
  this.userMenuItems = [];
5502
5533
  this.userMenuWidth = 0;
@@ -5504,15 +5535,23 @@
5504
5535
  this.userMenuTabindex = 0;
5505
5536
  this.iconPath = '/assets/images/icon.svg';
5506
5537
  }
5538
+ AppBarComponent.prototype.ngOnChanges = function () {
5539
+ if (this.user) {
5540
+ this.userMenuTitle = this.avatarService.getAvatarLabels(this.user).full;
5541
+ }
5542
+ };
5507
5543
  return AppBarComponent;
5508
5544
  }());
5509
5545
  AppBarComponent.decorators = [
5510
5546
  { type: i0.Component, args: [{
5511
5547
  selector: 'ec-app-bar',
5512
- template: "<section class=\"logo-container\">\r\n <img src=\"{{iconPath}}\" alt=\"EnergyCAP Platform\">\r\n</section>\r\n\r\n<section class=\"title-container\">\r\n <ng-content select=\".app-bar-title\"></ng-content>\r\n</section>\r\n\r\n<section class=\"actions-container\">\r\n <ng-content select=\".app-bar-actions\"></ng-content>\r\n <ec-dropdown id=\"AppBarUserMenu\"\r\n *ngIf=\"userMenuItems.length; else avatar\"\r\n [menuTitle]=\"user?.userMenuTitle\"\r\n [items]=\"userMenuItems\"\r\n [buttonCustomTemplate]=\"avatar\"\r\n [showArrow]=\"false\"\r\n [menuWidth]=\"userMenuWidth\"\r\n [menuMinWidth]=\"userMenuMinWidth\"\r\n [tabindex]=\"userMenuTabindex\"></ec-dropdown>\r\n</section>\r\n\r\n<ng-template #avatar>\r\n <div class=\"p-1\">\r\n <ec-avatar [user]=\"user\"></ec-avatar>\r\n </div>\r\n</ng-template>",
5548
+ template: "<section class=\"logo-container\">\r\n <img src=\"{{iconPath}}\"\r\n alt=\"EnergyCAP Platform\">\r\n</section>\r\n\r\n<section class=\"title-container\">\r\n <ng-content select=\".app-bar-title\"></ng-content>\r\n</section>\r\n\r\n<section class=\"actions-container\">\r\n <ng-content select=\".app-bar-actions\"></ng-content>\r\n <ec-dropdown id=\"AppBarUserMenu\"\r\n *ngIf=\"userMenuItems.length; else avatar\"\r\n [menuTitle]=\"userMenuTitle\"\r\n [items]=\"userMenuItems\"\r\n [buttonCustomTemplate]=\"avatar\"\r\n [showArrow]=\"false\"\r\n [menuWidth]=\"userMenuWidth\"\r\n [menuMinWidth]=\"userMenuMinWidth\"\r\n [tabindex]=\"userMenuTabindex\"></ec-dropdown>\r\n</section>\r\n\r\n<ng-template #avatar>\r\n <div class=\"p-1\">\r\n <ec-avatar [user]=\"user\"></ec-avatar>\r\n </div>\r\n</ng-template>",
5513
5549
  styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{align-items:center;background-color:#fff;display:flex;height:3rem;padding:0 .75rem 0 1rem;position:relative;width:100%;z-index:40}:host ::ng-deep .app-bar-actions{align-items:center;display:flex;justify-content:flex-end;margin-right:.25rem}section{flex:1 1}.logo-container img{height:2rem;width:2rem}.title-container{text-align:center}.actions-container{display:flex;justify-content:flex-end}"]
5514
5550
  },] }
5515
5551
  ];
5552
+ AppBarComponent.ctorParameters = function () { return [
5553
+ { type: AvatarService }
5554
+ ]; };
5516
5555
  AppBarComponent.propDecorators = {
5517
5556
  user: [{ type: i0.Input }],
5518
5557
  userMenuItems: [{ type: i0.Input }],
@@ -6389,22 +6428,86 @@
6389
6428
  };
6390
6429
 
6391
6430
  var PopoverComponent = /** @class */ (function () {
6392
- function PopoverComponent() {
6431
+ function PopoverComponent(overlay, viewContainerRef, elementRef) {
6432
+ this.overlay = overlay;
6433
+ this.viewContainerRef = viewContainerRef;
6434
+ this.elementRef = elementRef;
6393
6435
  this.icon = '';
6394
6436
  this.contentPosition = 'top-left';
6437
+ this.iconHoverClass = '';
6438
+ this.isVisible = false;
6395
6439
  }
6440
+ PopoverComponent.prototype.ngOnDestroy = function () {
6441
+ this.hide();
6442
+ };
6443
+ PopoverComponent.prototype.show = function () {
6444
+ if (!this.isVisible) {
6445
+ var overlayConfig = this.getOverlayConfig();
6446
+ this.overlayRef = this.overlay.create(overlayConfig);
6447
+ var contentPortal = new portal.TemplatePortal(this.content, this.viewContainerRef);
6448
+ this.contentViewRef = this.overlayRef.attach(contentPortal);
6449
+ this.isVisible = true;
6450
+ }
6451
+ };
6452
+ /**
6453
+ * Hides the popover if the mouse moves outside of the popover content
6454
+ */
6455
+ PopoverComponent.prototype.onMouseMove = function (event) {
6456
+ var _a;
6457
+ if (!this.contentRect) {
6458
+ this.contentRect = (_a = this.contentViewRef) === null || _a === void 0 ? void 0 : _a.rootNodes[0].getBoundingClientRect();
6459
+ }
6460
+ if (this.contentRect) {
6461
+ if (event.clientX > this.contentRect.right
6462
+ || event.clientX < this.contentRect.left
6463
+ || event.clientY > this.contentRect.bottom
6464
+ || event.clientY < this.contentRect.top) {
6465
+ this.hide();
6466
+ }
6467
+ }
6468
+ };
6469
+ PopoverComponent.prototype.hide = function () {
6470
+ var _a;
6471
+ this.contentRect = undefined;
6472
+ (_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.dispose();
6473
+ this.isVisible = false;
6474
+ };
6475
+ PopoverComponent.prototype.getOverlayConfig = function () {
6476
+ var position = this.getPosition();
6477
+ var positionStrategy = this.overlay.position()
6478
+ .flexibleConnectedTo(this.elementRef)
6479
+ .withPositions([position]);
6480
+ var config = new overlay.OverlayConfig({
6481
+ positionStrategy: positionStrategy
6482
+ });
6483
+ return config;
6484
+ };
6485
+ PopoverComponent.prototype.getPosition = function () {
6486
+ var position = this.contentPosition.split('-');
6487
+ var overlayX = (position[1] == 'left' ? 'start' : 'end');
6488
+ var overlayY = position[0];
6489
+ return { originX: overlayX, originY: overlayY, overlayX: overlayX, overlayY: overlayY };
6490
+ };
6396
6491
  return PopoverComponent;
6397
6492
  }());
6398
6493
  PopoverComponent.decorators = [
6399
6494
  { type: i0.Component, args: [{
6400
6495
  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}"]
6496
+ 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",
6497
+ 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
6498
  },] }
6404
6499
  ];
6500
+ PopoverComponent.ctorParameters = function () { return [
6501
+ { type: overlay.Overlay },
6502
+ { type: i0.ViewContainerRef },
6503
+ { type: i0.ElementRef }
6504
+ ]; };
6405
6505
  PopoverComponent.propDecorators = {
6406
6506
  icon: [{ type: i0.Input }],
6407
- contentPosition: [{ type: i0.Input }]
6507
+ contentPosition: [{ type: i0.Input }],
6508
+ iconHoverClass: [{ type: i0.Input }],
6509
+ content: [{ type: i0.ViewChild, args: ['content',] }],
6510
+ show: [{ type: i0.HostListener, args: ['mouseover',] }]
6408
6511
  };
6409
6512
 
6410
6513
  var CopyButtonDirective = /** @class */ (function () {
@@ -8024,7 +8127,8 @@
8024
8127
  forms.ReactiveFormsModule,
8025
8128
  i1$1.RouterModule,
8026
8129
  i1.TranslateModule,
8027
- a11y.A11yModule
8130
+ a11y.A11yModule,
8131
+ overlay.OverlayModule
8028
8132
  ],
8029
8133
  providers: [
8030
8134
  FormGroupHelper,
@@ -8800,8 +8904,9 @@
8800
8904
  exports.validateFormGroupValuesAreUnique = validateFormGroupValuesAreUnique;
8801
8905
  exports.ɵa = ResizableTableDirective;
8802
8906
  exports.ɵb = ResizableBase;
8803
- exports.ɵc = TableDetailRowComponent;
8804
- exports.ɵd = TelemetryService;
8907
+ exports.ɵc = AvatarService;
8908
+ exports.ɵd = TableDetailRowComponent;
8909
+ exports.ɵe = TelemetryService;
8805
8910
 
8806
8911
  Object.defineProperty(exports, '__esModule', { value: true });
8807
8912