Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/docs/src/app/core/api-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ export const API_FILES = {
'QuickViewGroupTitleComponent',
'QuickViewGroupItemComponent',
'QuickViewGroupItemLabelComponent',
'QuickViewGroupItemContentComponent'
'QuickViewGroupItemContentComponent',
'QuickViewGroupItemContentElementDirective'
],
scrollSpy: ['ScrollSpyDirective'],
select: ['SelectComponent', 'OptionComponent'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
</fd-quick-view-subheader-subtitle>
</fd-quick-view-subheader>

<fd-quick-view-group *ngFor="let group of data.groups">
<fd-quick-view-group-title>
<fd-quick-view-group *ngFor="let group of data.groups; let i = index"
[attr.aria-labelledby]="getGroupId(i, group)">
<fd-quick-view-group-title [id]="getGroupId(i, group)">
{{ group.title }}
</fd-quick-view-group-title>
<fd-quick-view-group-item *ngFor="let item of group.items">
Expand All @@ -24,9 +25,18 @@
[href]="'tel:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<a *ngSwitchCase="'Email'" [href]="'mailto:' + item.value" [innerText]="item.value" fd-link></a>
<div *ngSwitchDefault [innerText]="item.value"></div>
<a *ngSwitchCase="'Email'"
[href]="'mailto:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<div *ngSwitchDefault
[innerText]="item.value"
fd-quick-view-group-item-content-element
></div>
</ng-container>
</fd-quick-view-group-item-content>
</fd-quick-view-group-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ export class QuickViewBaseExampleComponent {
}]
}]
};

getGroupId(idx: number, group: any): string {
return `${this.data.id}-${idx}-${group.title.split(' ').join('-')}`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ng-template fdTemplate="header">
<div fd-bar-middle>
<fd-bar-element>
<h1 fd-title>Details</h1>
<h1 fd-title [id]="data.id+'-header'">Details</h1>
</fd-bar-element>
</div>
</ng-template>
Expand All @@ -22,8 +22,9 @@ <h1 fd-title>Details</h1>
</fd-quick-view-subheader-subtitle>
</fd-quick-view-subheader>

<fd-quick-view-group *ngFor="let group of data.groups">
<fd-quick-view-group-title>
<fd-quick-view-group *ngFor="let group of data.groups; let i = index"
[attr.aria-labelledby]="getGroupId(i, group)">
<fd-quick-view-group-title [id]="getGroupId(i, group)">
{{ group.title }}
</fd-quick-view-group-title>
<fd-quick-view-group-item *ngFor="let item of group.items">
Expand All @@ -36,9 +37,18 @@ <h1 fd-title>Details</h1>
[href]="'tel:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<a *ngSwitchCase="'Email'" [href]="'mailto:' + item.value" [innerText]="item.value" fd-link></a>
<div *ngSwitchDefault [innerText]="item.value"></div>
<a *ngSwitchCase="'Email'"
[href]="'mailto:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<div *ngSwitchDefault
[innerText]="item.value"
fd-quick-view-group-item-content-element
></div>
</ng-container>
</fd-quick-view-group-item-content>
</fd-quick-view-group-item>
Expand All @@ -55,7 +65,6 @@ <h1 fd-title>Details</h1>
</fd-button-bar>

<fd-button-bar
fd-initial-focus
fdType="transparent"
label="Cancel"
[compact]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ export class QuickViewDialogExampleComponent {
}]
};

get isOpened(): boolean {
return !!document.querySelector(`#${this.data.id}`);
}

constructor(private readonly dialogService: DialogService) {}

openDialog(dialog: TemplateRef<any>): void {
this.dialogService.open(dialog);
this.dialogService.open(dialog, { id: this.data.id, ariaLabelledBy: `${this.data.id}-header` });
}

getGroupId(idx: number, group: any): string {
return `${this.data.id}-${idx}-${group.title.split(' ').join('-')}`
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<div class="fd-docs-flex-display-helper">
<fd-popover placement="right-start" [noArrow]="false">
<fd-popover placement="right-start"
[noArrow]="false"
[focusAutoCapture]="true"
(isOpenChange)="isOpenChangePopover1($event)">
<fd-popover-control>
<button fd-button label="Open Popover"></button>
<button fd-button label="Open Popover"
[attr.aria-controls]="data.id+'-1'"
[attr.aria-expanded]="isOpened1"
[attr.aria-haspopup]="true"></button>
</fd-popover-control>

<fd-popover-body>
<fd-popover-body [id]="data.id+'-1'" role="tooltip">
<fd-quick-view [id]="data.id">
<fd-quick-view-title align="middle">{{ data.title }}</fd-quick-view-title>

Expand All @@ -18,8 +24,9 @@
</fd-quick-view-subheader-subtitle>
</fd-quick-view-subheader>

<fd-quick-view-group *ngFor="let group of data.groups">
<fd-quick-view-group-title>
<fd-quick-view-group *ngFor="let group of data.groups; let i = index;"
[attr.aria-labelledby]="getGroupId(i, group)">
<fd-quick-view-group-title [id]="getGroupId(i, group)">
{{ group.title }}
</fd-quick-view-group-title>
<fd-quick-view-group-item *ngFor="let item of group.items">
Expand All @@ -32,9 +39,18 @@
[href]="'tel:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<a *ngSwitchCase="'Email'" [href]="'mailto:' + item.value" [innerText]="item.value" fd-link></a>
<div *ngSwitchDefault [innerText]="item.value"></div>
<a *ngSwitchCase="'Email'"
[href]="'mailto:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<div *ngSwitchDefault
[innerText]="item.value"
fd-quick-view-group-item-content-element
></div>
</ng-container>
</fd-quick-view-group-item-content>
</fd-quick-view-group-item>
Expand All @@ -43,12 +59,18 @@
</fd-popover-body>
</fd-popover>

<fd-popover placement="right-start" [noArrow]="false">
<fd-popover placement="right-start"
[noArrow]="false"
[focusAutoCapture]="true"
(isOpenChange)="isOpenChangePopover2($event)">
<fd-popover-control>
<button fd-button label="Open Popover Without Heading"></button>
<button fd-button label="Open Popover Without Heading"
[attr.aria-controls]="data.id+'-2'"
[attr.aria-expanded]="isOpened2"
[attr.aria-haspopup]="true"></button>
</fd-popover-control>

<fd-popover-body>
<fd-popover-body [id]="data.id+'-2'" role="tooltip">
<fd-quick-view [id]="data.id+'-without-heading'">
<fd-quick-view-subheader>
<fd-avatar [image]="data.subHeader.avatar" size="s"></fd-avatar>
Expand All @@ -60,8 +82,9 @@
</fd-quick-view-subheader-subtitle>
</fd-quick-view-subheader>

<fd-quick-view-group *ngFor="let group of data.groups">
<fd-quick-view-group-title>
<fd-quick-view-group *ngFor="let group of data.groups; let i = index"
[attr.aria-labelledby]="getGroupId(i, group)">
<fd-quick-view-group-title [id]="getGroupId(i, group)">
{{ group.title }}
</fd-quick-view-group-title>
<fd-quick-view-group-item *ngFor="let item of group.items">
Expand All @@ -74,9 +97,18 @@
[href]="'tel:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<a *ngSwitchCase="'Email'"
[href]="'mailto:' + item.value"
[innerText]="item.value"
fd-link
fd-quick-view-group-item-content-element
></a>
<a *ngSwitchCase="'Email'" [href]="'mailto:' + item.value" [innerText]="item.value" fd-link></a>
<div *ngSwitchDefault [innerText]="item.value"></div>
<div *ngSwitchDefault
[innerText]="item.value"
fd-quick-view-group-item-content-element
></div>
</ng-container>
</fd-quick-view-group-item-content>
</fd-quick-view-group-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,19 @@ export class QuickViewPopoverExampleComponent {
}]
}]
};

isOpened1 = false;
isOpened2 = false;

isOpenChangePopover1(isOpen: boolean): void {
this.isOpened1 = isOpen;
}

isOpenChangePopover2(isOpen: boolean): void {
this.isOpened2 = isOpen;
}

getGroupId(idx: number, group: any): string {
return `${this.data.id}-${idx}-${group.title.split(' ').join('-')}`
}
}
1 change: 1 addition & 0 deletions libs/core/src/lib/quick-view/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './quick-view-group-title/quick-view-group-title.component';
export * from './quick-view-group-item/quick-view-group-item.component';
export * from './quick-view-group-item-label/quick-view-group-item-label.component';
export * from './quick-view-group-item-content/quick-view-group-item-content.component';
export * from './quick-view-group-item-content/quick-view-group-item-content-element.directive';
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { Component, ElementRef, ViewChild } from '@angular/core';
import { QuickViewGroupItemContentElementDirective } from './quick-view-group-item-content-element.directive';

@Component({
template: ` <div #directiveElement fd-quick-view-group-item-content-element> Element </div> `
})
class TestComponent {
@ViewChild('directiveElement')
ref: ElementRef;
}

describe('QuickViewGroupItemContentElementDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent, QuickViewGroupItemContentElementDirective]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should assign class', () => {
expect(component.ref.nativeElement.classList).toContain('fd-quick-view__group-item__content-element');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Directive } from '@angular/core';

@Directive({
// tslint:disable-next-line:directive-selector
selector: '[fd-quick-view-group-item-content-element]',
host: {
class: `${QuickViewGroupItemContentElementDirective.class} fd-input`
}
})
export class QuickViewGroupItemContentElementDirective {
/** @hidden */
static class = 'fd-quick-view__group-item__content-element';
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef } from '@angular/core';

import { QuickViewGroupItemContentElementDirective } from './quick-view-group-item-content-element.directive';
import { getClosest } from '@fundamental-ngx/core/utils';

@Component({
selector: 'fd-quick-view-group-item-content',
templateUrl: './quick-view-group-item-content.component.html',
host: {
'[class.fd-input]': 'true'
},
changeDetection: ChangeDetectionStrategy.OnPush
})
export class QuickViewGroupItemContentComponent {}
export class QuickViewGroupItemContentComponent implements AfterViewInit {
/** @hidden */
constructor(private readonly _elRef: ElementRef) {}

/** @hidden */
ngAfterViewInit(): void {
this._bindElementAttributes();
}

/** @hidden
* Needed for binding the id of the element and id of the proper label to aria-labelledby. */
private _bindElementAttributes(): void {
const parentId = getClosest('.fd-form-item', this._elRef.nativeElement)?.id;
const id = `${parentId}-content`;

const element = this._elRef.nativeElement.querySelector(`.${QuickViewGroupItemContentElementDirective.class}`);
if (element && parentId) {
element.setAttribute('id', id);
element.setAttribute('aria-labelledby', `${parentId}-label ${id}`);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef } from '@angular/core';
import { getClosest } from '@fundamental-ngx/core/utils';

@Component({
selector: 'fd-quick-view-group-item-label',
templateUrl: './quick-view-group-item-label.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class QuickViewGroupItemLabelComponent {}
export class QuickViewGroupItemLabelComponent implements AfterViewInit {
/** @hidden */
constructor(private readonly _elRef: ElementRef) {}

/** @hidden */
ngAfterViewInit(): void {
this._bindElementAttributes();
}

/** @hidden
* Needed for binding the id to the label element (and this id needed for aria-labelledby of proper element). */
private _bindElementAttributes(): void {
const parentId = getClosest('.fd-form-item', this._elRef.nativeElement)?.id;

if (this._elRef.nativeElement.firstChild && parentId) {
this._elRef.nativeElement.firstChild.setAttribute('id', `${parentId}-label`);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div fd-form-item>
<div fd-form-item [id]="id">
<ng-content></ng-content>
</div>
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';

let quickViewGroupItemUniqueId = 0;

@Component({
selector: 'fd-quick-view-group-item',
templateUrl: './quick-view-group-item.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class QuickViewGroupItemComponent {}
export class QuickViewGroupItemComponent {
/** Id of the quick view element. */
@Input()
id: string = 'fd-quick-view-group-item-' + quickViewGroupItemUniqueId++;
}
Loading