@ni/nimble-angular 16.0.4 → 16.0.6

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
  import * as i0 from '@angular/core';
2
- import { Directive, Input, NgModule, forwardRef, HostListener, Inject, Optional, Host, Injectable, EventEmitter, Output } from '@angular/core';
3
- import { RouterLinkWithHref } from '@angular/router';
2
+ import { Directive, Input, NgModule, HostListener, forwardRef, Inject, Optional, Host, Injectable, EventEmitter, Output } from '@angular/core';
3
+ import { RouterLinkWithHref, Router, ActivatedRoute } from '@angular/router';
4
4
  export { AnchorAppearance } from '@ni/nimble-components/dist/esm/anchor/types';
5
- import { CommonModule } from '@angular/common';
5
+ import { CommonModule, LocationStrategy } from '@angular/common';
6
6
  import '@ni/nimble-components/dist/esm/anchor';
7
7
  import '@ni/nimble-components/dist/esm/anchor-button';
8
8
  import '@ni/nimble-components/dist/esm/anchor-tab';
@@ -697,17 +697,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
697
697
  * won't also be an active RouterLink directive incorrectly handling navigation.
698
698
  */
699
699
  class NimbleBreadcrumbItemRouterLinkWithHrefDirective extends RouterLinkWithHref {
700
+ constructor(injector, elementRef) {
701
+ super(injector.get(Router), injector.get(ActivatedRoute), injector.get(LocationStrategy));
702
+ this.elementRef = elementRef;
703
+ }
700
704
  set nimbleRouterLink(commands) {
701
705
  this.routerLink = commands;
702
706
  }
707
+ onClick(_button, _ctrlKey, _shiftKey, _altKey, _metaKey) {
708
+ // onClick is the 'click' @HostListener handler in RouterLinkWithHref. Override it to do nothing so that this directive
709
+ // can be in control of when the click handler is called. This allows RouterLinkWithHref's onClick to only be called
710
+ // when the link within the element is clicked rather than any part of the element.
711
+ return true;
712
+ }
713
+ nimbleOnClick(event) {
714
+ // Call onClick on the base class only when the anchor within the breadcrumb item was clicked.
715
+ if (event.composedPath().some(el => el === this.elementRef.nativeElement.control)) {
716
+ return super.onClick(event.button, event.ctrlKey, event.shiftKey, event.altKey, event.metaKey);
717
+ }
718
+ return true;
719
+ }
703
720
  }
704
- NimbleBreadcrumbItemRouterLinkWithHrefDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NimbleBreadcrumbItemRouterLinkWithHrefDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
705
- NimbleBreadcrumbItemRouterLinkWithHrefDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: NimbleBreadcrumbItemRouterLinkWithHrefDirective, selector: "nimble-breadcrumb-item[nimbleRouterLink]", inputs: { nimbleRouterLink: "nimbleRouterLink" }, usesInheritance: true, ngImport: i0 });
721
+ NimbleBreadcrumbItemRouterLinkWithHrefDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NimbleBreadcrumbItemRouterLinkWithHrefDirective, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
722
+ NimbleBreadcrumbItemRouterLinkWithHrefDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: NimbleBreadcrumbItemRouterLinkWithHrefDirective, selector: "nimble-breadcrumb-item[nimbleRouterLink]", inputs: { nimbleRouterLink: "nimbleRouterLink" }, host: { listeners: { "click": "nimbleOnClick($event,$event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" } }, usesInheritance: true, ngImport: i0 });
706
723
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NimbleBreadcrumbItemRouterLinkWithHrefDirective, decorators: [{
707
724
  type: Directive,
708
725
  args: [{ selector: 'nimble-breadcrumb-item[nimbleRouterLink]' }]
709
- }], propDecorators: { nimbleRouterLink: [{
726
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { nimbleRouterLink: [{
710
727
  type: Input
728
+ }], nimbleOnClick: [{
729
+ type: HostListener,
730
+ args: ['click',
731
+ ['$event', '$event.button', '$event.ctrlKey', '$event.shiftKey', '$event.altKey', '$event.metaKey']]
711
732
  }] } });
712
733
 
713
734
  /**