-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3014 from eduardmarcinco/feat/table-expand-all
feat: allow users to expand all table rows
- Loading branch information
Showing
8 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,15 +1,47 @@ | ||
import { | ||
Component, | ||
HostBinding | ||
EventEmitter, | ||
HostBinding, | ||
Input, | ||
Output | ||
} from "@angular/core"; | ||
import { I18n } from "carbon-components-angular/i18n"; | ||
import { Observable } from "rxjs"; | ||
|
||
@Component({ | ||
// tslint:disable-next-line: component-selector | ||
selector: "[cdsTableHeadExpand], [ibmTableHeadExpand]", | ||
template: ` | ||
<ng-content></ng-content> | ||
<button | ||
*ngIf="showExpandAllToggle" | ||
class="cds--table-expand__button" | ||
[attr.aria-label]="getAriaLabel() | async" | ||
(click)="expandedChange.emit(!expanded)"> | ||
<svg cdsIcon="chevron--right" size="16" class="cds--table-expand__svg"></svg> | ||
</button> | ||
<ng-container *ngIf="!showExpandAllToggle"> | ||
<ng-content></ng-content> | ||
</ng-container> | ||
` | ||
}) | ||
export class TableHeadExpand { | ||
@HostBinding("class.cds--table-expand") hostClass = true; | ||
|
||
@Input() showExpandAllToggle = false; | ||
|
||
@Input() expanded = false; | ||
|
||
@Output() expandedChange = new EventEmitter<boolean>(); | ||
|
||
@HostBinding("attr.data-previous-value") get previousValue() { | ||
return this.expanded ? "collapsed" : null; | ||
} | ||
|
||
protected _ariaLabel = this.i18n.getOverridable("TABLE.EXPAND_ALL_BUTTON"); | ||
|
||
constructor(protected i18n: I18n) { } | ||
|
||
getAriaLabel(): Observable<string> { | ||
return this._ariaLabel.subject; | ||
} | ||
} |
This file contains 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 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 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 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 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 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