-
Notifications
You must be signed in to change notification settings - Fork 6.8k
docs: add temporary docs for cdk #5429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
### FocusTrap | ||
The `cdkTrapFocus` directive traps <kbd>Tab</kbd> key focus within an element. This is intended to | ||
be used to create accessible experience for components like | ||
[modal dialogs](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal), where focus must be | ||
constrained. | ||
|
||
This directive is declared in `A11yModule`. | ||
|
||
#### Example | ||
```html | ||
<div class="my-inner-dialog-content" cdkTrapFocus> | ||
<!-- Tab and Shift + Tab will not leave this element. --> | ||
</div> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
### InteractivityChecker | ||
`InteractivityChecker` is used to check the interactivity of an element, capturing disabled, | ||
visible, tabbable, and focusable states for accessibility purposes. | ||
|
||
#### Methods | ||
|
||
##### `isDisabled(element: HTMLElement): boolean` | ||
Whether the given element is disabled. | ||
|
||
##### `isVisible(element: HTMLElement): boolean` | ||
Whether the given element is visible. | ||
|
||
This will capture states like `display: none` and `visibility: hidden`, | ||
but not things like being clipped by an `overflow: hidden` parent or being outside the viewport. | ||
|
||
##### `isFocusable(element: HTMLElement): boolean` | ||
Gets whether an element can be focused by the user. | ||
|
||
##### `isTabbable(element: HTMLElement): boolean` | ||
Gets whether an element can be reached via Tab key. | ||
Assumes that the element has already been checked with isFocusable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
### ListKeyManager | ||
`ListKeyManager` manages the focus in a list of items based on keyboard interaction. Intended to be | ||
used with components that correspond to a `role="menu"` or `role="listbox"` pattern. | ||
|
||
#### Properties | ||
|
||
##### `activeItemIndex` | ||
Index of the currently active item | ||
|
||
##### `activeItem` | ||
The active item | ||
|
||
#### `tabOut` | ||
Observable that emits any time the <kbd>Tab</kbd> key is pressed, so components can react when | ||
focus is shifted off of the list. | ||
|
||
#### Methods | ||
|
||
##### `withWrap(): this` | ||
Turns on wrapping mode, which ensures that the active item will wrap to | ||
the other end of list when there are no more items in the given direction. | ||
|
||
##### `setActiveItem(index: number): void` | ||
Sets the active item to the item at the index specified. | ||
|
||
##### `onKeydown(event: KeyboardEvent): void` | ||
Sets the active item depending on the key event passed in. | ||
|
||
##### `setFirstItemActive(): void` | ||
Sets the active item to the first enabled item in the list. | ||
|
||
##### `setLastItemActive(): void` | ||
Sets the active item to the last enabled item in the list. | ||
|
||
##### `setNextItemActive(): void` | ||
Sets the active item to the next enabled item in the list. | ||
|
||
##### `setPreviousItemActive(): void` | ||
Sets the active item to a previous enabled item in the list. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
### LiveAnnouncer | ||
`LiveAnnouncer` is used to announce messages for screen-reader users using an `aria-live` region. | ||
See [the W3C's WAI-ARIA](https://www.w3.org/TR/wai-aria/states_and_properties#aria-live) | ||
for more information on aria-live regions. | ||
|
||
#### Methods | ||
|
||
##### `announce(message: string, politeness?: 'off' | 'polite' | 'assertive'): void` | ||
Announce the given message via aria-live region. The politeness argument determines the | ||
`aria-live` attribute on the announcer element, defaulting to 'polite'. | ||
|
||
#### Examples | ||
The LiveAnnouncer is injected into a component: | ||
```ts | ||
@Component({ | ||
selector: 'my-component' | ||
providers: [LiveAnnouncer] | ||
}) | ||
export class MyComponent { | ||
|
||
constructor(liveAnnouncer: LiveAnnouncer) { | ||
liveAnnouncer.announce("Hey Google"); | ||
} | ||
|
||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
### BidiModule | ||
|
||
When including the CDK's `BidiModule`, components can inject `Directionality` to get the current | ||
text direction (RTL or LTR); | ||
|
||
#### Example | ||
```ts | ||
@Component({ ... }) | ||
export class MyWidget { | ||
private isRtl: boolean; | ||
|
||
constructor(dir: Directionality) { | ||
this.isRtl = dir.value === 'rtl'; | ||
|
||
dir.change.subscribe(() => { | ||
this.flipDirection(); | ||
}); | ||
} | ||
} | ||
``` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add back the example for this? or are you afraid people won't read and will just add both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no one path to
node_modules
that would work for everyone, and if we put anything there then people copy it and complain that it doesn't work.