@seniorsistemas/angular-components 17.7.3 → 17.7.4

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.
Files changed (46) hide show
  1. package/bundles/seniorsistemas-angular-components.umd.js +327 -228
  2. package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-angular-components.umd.min.js +1 -1
  4. package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
  5. package/components/tiered-menu/components/tiered-menu/tiered-menu.component.d.ts +8 -4
  6. package/components/tiered-menu/components/tiered-menu-item/tiered-menu-item.component.d.ts +2 -1
  7. package/components/tiered-menu/components/tiered-menu-nested/tiered-menu-nested.component.d.ts +7 -4
  8. package/components/tiered-menu/models/tiered-menu-item-data.d.ts +2 -0
  9. package/components/tiered-menu/models/tiered-menu-item-internal-data.d.ts +2 -6
  10. package/components/tiered-menu/{tiered-menu.event.service.d.ts → services/tiered-menu.event.service.d.ts} +1 -8
  11. package/components/tiered-menu/services/tiered-menu.global.service.d.ts +4 -0
  12. package/components/tiered-menu/{tiered-menu.service.d.ts → services/tiered-menu.service.d.ts} +5 -3
  13. package/components/tiered-menu/tiered-menu.directive.d.ts +16 -14
  14. package/esm2015/components/tiered-menu/components/tiered-menu/tiered-menu.component.js +110 -51
  15. package/esm2015/components/tiered-menu/components/tiered-menu-item/tiered-menu-item.component.js +16 -8
  16. package/esm2015/components/tiered-menu/components/tiered-menu-nested/tiered-menu-nested.component.js +53 -9
  17. package/esm2015/components/tiered-menu/models/tiered-menu-item-data.js +1 -1
  18. package/esm2015/components/tiered-menu/models/tiered-menu-item-internal-data.js +1 -1
  19. package/esm2015/components/tiered-menu/services/tiered-menu.event.service.js +18 -0
  20. package/esm2015/components/tiered-menu/services/tiered-menu.global.service.js +9 -0
  21. package/esm2015/components/tiered-menu/services/tiered-menu.service.js +51 -0
  22. package/esm2015/components/tiered-menu/tiered-menu.directive.js +103 -109
  23. package/esm2015/components/tiered-menu/tiered-menu.module.js +8 -12
  24. package/esm2015/seniorsistemas-angular-components.js +18 -17
  25. package/esm5/components/tiered-menu/components/tiered-menu/tiered-menu.component.js +110 -51
  26. package/esm5/components/tiered-menu/components/tiered-menu-item/tiered-menu-item.component.js +16 -8
  27. package/esm5/components/tiered-menu/components/tiered-menu-nested/tiered-menu-nested.component.js +53 -9
  28. package/esm5/components/tiered-menu/models/tiered-menu-item-data.js +1 -1
  29. package/esm5/components/tiered-menu/models/tiered-menu-item-internal-data.js +1 -1
  30. package/esm5/components/tiered-menu/services/tiered-menu.event.service.js +19 -0
  31. package/esm5/components/tiered-menu/services/tiered-menu.global.service.js +12 -0
  32. package/esm5/components/tiered-menu/services/tiered-menu.service.js +54 -0
  33. package/esm5/components/tiered-menu/tiered-menu.directive.js +103 -110
  34. package/esm5/components/tiered-menu/tiered-menu.module.js +8 -12
  35. package/esm5/seniorsistemas-angular-components.js +18 -17
  36. package/fesm2015/seniorsistemas-angular-components.js +309 -211
  37. package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
  38. package/fesm5/seniorsistemas-angular-components.js +313 -215
  39. package/fesm5/seniorsistemas-angular-components.js.map +1 -1
  40. package/package.json +1 -1
  41. package/seniorsistemas-angular-components.d.ts +17 -16
  42. package/seniorsistemas-angular-components.metadata.json +1 -1
  43. package/esm2015/components/tiered-menu/tiered-menu.event.service.js +0 -39
  44. package/esm2015/components/tiered-menu/tiered-menu.service.js +0 -39
  45. package/esm5/components/tiered-menu/tiered-menu.event.service.js +0 -40
  46. package/esm5/components/tiered-menu/tiered-menu.service.js +0 -44
@@ -16119,27 +16119,6 @@
16119
16119
  this.closeItemMenuEvent = new core.EventEmitter();
16120
16120
  this.createMenuEvent = new core.EventEmitter();
16121
16121
  }
16122
- TieredMenuEventService.prototype.emitIncrementCurrentItemEvent = function () {
16123
- this.incrementCurrentItemEvent.emit();
16124
- };
16125
- TieredMenuEventService.prototype.emitDecrementCurrentItemEvent = function () {
16126
- this.decrementCurrentItemEvent.emit();
16127
- };
16128
- TieredMenuEventService.prototype.emitCloseAllMenusEvent = function () {
16129
- this.closeAllMenusEvent.emit();
16130
- };
16131
- TieredMenuEventService.prototype.emitSelectItemEvent = function (item) {
16132
- this.selectItemEvent.emit(item);
16133
- };
16134
- TieredMenuEventService.prototype.emitOpenItemMenuEvent = function (item) {
16135
- this.openItemMenuEvent.emit(item);
16136
- };
16137
- TieredMenuEventService.prototype.emitCloseItemMenuEvent = function (item) {
16138
- this.closeItemMenuEvent.emit(item);
16139
- };
16140
- TieredMenuEventService.prototype.emitCreateMenuEvent = function (item) {
16141
- this.createMenuEvent.emit(item);
16142
- };
16143
16122
  TieredMenuEventService = __decorate([
16144
16123
  core.Injectable()
16145
16124
  ], TieredMenuEventService);
@@ -16148,22 +16127,26 @@
16148
16127
 
16149
16128
  var TieredMenuService = /** @class */ (function () {
16150
16129
  function TieredMenuService() {
16130
+ this.currentItems = [];
16131
+ this.items = [];
16151
16132
  }
16152
16133
  TieredMenuService.prototype.normalizeData = function (items, parent) {
16153
16134
  var _this = this;
16154
16135
  return items.map(function (i) {
16155
- if (i.submenu) {
16156
- i.submenu = _this.normalizeData(i.submenu, i);
16136
+ var item = __assign({}, i);
16137
+ if (item.submenu) {
16138
+ item.submenu = _this.normalizeData(item.submenu, item);
16157
16139
  }
16158
- i.id = "id-" + Math.random().toString(36).substring(2, 9) + "-" + Date.now().toString(36);
16159
- i.parent = parent;
16160
- i.isOpen = false;
16161
- return i;
16140
+ item.id = _this._generateId();
16141
+ item.parent = parent;
16142
+ item.isOpen = false;
16143
+ return item;
16162
16144
  });
16163
16145
  };
16164
16146
  TieredMenuService.prototype.markAllItemsAsClosed = function (items) {
16165
16147
  var _this = this;
16166
- return items.map(function (item) {
16148
+ return items.map(function (i) {
16149
+ var item = __assign({}, i);
16167
16150
  if (item.submenu) {
16168
16151
  item.submenu = _this.markAllItemsAsClosed(item.submenu);
16169
16152
  }
@@ -16171,16 +16154,22 @@
16171
16154
  return item;
16172
16155
  });
16173
16156
  };
16174
- TieredMenuService.prototype.searchTheHierarchy = function (item1, item2) {
16175
- var itemAux = item2;
16176
- while (itemAux) {
16177
- if (itemAux === item1) {
16157
+ TieredMenuService.prototype.searchTheHierarchy = function (itemA, itemB) {
16158
+ var item = itemB;
16159
+ while (item) {
16160
+ if (item === itemA) {
16178
16161
  return true;
16179
16162
  }
16180
- itemAux = itemAux.parent;
16163
+ item = item.parent;
16181
16164
  }
16182
16165
  return false;
16183
16166
  };
16167
+ TieredMenuService.prototype.cloneItems = function (items) {
16168
+ return JSON.parse(JSON.stringify(items));
16169
+ };
16170
+ TieredMenuService.prototype._generateId = function () {
16171
+ return "id-" + Math.random().toString(36).substring(2, 9) + "-" + Math.random().toString(36).substring(2, 9) + "-" + Math.random().toString(36).substring(2, 9);
16172
+ };
16184
16173
  TieredMenuService = __decorate([
16185
16174
  core.Injectable()
16186
16175
  ], TieredMenuService);
@@ -16192,9 +16181,44 @@
16192
16181
  this.tieredMenuService = tieredMenuService;
16193
16182
  this._tieredMenuEventService = _tieredMenuEventService;
16194
16183
  this.top = 0;
16195
- this.maxHeight = 0;
16184
+ this.left = 0;
16196
16185
  this._unsubscribe$ = new rxjs.Subject();
16197
16186
  }
16187
+ TieredMenuNestedComponent.prototype.onResize = function () {
16188
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16189
+ };
16190
+ TieredMenuNestedComponent.prototype.onDocumentClick = function (event) {
16191
+ // Closing menu when clicked outside.
16192
+ var target = event.target;
16193
+ var clickedInside = target.closest("s-tiered-menu-item") || target.closest("s-tiered-menu-divider");
16194
+ if (!clickedInside) {
16195
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16196
+ }
16197
+ };
16198
+ TieredMenuNestedComponent.prototype.onKeydownHandler = function (event) {
16199
+ switch (event.key) {
16200
+ case "Escape":
16201
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16202
+ break;
16203
+ case " ":
16204
+ case "Enter":
16205
+ this._tieredMenuEventService.selectItemEvent.emit(this.tieredMenuService.currentItem);
16206
+ break;
16207
+ case "ArrowLeft":
16208
+ // When nested I need a reference to the current item's parent item, otherwise just the current item.
16209
+ this._tieredMenuEventService.closeItemMenuEvent.emit(this.tieredMenuService.currentItem.parent);
16210
+ break;
16211
+ case "ArrowRight":
16212
+ this._tieredMenuEventService.openItemMenuEvent.emit(this.tieredMenuService.currentItem);
16213
+ break;
16214
+ case "ArrowUp":
16215
+ this._tieredMenuEventService.decrementCurrentItemEvent.emit();
16216
+ break;
16217
+ case "ArrowDown":
16218
+ this._tieredMenuEventService.incrementCurrentItemEvent.emit();
16219
+ break;
16220
+ }
16221
+ };
16198
16222
  TieredMenuNestedComponent.prototype.ngOnInit = function () {
16199
16223
  this.tieredMenuService.currentItems = this.items;
16200
16224
  this._subscribeEvents();
@@ -16275,7 +16299,7 @@
16275
16299
  if (item.command) {
16276
16300
  item.command();
16277
16301
  // Close all menus after the item was selected.
16278
- _this._tieredMenuEventService.emitCloseAllMenusEvent();
16302
+ _this._tieredMenuEventService.closeAllMenusEvent.emit();
16279
16303
  }
16280
16304
  });
16281
16305
  this._tieredMenuEventService.openItemMenuEvent
@@ -16287,7 +16311,7 @@
16287
16311
  while ((_a = itemAux === null || itemAux === void 0 ? void 0 : itemAux.parent) === null || _a === void 0 ? void 0 : _a.parent) {
16288
16312
  itemAux = itemAux.parent;
16289
16313
  }
16290
- _this._tieredMenuEventService.emitCloseItemMenuEvent((_b = itemAux.parent) !== null && _b !== void 0 ? _b : itemAux);
16314
+ _this._tieredMenuEventService.closeItemMenuEvent.emit((_b = itemAux.parent) !== null && _b !== void 0 ? _b : itemAux);
16291
16315
  }
16292
16316
  _this._lastOpenItem = item;
16293
16317
  _this._openItem(item);
@@ -16304,20 +16328,30 @@
16304
16328
  { type: TieredMenuService },
16305
16329
  { type: TieredMenuEventService }
16306
16330
  ]; };
16331
+ __decorate([
16332
+ core.HostListener("window:resize")
16333
+ ], TieredMenuNestedComponent.prototype, "onResize", null);
16334
+ __decorate([
16335
+ core.HostListener("document:click", ["$event"])
16336
+ ], TieredMenuNestedComponent.prototype, "onDocumentClick", null);
16337
+ __decorate([
16338
+ core.HostListener("document:keydown", ["$event"])
16339
+ ], TieredMenuNestedComponent.prototype, "onKeydownHandler", null);
16307
16340
  TieredMenuNestedComponent = __decorate([
16308
16341
  core.Component({
16309
- template: "<div\n class=\"menu menu--nested\"\n [ngStyle]=\"{\n 'top': top + 'px',\n 'max-height': maxHeight + 'px'\n }\">\n <ng-container *ngTemplateOutlet=\"itemsTemplate; context: { $implicit: items }\"></ng-container>\n</div>\n\n<ng-template #itemsTemplate let-items>\n <div *ngFor=\"let item of items\">\n <s-tiered-menu-item\n *ngIf=\"!item.divider\"\n [item]=\"item\"\n [focused]=\"item === tieredMenuService.currentItem\"\n [closeOnClick]=\"true\">\n </s-tiered-menu-item>\n\n <s-tiered-menu-divider *ngIf=\"item.divider\"></s-tiered-menu-divider>\n\n <div *ngIf=\"item.submenu && item.isOpen\">\n <div class=\"submenu\">\n <ng-container *ngTemplateOutlet=\"itemsTemplate; context: { $implicit: item.submenu }\"></ng-container>\n </div>\n </div>\n </div>\n</ng-template>\n",
16310
- styles: [".menu{background-color:#fff;border:1px solid #ccc;border-radius:6px;box-shadow:0 2px 12px 0 rgba(0,0,0,.1);display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;min-width:176px;padding:4px 0;position:fixed;z-index:9999;overflow:auto}.menu--nested{width:90vw;margin:0 5vw}.menu .submenu{margin-left:24px}"]
16342
+ template: "<div\n class=\"menu menu--nested\"\n [ngStyle]=\"{\n 'top': top + 'px',\n 'left': left + 'px'\n }\">\n <ng-container *ngTemplateOutlet=\"itemsTemplate; context: { $implicit: items }\"></ng-container>\n</div>\n\n<ng-template #itemsTemplate let-items>\n <div *ngFor=\"let item of items\">\n <s-tiered-menu-item\n *ngIf=\"!item.divider\"\n [item]=\"item\"\n [focused]=\"item === tieredMenuService.currentItem\"\n [closeOnClick]=\"true\">\n </s-tiered-menu-item>\n\n <s-tiered-menu-divider *ngIf=\"item.divider\"></s-tiered-menu-divider>\n\n <div *ngIf=\"item.submenu && item.isOpen\">\n <div class=\"submenu\">\n <ng-container *ngTemplateOutlet=\"itemsTemplate; context: { $implicit: item.submenu }\"></ng-container>\n </div>\n </div>\n </div>\n</ng-template>\n",
16343
+ styles: [".menu{background-color:#fff;border:1px solid #ccc;border-radius:6px;box-shadow:0 2px 12px 0 rgba(0,0,0,.1);display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;min-width:176px;padding:4px 0;position:absolute;z-index:9999;overflow:auto;width:calc(100vw - 8px)}.menu .submenu{margin-left:24px}"]
16311
16344
  })
16312
16345
  ], TieredMenuNestedComponent);
16313
16346
  return TieredMenuNestedComponent;
16314
16347
  }());
16315
16348
 
16316
16349
  var TieredMenuComponent = /** @class */ (function () {
16317
- function TieredMenuComponent(_appRef, _componentFactoryResolver, _injector, tieredMenuService, _tieredMenuEventService) {
16350
+ function TieredMenuComponent(_appRef, _componentFactoryResolver, _injector, _changeDetectorRef, tieredMenuService, _tieredMenuEventService) {
16318
16351
  this._appRef = _appRef;
16319
16352
  this._componentFactoryResolver = _componentFactoryResolver;
16320
16353
  this._injector = _injector;
16354
+ this._changeDetectorRef = _changeDetectorRef;
16321
16355
  this.tieredMenuService = tieredMenuService;
16322
16356
  this._tieredMenuEventService = _tieredMenuEventService;
16323
16357
  this.top = 0;
@@ -16328,6 +16362,54 @@
16328
16362
  this.destroyRequest = new core.EventEmitter();
16329
16363
  }
16330
16364
  TieredMenuComponent_1 = TieredMenuComponent;
16365
+ TieredMenuComponent.prototype.onResize = function () {
16366
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16367
+ };
16368
+ TieredMenuComponent.prototype.onDocumentClick = function (event) {
16369
+ // Closing menu when clicked outside.
16370
+ var target = event.target;
16371
+ var clickedInside = target.closest("s-tiered-menu-item") || target.closest("s-tiered-menu-divider");
16372
+ if (!clickedInside) {
16373
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16374
+ }
16375
+ };
16376
+ TieredMenuComponent.prototype.onKeydownHandler = function (event) {
16377
+ switch (event.key) {
16378
+ case "Escape":
16379
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16380
+ break;
16381
+ case " ":
16382
+ case "Enter":
16383
+ if (!this.tieredMenuService.currentItem.disabled) {
16384
+ this._tieredMenuEventService.selectItemEvent.emit(this.tieredMenuService.currentItem);
16385
+ }
16386
+ break;
16387
+ case "ArrowLeft":
16388
+ if (this.items.includes(this.tieredMenuService.currentItem)) {
16389
+ this._tieredMenuEventService.closeItemMenuEvent.emit(this.tieredMenuService.currentItem);
16390
+ this._changeDetectorRef.detectChanges();
16391
+ }
16392
+ break;
16393
+ case "ArrowRight":
16394
+ if (!this.tieredMenuService.currentItem.disabled && this.items.includes(this.tieredMenuService.currentItem)) {
16395
+ this._tieredMenuEventService.openItemMenuEvent.emit(this.tieredMenuService.currentItem);
16396
+ event.stopImmediatePropagation();
16397
+ }
16398
+ break;
16399
+ case "ArrowUp":
16400
+ if (!this.tieredMenuService.currentItem || this.items.includes(this.tieredMenuService.currentItem)) {
16401
+ this._tieredMenuEventService.decrementCurrentItemEvent.emit();
16402
+ event.stopImmediatePropagation();
16403
+ }
16404
+ break;
16405
+ case "ArrowDown":
16406
+ if (!this.tieredMenuService.currentItem || this.items.includes(this.tieredMenuService.currentItem)) {
16407
+ this._tieredMenuEventService.incrementCurrentItemEvent.emit();
16408
+ event.stopImmediatePropagation();
16409
+ }
16410
+ break;
16411
+ }
16412
+ };
16331
16413
  TieredMenuComponent.prototype.ngOnInit = function () {
16332
16414
  this.tieredMenuService.currentItems = this.items;
16333
16415
  this._subscribeEvents();
@@ -16387,8 +16469,7 @@
16387
16469
  // Setting the menu items.
16388
16470
  this._componentRef.instance.items = items;
16389
16471
  // Subscribe menu events.
16390
- this._componentRef.instance.destroyRequest
16391
- .subscribe(function (propagate) {
16472
+ this._componentRef.instance.destroyRequest.subscribe(function (propagate) {
16392
16473
  _this._destroy(propagate);
16393
16474
  });
16394
16475
  this._menuDivElement = domElem.querySelector(".menu");
@@ -16408,14 +16489,23 @@
16408
16489
  }
16409
16490
  };
16410
16491
  TieredMenuComponent.prototype._setMenuPosition = function (position) {
16411
- var _a;
16492
+ var _a, _b;
16493
+ var ITEM_HEIGHT = 37;
16494
+ var DIVIDER_HEIGHT = 5;
16495
+ var PADDING = 8;
16412
16496
  if (this._componentRef !== null) {
16413
16497
  var top_1 = position.top, right = position.right, bottom = position.bottom, left = position.left;
16498
+ var itemsCount = (_a = this._componentRef.instance.items) === null || _a === void 0 ? void 0 : _a.reduce(function (count, item) {
16499
+ return !item.divider ? count + 1 : count;
16500
+ }, 0);
16501
+ var dividersCount = (_b = this._componentRef.instance.items) === null || _b === void 0 ? void 0 : _b.reduce(function (count, item) {
16502
+ return item.divider ? count + 1 : count;
16503
+ }, 0);
16414
16504
  // I need to calculate the height of the component because the internal elements have not been created yet.
16415
- var menuHeight = ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) * 40;
16505
+ var menuHeight = itemsCount * ITEM_HEIGHT + dividersCount * DIVIDER_HEIGHT + PADDING + 8;
16416
16506
  var menuWidth = this._menuDivElement.getBoundingClientRect().width;
16417
- var rightFreeSpace = document.body.clientWidth - right;
16418
- var bottomFreeSpace = document.body.clientHeight - bottom;
16507
+ var rightFreeSpace = window.innerWidth - right;
16508
+ var bottomFreeSpace = window.innerHeight - bottom;
16419
16509
  if (rightFreeSpace > menuWidth) {
16420
16510
  this._componentRef.instance.left = right;
16421
16511
  }
@@ -16423,85 +16513,77 @@
16423
16513
  this._componentRef.instance.left = left - menuWidth;
16424
16514
  }
16425
16515
  if (bottomFreeSpace <= menuHeight) {
16426
- this._componentRef.instance.top = top_1 - menuHeight;
16516
+ this._componentRef.instance.top = Math.max(window.innerHeight - menuHeight, window.scrollY);
16427
16517
  }
16428
16518
  else {
16429
- this._componentRef.instance.top = top_1;
16519
+ this._componentRef.instance.top = window.scrollY + top_1;
16430
16520
  }
16431
16521
  }
16432
16522
  };
16433
16523
  TieredMenuComponent.prototype._subscribeEvents = function () {
16434
16524
  var _this = this;
16435
16525
  // Increment current item event.
16436
- this._tieredMenuEventService.incrementCurrentItemEvent
16437
- .pipe(operators.takeUntil(this._unsubscribe$))
16438
- .subscribe(function () {
16526
+ this._tieredMenuEventService.incrementCurrentItemEvent.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function () {
16439
16527
  _this._incrementCurItem();
16440
16528
  });
16441
16529
  // Decrement current item event.
16442
- this._tieredMenuEventService.decrementCurrentItemEvent
16443
- .pipe(operators.takeUntil(this._unsubscribe$))
16444
- .subscribe(function () {
16530
+ this._tieredMenuEventService.decrementCurrentItemEvent.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function () {
16445
16531
  _this._decrementCurItem();
16446
16532
  });
16447
16533
  // Select item event.
16448
- this._tieredMenuEventService.selectItemEvent
16449
- .pipe(operators.takeUntil(this._unsubscribe$))
16450
- .subscribe(function (item) {
16534
+ this._tieredMenuEventService.selectItemEvent.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function (item) {
16451
16535
  if (item.submenu) {
16452
- _this._tieredMenuEventService.emitOpenItemMenuEvent(item);
16536
+ _this._tieredMenuEventService.openItemMenuEvent.emit(item);
16453
16537
  }
16454
16538
  else if (item.command) {
16455
- _this._tieredMenuEventService.emitCloseAllMenusEvent();
16539
+ _this._tieredMenuEventService.closeAllMenusEvent.emit();
16456
16540
  item.command();
16457
16541
  }
16458
16542
  });
16459
16543
  // Close all menus event.
16460
- this._tieredMenuEventService.closeAllMenusEvent
16461
- .pipe(operators.takeUntil(this._unsubscribe$))
16462
- .subscribe(function () {
16544
+ this._tieredMenuEventService.closeAllMenusEvent.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function () {
16463
16545
  _this._destroy();
16464
16546
  _this.tieredMenuService.currentItem = null;
16465
16547
  _this.tieredMenuService.currentItems = _this.tieredMenuService.items;
16548
+ _this.tieredMenuService.markAllItemsAsClosed(_this.tieredMenuService.items);
16466
16549
  });
16467
16550
  // Open item menu event.
16468
- this._tieredMenuEventService.openItemMenuEvent
16469
- .pipe(operators.takeUntil(this._unsubscribe$))
16470
- .subscribe(function (item) {
16471
- item.isOpen = false;
16551
+ this._tieredMenuEventService.openItemMenuEvent.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function (item) {
16472
16552
  if (_this.tieredMenuService.currentItem) {
16473
16553
  if (_this.tieredMenuService.currentItem.parent === item) {
16474
16554
  return;
16475
16555
  }
16476
16556
  if (!_this.tieredMenuService.searchTheHierarchy(_this.tieredMenuService.currentItem.parent, item)) {
16477
- var itemAux = _this.tieredMenuService.currentItem;
16478
- while (itemAux.parent !== item.parent) {
16479
- _this._tieredMenuEventService.emitCloseItemMenuEvent(itemAux);
16480
- itemAux = itemAux.parent;
16557
+ var current = _this.tieredMenuService.currentItem;
16558
+ current.isOpen = false;
16559
+ while ((current === null || current === void 0 ? void 0 : current.parent) !== item.parent) {
16560
+ _this._tieredMenuEventService.closeItemMenuEvent.emit(current);
16561
+ _this._changeDetectorRef.detectChanges();
16562
+ current = current.parent;
16481
16563
  }
16482
- }
16483
- }
16484
- if (item.submenu) {
16485
- if (!item.isOpen) {
16486
- var _a = document
16487
- .querySelector("#" + item.id)
16488
- .getBoundingClientRect(), top_2 = _a.top, right = _a.right, left = _a.left, bottom = _a.bottom;
16489
- var position = { top: top_2, right: right, left: left, bottom: bottom };
16490
- if (_this.items.includes(item)) {
16491
- _this._createMenu(item.submenu, position);
16492
- _this.tieredMenuService.currentItems = item.submenu;
16493
- _this.tieredMenuService.currentItem = item.submenu[0];
16564
+ if (current) {
16565
+ current.isOpen = false;
16494
16566
  }
16495
16567
  }
16496
16568
  }
16569
+ if (item.submenu && !item.isOpen && _this.items.includes(item)) {
16570
+ var _a = document.querySelector("#" + item.id).getBoundingClientRect(), top_2 = _a.top, right = _a.right, left = _a.left, bottom = _a.bottom;
16571
+ var position = { top: top_2, right: right, left: left, bottom: bottom };
16572
+ _this._createMenu(item.submenu, position);
16573
+ _this.tieredMenuService.currentItems = item.submenu;
16574
+ _this.tieredMenuService.currentItem = item.submenu[0];
16575
+ item.isOpen = true;
16576
+ }
16497
16577
  });
16498
16578
  // Close item menu event.
16499
16579
  this._tieredMenuEventService.closeItemMenuEvent
16500
16580
  .pipe(operators.takeUntil(this._unsubscribe$))
16501
16581
  .subscribe(function (item) {
16502
16582
  var _a, _b;
16503
- if (_this.items.includes(item)) {
16504
- item.isOpen = false;
16583
+ if (_this.items.some(function (i) { return i.id === item.id; })) {
16584
+ if (item.parent) {
16585
+ item.parent.isOpen = false;
16586
+ }
16505
16587
  _this.tieredMenuService.currentItems = ((_b = (_a = item === null || item === void 0 ? void 0 : item.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.submenu) || _this.tieredMenuService.items;
16506
16588
  _this.tieredMenuService.currentItem = item.parent;
16507
16589
  _this.destroyRequest.emit(false);
@@ -16513,108 +16595,106 @@
16513
16595
  { type: core.ApplicationRef },
16514
16596
  { type: core.ComponentFactoryResolver },
16515
16597
  { type: core.Injector },
16598
+ { type: core.ChangeDetectorRef },
16516
16599
  { type: TieredMenuService },
16517
16600
  { type: TieredMenuEventService }
16518
16601
  ]; };
16519
16602
  __decorate([
16520
16603
  core.Output()
16521
16604
  ], TieredMenuComponent.prototype, "destroyRequest", void 0);
16605
+ __decorate([
16606
+ core.HostListener("window:resize")
16607
+ ], TieredMenuComponent.prototype, "onResize", null);
16608
+ __decorate([
16609
+ core.HostListener("document:click", ["$event"])
16610
+ ], TieredMenuComponent.prototype, "onDocumentClick", null);
16611
+ __decorate([
16612
+ core.HostListener("document:keydown", ["$event"])
16613
+ ], TieredMenuComponent.prototype, "onKeydownHandler", null);
16522
16614
  TieredMenuComponent = TieredMenuComponent_1 = __decorate([
16523
16615
  core.Component({
16524
16616
  selector: "s-tiered-menu",
16525
- template: "<div class=\"menu\" [ngStyle]=\"{\n 'left': left + 'px',\n 'top': top + 'px'\n }\">\n\n <div *ngFor=\"let item of items\">\n <s-tiered-menu-item\n *ngIf=\"!item.divider\"\n [item]=\"item\"\n [focused]=\"item === tieredMenuService.currentItem\"\n triggerEvent=\"hover\"\n [closeOnClick]=\"false\">\n </s-tiered-menu-item>\n <s-tiered-menu-divider *ngIf=\"item.divider\"></s-tiered-menu-divider>\n </div>\n</div>",
16526
- styles: [".menu{background-color:#fff;border:1px solid #ccc;border-radius:6px;box-shadow:0 2px 12px 0 rgba(0,0,0,.1);display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;min-width:176px;padding:4px 0;position:fixed;z-index:9999}"]
16617
+ template: "<div\n class=\"menu\"\n [ngStyle]=\"{\n 'left': left + 'px',\n 'top': top + 'px'\n }\">\n\n <div *ngFor=\"let item of items\">\n <s-tiered-menu-item\n *ngIf=\"!item.divider\"\n [item]=\"item\"\n [focused]=\"item === tieredMenuService.currentItem\"\n [highlight]=\"item.isOpen\"\n triggerEvent=\"hover\"\n [closeOnClick]=\"false\">\n </s-tiered-menu-item>\n <s-tiered-menu-divider *ngIf=\"item.divider\"></s-tiered-menu-divider>\n </div>\n</div>",
16618
+ styles: [".menu{background-color:#fff;border:1px solid #ccc;border-radius:6px;box-shadow:0 2px 12px 0 rgba(0,0,0,.1);display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;max-height:100vh;min-width:176px;padding:4px 0;overflow-y:auto;position:absolute;z-index:9999}"]
16527
16619
  })
16528
16620
  ], TieredMenuComponent);
16529
16621
  return TieredMenuComponent;
16530
16622
  }());
16531
16623
 
16624
+ var TieredMenuGlobalService = /** @class */ (function () {
16625
+ function TieredMenuGlobalService() {
16626
+ }
16627
+ TieredMenuGlobalService = __decorate([
16628
+ core.Injectable()
16629
+ ], TieredMenuGlobalService);
16630
+ return TieredMenuGlobalService;
16631
+ }());
16632
+
16532
16633
  var TieredMenuDirective = /** @class */ (function () {
16533
- function TieredMenuDirective(_elementRef, _appRef, _componentFactoryResolver, _injector, _tieredMenuEventService, _tieredMenuService) {
16634
+ function TieredMenuDirective(_elementRef, _appRef, _componentFactoryResolver, _injector, _tieredMenuEventService, _tieredMenuService, _tieredMenuGlobalService, _changeDetectorRef) {
16534
16635
  this._elementRef = _elementRef;
16535
16636
  this._appRef = _appRef;
16536
16637
  this._componentFactoryResolver = _componentFactoryResolver;
16537
16638
  this._injector = _injector;
16538
16639
  this._tieredMenuEventService = _tieredMenuEventService;
16539
16640
  this._tieredMenuService = _tieredMenuService;
16641
+ this._tieredMenuGlobalService = _tieredMenuGlobalService;
16642
+ this._changeDetectorRef = _changeDetectorRef;
16643
+ this.items = [];
16644
+ this.triggerEvent = "click";
16540
16645
  this._componentRef = null;
16541
16646
  this._isNested = false;
16542
16647
  this._isOpen = false;
16543
16648
  this._unsubscribe$ = new rxjs.Subject();
16544
- this.alwaysOpen = false;
16545
- this.triggerEvent = "click";
16546
16649
  }
16650
+ TieredMenuDirective.prototype.onClick = function (event) {
16651
+ var _a;
16652
+ if (this.triggerEvent === "click" && ((_a = this._tieredMenuService.items) === null || _a === void 0 ? void 0 : _a.length) > 0 && !this._isOpen) {
16653
+ this._lastActiveElement = document.activeElement;
16654
+ this._createMenu();
16655
+ event.preventDefault();
16656
+ event.stopPropagation();
16657
+ }
16658
+ };
16547
16659
  TieredMenuDirective.prototype.ngOnInit = function () {
16548
- this._tieredMenuService.items = this._tieredMenuService.normalizeData(this.items);
16549
- this._tieredMenuService.currentItems = this._tieredMenuService.items;
16550
- this._tieredMenuService.currentItem = this._tieredMenuService.items[0];
16660
+ this._updateServiceItems();
16551
16661
  this._subscribeEvents();
16552
16662
  };
16553
- TieredMenuDirective.prototype.ngAfterViewInit = function () {
16554
- var _this = this;
16555
- // setTimeout to create the menu after creating the elements.
16556
- if (this.alwaysOpen) {
16557
- setTimeout(function () {
16558
- _this._createMenu();
16559
- }, 0);
16663
+ TieredMenuDirective.prototype.ngDoCheck = function () {
16664
+ if (!this.previousItems) {
16665
+ this.previousItems = this._tieredMenuService.cloneItems(this.items);
16666
+ }
16667
+ ;
16668
+ var hasChanges = false;
16669
+ if (this.items.length !== this.previousItems.length) {
16670
+ hasChanges = true;
16560
16671
  }
16672
+ else {
16673
+ for (var i = 0; i < this.items.length; i++) {
16674
+ if (!this._compareItems(this.items[i], this.previousItems[i])) {
16675
+ hasChanges = true;
16676
+ break;
16677
+ }
16678
+ }
16679
+ }
16680
+ if (hasChanges) {
16681
+ this._updateServiceItems();
16682
+ this._changeDetectorRef.detectChanges();
16683
+ this._rebuildMenu();
16684
+ }
16685
+ this.previousItems = this._tieredMenuService.cloneItems(this.items);
16561
16686
  };
16562
16687
  TieredMenuDirective.prototype.ngOnDestroy = function () {
16563
16688
  this._unsubscribe$.next();
16564
16689
  this._unsubscribe$.complete();
16565
16690
  this._destroy();
16566
16691
  };
16567
- TieredMenuDirective.prototype.onResize = function () {
16568
- if (!this.alwaysOpen) {
16569
- this._tieredMenuEventService.emitCloseAllMenusEvent();
16570
- }
16571
- };
16572
- TieredMenuDirective.prototype.onKeydownHandler = function (event) {
16573
- if (!this._isOpen)
16574
- return;
16575
- switch (event.key) {
16576
- case "Escape":
16577
- this._tieredMenuEventService.emitCloseAllMenusEvent();
16578
- break;
16579
- case " ":
16580
- case "Enter":
16581
- this._tieredMenuEventService.emitSelectItemEvent(this._tieredMenuService.currentItem);
16582
- break;
16583
- case "ArrowLeft":
16584
- // When nested I need a reference to the current item's parent item, otherwise just the current item.
16585
- this._tieredMenuEventService.emitCloseItemMenuEvent(this._isNested ? this._tieredMenuService.currentItem.parent : this._tieredMenuService.currentItem);
16586
- break;
16587
- case "ArrowRight":
16588
- this._tieredMenuEventService.emitOpenItemMenuEvent(this._tieredMenuService.currentItem);
16589
- break;
16590
- case "ArrowUp":
16591
- this._tieredMenuEventService.emitDecrementCurrentItemEvent();
16592
- break;
16593
- case "ArrowDown":
16594
- this._tieredMenuEventService.emitIncrementCurrentItemEvent();
16595
- break;
16596
- }
16597
- };
16598
- TieredMenuDirective.prototype.onClick = function (event) {
16599
- if (this.triggerEvent === "click" && this.items && this.items && !this._isOpen) {
16600
- this._lastActiveElement = document.activeElement;
16601
- this._createMenu();
16602
- event.preventDefault();
16603
- event.stopPropagation();
16604
- }
16605
- };
16606
- TieredMenuDirective.prototype.onDocumentClick = function (event) {
16607
- // Closing menu when clicked outside.
16608
- var target = event.target;
16609
- var clickedInside = target.closest("s-tiered-menu-item") || target.closest("s-tiered-menu-divider");
16610
- if (!clickedInside) {
16611
- this._tieredMenuEventService.emitCloseAllMenusEvent();
16612
- }
16613
- };
16614
16692
  TieredMenuDirective.prototype._createMenu = function () {
16615
- var _a;
16616
- if (!this._componentRef && this.items) {
16617
- (_a = this._lastActiveElement) === null || _a === void 0 ? void 0 : _a.blur();
16693
+ var _a, _b, _c;
16694
+ if (!this._componentRef && ((_a = this._tieredMenuService.items) === null || _a === void 0 ? void 0 : _a.length) > 0) {
16695
+ (_b = this._tieredMenuGlobalService.lastInstance) === null || _b === void 0 ? void 0 : _b._destroy();
16696
+ this._tieredMenuGlobalService.lastInstance = this;
16697
+ (_c = this._lastActiveElement) === null || _c === void 0 ? void 0 : _c.blur();
16618
16698
  this._isOpen = true;
16619
16699
  this._isNested = document.body.clientWidth < 600;
16620
16700
  this._isNested ? this._createNestedMenu() : this._createTieredMenu();
@@ -16622,145 +16702,176 @@
16622
16702
  };
16623
16703
  TieredMenuDirective.prototype._createTieredMenu = function () {
16624
16704
  var _this = this;
16625
- if (!this._componentRef && this.items) {
16705
+ var _a;
16706
+ if (!this._componentRef && ((_a = this._tieredMenuService.items) === null || _a === void 0 ? void 0 : _a.length) > 0) {
16626
16707
  var componentFactory = this._componentFactoryResolver.resolveComponentFactory(TieredMenuComponent);
16627
16708
  this._componentRef = componentFactory.create(this._injector);
16628
16709
  this._appRef.attachView(this._componentRef.hostView);
16629
16710
  var domElem = this._componentRef.hostView.rootNodes[0];
16630
16711
  document.body.appendChild(domElem);
16631
16712
  this._setMenuComponentProperties();
16632
- this._componentRef.instance.destroyRequest
16633
- .pipe(operators.takeUntil(this._unsubscribe$))
16634
- .subscribe(function () {
16713
+ this._componentRef.instance.destroyRequest.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function () {
16635
16714
  _this._destroy();
16636
16715
  });
16637
- this._menuDivElement = domElem.querySelector(".menu");
16638
16716
  this._setMenuPosition();
16639
16717
  }
16640
16718
  };
16641
16719
  TieredMenuDirective.prototype._createNestedMenu = function () {
16642
- if (!this._componentRef && this.items) {
16720
+ var _a;
16721
+ if (!this._componentRef && ((_a = this._tieredMenuService.items) === null || _a === void 0 ? void 0 : _a.length) > 0) {
16643
16722
  var componentFactory = this._componentFactoryResolver.resolveComponentFactory(TieredMenuNestedComponent);
16644
16723
  this._componentRef = componentFactory.create(this._injector);
16645
16724
  this._appRef.attachView(this._componentRef.hostView);
16646
16725
  var domElem = this._componentRef.hostView.rootNodes[0];
16647
16726
  document.body.appendChild(domElem);
16648
16727
  this._setMenuComponentProperties();
16649
- this._menuDivElement = domElem.querySelector(".menu");
16650
16728
  this._setMenuPosition();
16651
16729
  }
16652
16730
  };
16653
16731
  TieredMenuDirective.prototype._destroy = function () {
16654
- var _a;
16655
- if (this._componentRef !== null && !this.alwaysOpen) {
16732
+ if (this._componentRef) {
16656
16733
  this._isOpen = false;
16657
16734
  window.clearTimeout(this._showTimeout);
16658
16735
  this._appRef.detachView(this._componentRef.hostView);
16659
16736
  this._componentRef.destroy();
16660
16737
  this._componentRef = null;
16661
- this._menuDivElement = null;
16662
- (_a = this._lastActiveElement) === null || _a === void 0 ? void 0 : _a.focus();
16663
16738
  this._tieredMenuService.currentItems = this._tieredMenuService.items;
16664
16739
  this._tieredMenuService.currentItem = this._tieredMenuService.items[0];
16740
+ this._tieredMenuEventService.closeAllMenusEvent.emit();
16665
16741
  }
16666
16742
  };
16667
16743
  TieredMenuDirective.prototype._setMenuPosition = function () {
16744
+ var _a, _b;
16745
+ var ITEM_HEIGHT = 37;
16746
+ var ITEM_WIDTH = 176;
16747
+ var DIVIDER_HEIGHT = 5;
16748
+ var PADDING = 8;
16749
+ var MARGIN = 4;
16668
16750
  if (this._componentRef !== null) {
16669
- var _a = this._elementRef.nativeElement.getBoundingClientRect(), right = _a.right, bottom = _a.bottom, left = _a.left;
16670
- var menuWidth = this._menuDivElement.getBoundingClientRect().width;
16671
- var rightFreeSpace = document.body.clientWidth - right;
16672
- var topPosition = bottom + 2;
16673
- this._componentRef.instance.top = topPosition;
16674
- if (!this._isNested) {
16675
- if (rightFreeSpace > menuWidth) {
16676
- this._componentRef.instance.left = left;
16677
- }
16678
- else {
16679
- this._componentRef.instance.left = left - menuWidth;
16680
- }
16751
+ this._componentRef.instance.top = 8;
16752
+ var _c = this._elementRef.nativeElement.getBoundingClientRect(), bottom = _c.bottom, left = _c.left, right = _c.right;
16753
+ var itemsCount = (_a = this._componentRef.instance.items) === null || _a === void 0 ? void 0 : _a.reduce(function (count, item) {
16754
+ return !item.divider ? count + 1 : count;
16755
+ }, 0);
16756
+ var dividersCount = (_b = this._componentRef.instance.items) === null || _b === void 0 ? void 0 : _b.reduce(function (count, item) {
16757
+ return item.divider ? count + 1 : count;
16758
+ }, 0);
16759
+ var menuHeight = itemsCount * ITEM_HEIGHT + dividersCount * DIVIDER_HEIGHT + PADDING + MARGIN;
16760
+ var rightFreeSpace = window.innerWidth - right;
16761
+ var bottomFreeSpace = window.innerHeight - bottom;
16762
+ this._componentRef.instance.top = bottom;
16763
+ this._componentRef.instance.left = left;
16764
+ if (bottomFreeSpace <= menuHeight) {
16765
+ this._componentRef.instance.top = Math.max(bottom - menuHeight, 0);
16681
16766
  }
16682
16767
  else {
16683
- // setting the maximum menu size to ensure its content is always visible. 10px margin.
16684
- this._componentRef.instance.maxHeight = window.innerHeight - topPosition - 10;
16768
+ this._componentRef.instance.top = bottom + MARGIN;
16769
+ }
16770
+ if (rightFreeSpace > 176) {
16771
+ this._componentRef.instance.left = left;
16772
+ }
16773
+ else {
16774
+ this._componentRef.instance.left = right - ITEM_WIDTH;
16775
+ }
16776
+ if (this._isNested) {
16777
+ this._componentRef.instance.left = MARGIN;
16685
16778
  }
16686
16779
  }
16687
16780
  };
16688
16781
  TieredMenuDirective.prototype._setMenuComponentProperties = function () {
16689
16782
  if (this._componentRef != null) {
16690
- this._componentRef.instance.items = this.items;
16783
+ this._componentRef.instance.items = this._tieredMenuService.items;
16691
16784
  }
16692
16785
  };
16693
16786
  TieredMenuDirective.prototype._subscribeEvents = function () {
16694
16787
  var _this = this;
16695
- this._tieredMenuEventService.closeAllMenusEvent
16696
- .pipe(operators.takeUntil(this._unsubscribe$))
16697
- .subscribe(function () {
16698
- _this.items = _this._tieredMenuService.markAllItemsAsClosed(_this.items);
16788
+ this._tieredMenuEventService.closeAllMenusEvent.pipe(operators.takeUntil(this._unsubscribe$)).subscribe(function () {
16789
+ _this._tieredMenuService.items = _this._tieredMenuService.markAllItemsAsClosed(_this._tieredMenuService.items);
16699
16790
  _this._destroy();
16700
16791
  });
16701
16792
  };
16793
+ TieredMenuDirective.prototype._compareItems = function (item1, item2) {
16794
+ return JSON.stringify(item1) === JSON.stringify(item2);
16795
+ };
16796
+ TieredMenuDirective.prototype._rebuildMenu = function () {
16797
+ this._destroy();
16798
+ };
16799
+ TieredMenuDirective.prototype._updateServiceItems = function () {
16800
+ this._tieredMenuService.items = this._tieredMenuService.normalizeData(this.items);
16801
+ this._tieredMenuService.currentItems = this._tieredMenuService.items;
16802
+ this._tieredMenuService.currentItem = this._tieredMenuService.items[0];
16803
+ };
16702
16804
  TieredMenuDirective.ctorParameters = function () { return [
16703
16805
  { type: core.ElementRef },
16704
16806
  { type: core.ApplicationRef },
16705
16807
  { type: core.ComponentFactoryResolver },
16706
16808
  { type: core.Injector },
16707
16809
  { type: TieredMenuEventService },
16708
- { type: TieredMenuService }
16810
+ { type: TieredMenuService },
16811
+ { type: TieredMenuGlobalService },
16812
+ { type: core.ChangeDetectorRef }
16709
16813
  ]; };
16710
16814
  __decorate([
16711
16815
  core.Input()
16712
16816
  ], TieredMenuDirective.prototype, "items", void 0);
16713
- __decorate([
16714
- core.Input()
16715
- ], TieredMenuDirective.prototype, "alwaysOpen", void 0);
16716
16817
  __decorate([
16717
16818
  core.Input()
16718
16819
  ], TieredMenuDirective.prototype, "triggerEvent", void 0);
16719
- __decorate([
16720
- core.HostListener("window:resize")
16721
- ], TieredMenuDirective.prototype, "onResize", null);
16722
- __decorate([
16723
- core.HostListener("document:keydown", ["$event"])
16724
- ], TieredMenuDirective.prototype, "onKeydownHandler", null);
16725
16820
  __decorate([
16726
16821
  core.HostListener("click", ["$event"])
16727
16822
  ], TieredMenuDirective.prototype, "onClick", null);
16728
- __decorate([
16729
- core.HostListener("document:click", ["$event"])
16730
- ], TieredMenuDirective.prototype, "onDocumentClick", null);
16731
16823
  TieredMenuDirective = __decorate([
16732
16824
  core.Directive({
16733
16825
  selector: "[sTieredMenu]",
16826
+ providers: [TieredMenuEventService, TieredMenuService],
16734
16827
  })
16735
16828
  ], TieredMenuDirective);
16736
16829
  return TieredMenuDirective;
16737
16830
  }());
16738
16831
 
16832
+ var TieredMenuDividerComponent = /** @class */ (function () {
16833
+ function TieredMenuDividerComponent() {
16834
+ }
16835
+ TieredMenuDividerComponent = __decorate([
16836
+ core.Component({
16837
+ selector: "s-tiered-menu-divider",
16838
+ template: "<div class=\"divider\"></div>",
16839
+ styles: [".divider{margin:2px 0;height:1px;background-color:#ccc}"]
16840
+ })
16841
+ ], TieredMenuDividerComponent);
16842
+ return TieredMenuDividerComponent;
16843
+ }());
16844
+
16739
16845
  var TieredMenuItemComponent = /** @class */ (function () {
16740
16846
  function TieredMenuItemComponent(_tieredMenuEventService) {
16741
16847
  this._tieredMenuEventService = _tieredMenuEventService;
16742
16848
  this.focused = false;
16849
+ this.highlight = false;
16743
16850
  this.triggerEvent = "click";
16744
16851
  this.closeOnClick = false;
16745
16852
  }
16746
16853
  TieredMenuItemComponent.prototype.onClick = function () {
16854
+ if (this.item.disabled)
16855
+ return;
16747
16856
  if (this.item.submenu) {
16748
16857
  if (!this.item.isOpen) {
16749
- this._tieredMenuEventService.emitOpenItemMenuEvent(this.item);
16858
+ this._tieredMenuEventService.openItemMenuEvent.emit(this.item);
16750
16859
  }
16751
16860
  else if (this.closeOnClick) {
16752
- this._tieredMenuEventService.emitCloseItemMenuEvent(this.item);
16861
+ this._tieredMenuEventService.closeItemMenuEvent.emit(this.item);
16753
16862
  }
16754
16863
  }
16755
16864
  else {
16756
- this._tieredMenuEventService.emitSelectItemEvent(this.item);
16865
+ this._tieredMenuEventService.selectItemEvent.emit(this.item);
16757
16866
  }
16758
16867
  };
16759
16868
  TieredMenuItemComponent.prototype.onMouseEnter = function () {
16760
16869
  var _this = this;
16870
+ if (this.item.disabled)
16871
+ return;
16761
16872
  if (this.triggerEvent === "hover" && !this.item.isOpen) {
16762
16873
  this._showTimeout = window.setTimeout(function () {
16763
- _this._tieredMenuEventService.emitOpenItemMenuEvent(_this.item);
16874
+ _this._tieredMenuEventService.openItemMenuEvent.emit(_this.item);
16764
16875
  }, 300);
16765
16876
  }
16766
16877
  };
@@ -16776,6 +16887,9 @@
16776
16887
  __decorate([
16777
16888
  core.Input()
16778
16889
  ], TieredMenuItemComponent.prototype, "focused", void 0);
16890
+ __decorate([
16891
+ core.Input()
16892
+ ], TieredMenuItemComponent.prototype, "highlight", void 0);
16779
16893
  __decorate([
16780
16894
  core.Input()
16781
16895
  ], TieredMenuItemComponent.prototype, "triggerEvent", void 0);
@@ -16795,26 +16909,13 @@
16795
16909
  TieredMenuItemComponent = __decorate([
16796
16910
  core.Component({
16797
16911
  selector: "s-tiered-menu-item",
16798
- template: "<div\n [id]=\"item.id\"\n class=\"tiered-menu-item\"\n [ngClass]=\"{\n 'tiered-menu-item--open': item.isOpen,\n 'tiered-menu-item--focused': focused\n }\">\n <div class=\"tiered-menu-item-content\">\n <span class=\"icon\" [ngClass]=\"item.iconClass\"></span>\n <span class=\"label\">{{ item.label }}</span>\n </div>\n <span\n *ngIf=\"item.submenu\"\n class=\"submenu-icon\"\n [ngClass]=\"{\n 'fas': true,\n 'fa-chevron-left': item.isOpen,\n 'fa-chevron-right': !item.isOpen\n }\">\n </span>\n</div>",
16799
- styles: [".tiered-menu-item{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;padding:8px 16px;-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.tiered-menu-item .tiered-menu-item-content .label{margin:0 12px}.tiered-menu-item:hover{background-color:#e9e6e6}.tiered-menu-item--focused{background-color:#ccc!important}.tiered-menu-item--open{background-color:#e4e2e2}"]
16912
+ template: "<div\n [id]=\"item.id\"\n class=\"tiered-menu-item\"\n [ngClass]=\"{\n 'tiered-menu-item--open': item.isOpen,\n 'tiered-menu-item--focused': focused,\n 'tiered-menu-item--disabled': item.disabled\n }\">\n <div class=\"tiered-menu-item-content\">\n <span class=\"icon\" [ngClass]=\"item.iconClass\"></span>\n <span class=\"label\">{{ item.label }}</span>\n </div>\n <span\n *ngIf=\"item.submenu\"\n class=\"submenu-icon\"\n [ngClass]=\"{\n 'fas': true,\n 'fa-chevron-left': item.isOpen,\n 'fa-chevron-right': !item.isOpen\n }\">\n </span>\n</div>",
16913
+ styles: [".tiered-menu-item{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;padding:8px 16px;-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.tiered-menu-item .tiered-menu-item-content .label{margin:0 12px}.tiered-menu-item:hover{background-color:#e9e6e6}.tiered-menu-item--focused{background-color:#ccc!important}.tiered-menu-item--open{background-color:#e4e2e2}.tiered-menu-item--disabled{opacity:50%;cursor:default}"]
16800
16914
  })
16801
16915
  ], TieredMenuItemComponent);
16802
16916
  return TieredMenuItemComponent;
16803
16917
  }());
16804
16918
 
16805
- var TieredMenuDividerComponent = /** @class */ (function () {
16806
- function TieredMenuDividerComponent() {
16807
- }
16808
- TieredMenuDividerComponent = __decorate([
16809
- core.Component({
16810
- selector: "s-tiered-menu-divider",
16811
- template: "<div class=\"divider\"></div>",
16812
- styles: [".divider{margin:2px 0;height:1px;background-color:#ccc}"]
16813
- })
16814
- ], TieredMenuDividerComponent);
16815
- return TieredMenuDividerComponent;
16816
- }());
16817
-
16818
16919
  var TieredMenuModule = /** @class */ (function () {
16819
16920
  function TieredMenuModule() {
16820
16921
  }
@@ -16831,10 +16932,7 @@
16831
16932
  TieredMenuDividerComponent,
16832
16933
  ],
16833
16934
  exports: [TieredMenuDirective],
16834
- providers: [
16835
- TieredMenuEventService,
16836
- TieredMenuService,
16837
- ],
16935
+ providers: [TieredMenuGlobalService],
16838
16936
  })
16839
16937
  ], TieredMenuModule);
16840
16938
  return TieredMenuModule;
@@ -18006,20 +18104,21 @@
18006
18104
  exports.ɵcz = TieredMenuEventService;
18007
18105
  exports.ɵd = TemplateModule;
18008
18106
  exports.ɵda = TieredMenuService;
18009
- exports.ɵdb = TieredMenuComponent;
18010
- exports.ɵdc = TieredMenuNestedComponent;
18011
- exports.ɵdd = TieredMenuItemComponent;
18012
- exports.ɵde = TieredMenuDividerComponent;
18013
- exports.ɵdf = TimelineItemModule;
18014
- exports.ɵdg = TimelineIconItemComponent;
18015
- exports.ɵdh = HorizontalTimelineModule;
18016
- exports.ɵdi = HorizontalTimelineComponent;
18017
- exports.ɵdj = VerticalTimelineModule;
18018
- exports.ɵdk = VerticalTimelineComponent;
18019
- exports.ɵdl = RangeLineComponent;
18020
- exports.ɵdm = CollapseOptionComponent;
18021
- exports.ɵdn = CollapsedItemsComponent;
18022
- exports.ɵdo = VerticalItemsComponent;
18107
+ exports.ɵdb = TieredMenuGlobalService;
18108
+ exports.ɵdc = TieredMenuComponent;
18109
+ exports.ɵdd = TieredMenuNestedComponent;
18110
+ exports.ɵde = TieredMenuItemComponent;
18111
+ exports.ɵdf = TieredMenuDividerComponent;
18112
+ exports.ɵdg = TimelineItemModule;
18113
+ exports.ɵdh = TimelineIconItemComponent;
18114
+ exports.ɵdi = HorizontalTimelineModule;
18115
+ exports.ɵdj = HorizontalTimelineComponent;
18116
+ exports.ɵdk = VerticalTimelineModule;
18117
+ exports.ɵdl = VerticalTimelineComponent;
18118
+ exports.ɵdm = RangeLineComponent;
18119
+ exports.ɵdn = CollapseOptionComponent;
18120
+ exports.ɵdo = CollapsedItemsComponent;
18121
+ exports.ɵdp = VerticalItemsComponent;
18023
18122
  exports.ɵe = CustomTranslationsModule;
18024
18123
  exports.ɵf = CodeEditorComponent;
18025
18124
  exports.ɵg = CoreFacade;