|
1 | | -// Copyright (c) Microsoft Corporation. All rights reserved. |
2 | | -// Licensed under the MIT License. |
3 | | - |
4 | | -import { ReactWrapperComponent } from '@angular-react/core'; |
5 | | -import { INavProps, INavLink, INav } from 'office-ui-fabric-react'; |
6 | | -import { |
7 | | - Component, |
8 | | - ChangeDetectionStrategy, |
9 | | - Input, |
10 | | - ViewChild, |
11 | | - ElementRef, |
12 | | - ChangeDetectorRef, |
13 | | - Renderer2, |
14 | | - Output, |
15 | | - EventEmitter, |
16 | | -} from '@angular/core'; |
17 | | - |
18 | | -@Component({ |
19 | | - selector: 'fab-nav', |
20 | | - exportAs: 'fabNav', |
21 | | - template: ` |
22 | | - <Nav |
23 | | - #reactNode |
24 | | - [groups]="groups" |
25 | | - [LinkClick]="onLinkClickHandler" |
26 | | - [selectedKey]="selectedKey" |
27 | | - [expandButtonAriaLabel]="expandButtonAriaLabel" |
28 | | - [expandedStateText]="expandedStateText" |
29 | | - [collapsedStateText]="collapsedStateText" |
30 | | - [LinkExpandClick]="onLinkExpandClickHandler" |
31 | | - [isOnTop]="isOnTop" |
32 | | - [initialSelectedKey]="initialSelectedKey" |
33 | | - [ariaLabel]="ariaLabel" |
34 | | - [selectedAriaLabel]="selectedAriaLabel" |
35 | | - > |
36 | | - </Nav> |
37 | | - `, |
38 | | - styles: ['react-renderer'], |
39 | | - changeDetection: ChangeDetectionStrategy.OnPush, |
40 | | -}) |
41 | | -export class FabNavComponent extends ReactWrapperComponent<INavProps> { |
42 | | - @ViewChild('reactNode', { static: true }) |
43 | | - protected reactNodeRef: ElementRef; |
44 | | - |
45 | | - @Input() componentRef?: INavProps['componentRef']; |
46 | | - @Input() groups: INavProps["groups"]; |
47 | | - @Input() selectedKey?: INavProps["selectedKey"]; |
48 | | - @Input() isOnTop?: INavProps["isOnTop"]; |
49 | | - @Input() initialSelectedKey?: INavProps["initialSelectedKey"]; |
50 | | - @Input() ariaLabel?: INavProps["ariaLabel"]; |
51 | | - @Input() expandButtonAriaLabel?: INavProps["expandButtonAriaLabel"]; |
52 | | - @Input() selectedAriaLabel?: INavProps["selectedAriaLabel"]; |
53 | | - |
54 | | - @Output() readonly onLinkClick = new EventEmitter<{ |
55 | | - event: Event, |
56 | | - link: INavLink |
57 | | - }>(); |
58 | | - @Output() readonly onLinkExpandClick = new EventEmitter<{ |
59 | | - event: Event, |
60 | | - link: INavLink |
61 | | - }>(); |
62 | | - |
63 | | - constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, renderer: Renderer2) { |
64 | | - super(elementRef, changeDetectorRef, renderer); |
65 | | - this.onLinkClickHandler = this.onLinkClickHandler.bind(this); |
66 | | - this.onLinkExpandClickHandler = this.onLinkExpandClickHandler.bind(this); |
67 | | - } |
68 | | - |
69 | | - onLinkClickHandler(event: React.MouseEvent<HTMLElement>, link?: INavLink): void { |
70 | | - this.onLinkClick.emit({ |
71 | | - event: event.nativeEvent, |
72 | | - link: link |
73 | | - }); |
74 | | - } |
75 | | - |
76 | | - onLinkExpandClickHandler(event: React.MouseEvent<HTMLElement>, link?: INavLink): void { |
77 | | - this.onLinkExpandClick.emit({ |
78 | | - event: event.nativeEvent, |
79 | | - link: link |
80 | | - }); |
81 | | - } |
82 | | -} |
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +import { ReactWrapperComponent } from '@angular-react/core'; |
| 5 | +import { INavProps, INavLink, INav } from 'office-ui-fabric-react'; |
| 6 | +import { |
| 7 | + Component, |
| 8 | + ChangeDetectionStrategy, |
| 9 | + Input, |
| 10 | + ViewChild, |
| 11 | + ElementRef, |
| 12 | + ChangeDetectorRef, |
| 13 | + Renderer2, |
| 14 | + Output, |
| 15 | + EventEmitter, |
| 16 | +} from '@angular/core'; |
| 17 | + |
| 18 | +@Component({ |
| 19 | + selector: 'fab-nav', |
| 20 | + exportAs: 'fabNav', |
| 21 | + template: ` |
| 22 | + <Nav |
| 23 | + #reactNode |
| 24 | + [groups]="groups" |
| 25 | + [LinkClick]="onLinkClickHandler" |
| 26 | + [selectedKey]="selectedKey" |
| 27 | + [expandButtonAriaLabel]="expandButtonAriaLabel" |
| 28 | + [LinkExpandClick]="onLinkExpandClickHandler" |
| 29 | + [isOnTop]="isOnTop" |
| 30 | + [initialSelectedKey]="initialSelectedKey" |
| 31 | + [ariaLabel]="ariaLabel" |
| 32 | + [selectedAriaLabel]="selectedAriaLabel" |
| 33 | + > |
| 34 | + </Nav> |
| 35 | + `, |
| 36 | + styles: ['react-renderer'], |
| 37 | + changeDetection: ChangeDetectionStrategy.OnPush, |
| 38 | +}) |
| 39 | +export class FabNavComponent extends ReactWrapperComponent<INavProps> { |
| 40 | + @ViewChild('reactNode', { static: true }) |
| 41 | + protected reactNodeRef: ElementRef; |
| 42 | + |
| 43 | + @Input() componentRef?: INavProps['componentRef']; |
| 44 | + @Input() groups: INavProps["groups"]; |
| 45 | + @Input() selectedKey?: INavProps["selectedKey"]; |
| 46 | + @Input() isOnTop?: INavProps["isOnTop"]; |
| 47 | + @Input() initialSelectedKey?: INavProps["initialSelectedKey"]; |
| 48 | + @Input() ariaLabel?: INavProps["ariaLabel"]; |
| 49 | + @Input() expandButtonAriaLabel?: INavProps["expandButtonAriaLabel"]; |
| 50 | + @Input() selectedAriaLabel?: INavProps["selectedAriaLabel"]; |
| 51 | + |
| 52 | + @Output() readonly onLinkClick = new EventEmitter<{ |
| 53 | + event: Event, |
| 54 | + link: INavLink |
| 55 | + }>(); |
| 56 | + @Output() readonly onLinkExpandClick = new EventEmitter<{ |
| 57 | + event: Event, |
| 58 | + link: INavLink |
| 59 | + }>(); |
| 60 | + |
| 61 | + constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, renderer: Renderer2) { |
| 62 | + super(elementRef, changeDetectorRef, renderer); |
| 63 | + this.onLinkClickHandler = this.onLinkClickHandler.bind(this); |
| 64 | + this.onLinkExpandClickHandler = this.onLinkExpandClickHandler.bind(this); |
| 65 | + } |
| 66 | + |
| 67 | + onLinkClickHandler(event: React.MouseEvent<HTMLElement>, link?: INavLink): void { |
| 68 | + this.onLinkClick.emit({ |
| 69 | + event: event.nativeEvent, |
| 70 | + link: link |
| 71 | + }); |
| 72 | + } |
| 73 | + |
| 74 | + onLinkExpandClickHandler(event: React.MouseEvent<HTMLElement>, link?: INavLink): void { |
| 75 | + this.onLinkExpandClick.emit({ |
| 76 | + event: event.nativeEvent, |
| 77 | + link: link |
| 78 | + }); |
| 79 | + } |
| 80 | +} |
0 commit comments