Skip to content

Commit fde35e4

Browse files
jelbourntinayuangao
authored andcommitted
feat: move a11y, bidi, platform, rxjs, and portal to cdk (#5386)
* feat: move a11y, bidi, platform, and portal to cdk * lint * Fix weird rxjs operator typing issue * Workaround for ngc issue * debug ie11 * debug ios * Add directionaltiy reexport
1 parent 2ff0433 commit fde35e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2312
-1798
lines changed

src/cdk/a11y/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# LiveAnnouncer
2+
`LiveAnnouncer` is a service, which announces messages to several screenreaders.
3+
4+
### Methods
5+
6+
| Name | Description |
7+
| --- | --- |
8+
| `announce(message, politeness)` | This announces a text message to the supported screenreaders. <br><br>The politeness parameter sets the `aria-live` attribute on the announcer element |
9+
10+
### Examples
11+
The service can be injected in a component.
12+
```ts
13+
@Component({
14+
selector: 'my-component'
15+
providers: [LiveAnnouncer]
16+
})
17+
export class MyComponent {
18+
19+
constructor(live: LiveAnnouncer) {
20+
live.announce("Hey Google");
21+
}
22+
23+
}
24+
```
25+
26+
### Supported Screenreaders
27+
- JAWS (Windows)
28+
- NVDA (Windows)
29+
- VoiceOver (OSX and iOS)
30+
- TalkBack (Android)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {QueryList} from '@angular/core';
10+
import {ListKeyManager, CanDisable} from './list-key-manager';
11+
12+
/**
13+
* This is the interface for highlightable items (used by the ActiveDescendantKeyManager).
14+
* Each item must know how to style itself as active or inactive and whether or not it is
15+
* currently disabled.
16+
*/
17+
export interface Highlightable extends CanDisable {
18+
setActiveStyles(): void;
19+
setInactiveStyles(): void;
20+
}
21+
22+
export class ActiveDescendantKeyManager extends ListKeyManager<Highlightable> {
23+
24+
/**
25+
* This method sets the active item to the item at the specified index.
26+
* It also adds active styles to the newly active item and removes active
27+
* styles from the previously active item.
28+
*/
29+
setActiveItem(index: number): void {
30+
Promise.resolve().then(() => {
31+
if (this.activeItem) {
32+
this.activeItem.setInactiveStyles();
33+
}
34+
super.setActiveItem(index);
35+
if (this.activeItem) {
36+
this.activeItem.setActiveStyles();
37+
}
38+
});
39+
}
40+
41+
}

src/cdk/a11y/fake-mousedown.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
/**
10+
* Screenreaders will often fire fake mousedown events when a focusable element
11+
* is activated using the keyboard. We can typically distinguish between these faked
12+
* mousedown events and real mousedown events using the "buttons" property. While
13+
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
14+
* the left mouse button), faked mousedowns will usually set the property value to 0.
15+
*/
16+
export function isFakeMousedownFromScreenReader(event: MouseEvent): boolean {
17+
return event.buttons === 0;
18+
}

src/cdk/a11y/focus-key-manager.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {QueryList} from '@angular/core';
10+
import {ListKeyManager, CanDisable} from './list-key-manager';
11+
12+
/**
13+
* This is the interface for focusable items (used by the FocusKeyManager).
14+
* Each item must know how to focus itself and whether or not it is currently disabled.
15+
*/
16+
export interface Focusable extends CanDisable {
17+
focus(): void;
18+
}
19+
20+
21+
export class FocusKeyManager extends ListKeyManager<Focusable> {
22+
23+
constructor(items: QueryList<Focusable>) {
24+
super(items);
25+
}
26+
27+
/**
28+
* This method sets the active item to the item at the specified index.
29+
* It also adds focuses the newly active item.
30+
*/
31+
setActiveItem(index: number): void {
32+
super.setActiveItem(index);
33+
34+
if (this.activeItem) {
35+
this.activeItem.focus();
36+
}
37+
}
38+
39+
}

0 commit comments

Comments
 (0)