Skip to content

Commit 3582c07

Browse files
authored
Merge branch 'master' into issue#46
2 parents 971ef3b + 2f53c91 commit 3582c07

File tree

7 files changed

+557
-422
lines changed

7 files changed

+557
-422
lines changed

package-lock.json

Lines changed: 510 additions & 357 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,19 @@
8686
"@commitlint/cli": "7.2.1",
8787
"@commitlint/config-conventional": "7.0.1",
8888
"@compodoc/compodoc": "1.1.7",
89-
"@storybook/addon-actions": "5.0.0",
90-
"@storybook/addon-knobs": "5.0.0",
91-
"@storybook/addon-links": "5.0.0",
92-
"@storybook/addon-notes": "5.0.0",
93-
"@storybook/addon-options": "5.0.0",
94-
"@storybook/addon-storysource": "5.0.0",
95-
"@storybook/addons": "5.0.0",
96-
"@storybook/angular": "5.0.0",
89+
"@storybook/addon-actions": "5.0.3",
90+
"@storybook/addon-knobs": "5.0.3",
91+
"@storybook/addon-links": "5.0.3",
92+
"@storybook/addon-notes": "5.0.3",
93+
"@storybook/addon-options": "5.0.3",
94+
"@storybook/addon-storysource": "5.0.3",
95+
"@storybook/addons": "5.0.3",
96+
"@storybook/angular": "5.0.3",
9797
"@types/jasmine": "2.8.6",
9898
"@types/node": "8.5.2",
9999
"angular2-template-loader": "0.6.2",
100100
"babel-loader": "8.0.4",
101-
"carbon-components": "9.82.17",
101+
"carbon-components": "9.84.14",
102102
"codelyzer": "4.5.0",
103103
"commitizen": "2.10.1",
104104
"core-js": "2.5.5",

src/i18n/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@
118118
"END_OF_DATA": "You've reached the end of your content",
119119
"SCROLL_TOP": "Scroll to top",
120120
"CHECKBOX_HEADER": "Select all rows",
121-
"CHECKBOX_ROW": "Select row",
121+
"CHECKBOX_ROW": "Select {{value}}",
122122
"EXPAND_BUTTON": "Expand row",
123123
"SORT_DESCENDING": "Sort rows by this header in descending order",
124-
"SORT_ASCENDING": "Sort rows by this header in ascending order"
125-
124+
"SORT_ASCENDING": "Sort rows by this header in ascending order",
125+
"ROW": "row"
126126
},
127127
"TABLE_TOOLBAR": {
128128
"ACTION_BAR": "Table Action Bar"

src/table/table.component.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ import { I18n } from "./../i18n/i18n.module";
347347
(click)="setCheckboxIndex()">
348348
<ibm-checkbox
349349
inline="true"
350-
[attr.aria-label]="checkboxRowLabel | async"
350+
[aria-label]="checkboxRowLabel | i18nReplace:getSelectionLabelValue(row) | async"
351351
[size]="size !== ('lg' ? 'sm' : 'md')"
352352
[(ngModel)]="model.rowsSelected[i]"
353353
(change)="onRowCheckboxChange(i)">
@@ -650,6 +650,18 @@ export class Table implements AfterViewInit {
650650
*/
651651
@Input() footerTemplate: TemplateRef<any>;
652652

653+
/**
654+
* Used to populate the row selection checkbox label with a useful value if set.
655+
*
656+
* Example:
657+
* ```
658+
* <ibm-table [selectionLabelColumn]="0"></ibm-table>
659+
* <!-- results in aria-label="Select first column value"
660+
* (where "first column value" is the value of the first column in the row -->
661+
* ```
662+
*/
663+
@Input() selectionLabelColumn: number;
664+
653665
/**
654666
* Emits an index of the column that wants to be sorted.
655667
*
@@ -952,4 +964,11 @@ export class Table implements AfterViewInit {
952964
setExpandIndex(event) {
953965
this.columnIndex = 0;
954966
}
967+
968+
getSelectionLabelValue(row: TableItem[]) {
969+
if (!this.selectionLabelColumn) {
970+
return { value: this.i18n.get().TABLE.ROW };
971+
}
972+
return { value: row[this.selectionLabelColumn].data };
973+
}
955974
}

src/tabs/tab-headers.component.ts

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import {
44
Input,
55
HostListener,
66
ViewChild,
7-
AfterViewInit,
87
ContentChildren,
9-
AfterContentInit
8+
AfterContentInit,
9+
ViewChildren,
10+
ElementRef
1011
} from "@angular/core";
1112

12-
import { fromEvent } from "rxjs";
13-
import { throttleTime } from "rxjs/operators";
14-
1513
import { Tab } from "./tab.component";
1614

1715

@@ -61,6 +59,7 @@ import { Tab } from "./tab.component";
6159
role="presentation"
6260
(click)="selectTab(tabref, tab, i)">
6361
<a
62+
#tabItem
6463
[attr.aria-selected]="tab.active"
6564
[attr.tabindex]="(tab.active?0:-1)"
6665
[attr.aria-controls]="tab.id"
@@ -88,24 +87,20 @@ import { Tab } from "./tab.component";
8887
`
8988
})
9089

91-
export class TabHeaders implements AfterViewInit, AfterContentInit {
90+
export class TabHeaders implements AfterContentInit {
9291
/**
9392
* List of `Tab` components.
94-
* @type {QueryList<Tab>}
95-
* @memberof TabHeaders
9693
*/
9794
// disable the next line because we need to rename the input
9895
// tslint:disable-next-line
9996
@Input("tabs") tabInput: QueryList<Tab>;
10097
/**
10198
* Set to 'true' to have `Tab` items cached and not reloaded on tab switching.
10299
* Duplicate from `n-tabs` to support standalone headers
103-
* @memberof Tabs
104100
*/
105101
@Input() cacheActive = false;
106102
/**
107103
* Set to 'true' to have tabs automatically activated and have their content displayed when they receive focus.
108-
* @memberof TabHeaders
109104
*/
110105
@Input() followFocus: boolean;
111106
/**
@@ -115,7 +110,6 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
115110

116111
/**
117112
* Gets the Unordered List element that holds the `Tab` headings from the view DOM.
118-
* @memberof TabHeaders
119113
*/
120114
@ViewChild("tabList") headerContainer;
121115
/**
@@ -128,26 +122,21 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
128122
public tabs: QueryList<Tab>;
129123
/**
130124
* The index of the first visible tab.
131-
* @memberof TabHeaders
132125
*/
133126
public firstVisibleTab = 0;
134127
/**
135128
* The DOM element containing the `Tab` headings displayed.
136-
* @memberof TabHeaders
137129
*/
138-
public allTabHeaders;
130+
@ViewChildren("tabItem") allTabHeaders: QueryList<ElementRef>;
139131
/**
140132
* Controls the manual focusing done by tabbing through headings.
141-
* @memberof TabHeaders
142133
*/
143134
public currentSelectedTab: number;
144135
public tabListVisible = false;
145136

146137
// keyboard accessibility
147138
/**
148139
* Controls the keydown events used for tabbing through the headings.
149-
* @param {any} event
150-
* @memberof TabHeaders
151140
*/
152141
@HostListener("keydown", ["$event"])
153142
keyboardInput(event) {
@@ -160,13 +149,13 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
160149
if (this.followFocus) {
161150
this.selectTab(event.target, tabsArray[this.currentSelectedTab + 1], this.currentSelectedTab);
162151
}
163-
this.allTabHeaders[this.currentSelectedTab + 1].focus();
152+
this.allTabHeaders.toArray()[this.currentSelectedTab + 1].nativeElement.focus();
164153
} else {
165154
event.preventDefault();
166155
if (this.followFocus) {
167156
this.selectTab(event.target, tabsArray[0], 0);
168157
}
169-
this.allTabHeaders[0].focus();
158+
this.allTabHeaders.first.nativeElement.focus();
170159
}
171160
}
172161

@@ -177,13 +166,13 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
177166
if (this.followFocus) {
178167
this.selectTab(event.target, tabsArray[this.currentSelectedTab - 1], this.currentSelectedTab);
179168
}
180-
this.allTabHeaders[this.currentSelectedTab - 1].focus();
169+
this.allTabHeaders.toArray()[this.currentSelectedTab - 1].nativeElement.focus();
181170
} else {
182171
event.preventDefault();
183172
if (this.followFocus) {
184173
this.selectTab(event.target, tabsArray[this.allTabHeaders.length - 1], this.allTabHeaders.length);
185174
}
186-
this.allTabHeaders[this.allTabHeaders.length - 1].focus();
175+
this.allTabHeaders.toArray()[this.allTabHeaders.length - 1].nativeElement.focus();
187176
}
188177
}
189178

@@ -192,15 +181,15 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
192181
if (this.followFocus) {
193182
this.selectTab(event.target, tabsArray[0], 0);
194183
}
195-
this.allTabHeaders[0].focus();
184+
this.allTabHeaders.toArray()[0].nativeElement.focus();
196185
}
197186

198187
if (event.key === "End") {
199188
event.preventDefault();
200189
if (this.followFocus) {
201190
this.selectTab(event.target, tabsArray[this.allTabHeaders.length - 1], this.allTabHeaders.length);
202191
}
203-
this.allTabHeaders[this.allTabHeaders.length - 1].focus();
192+
this.allTabHeaders.toArray()[this.allTabHeaders.length - 1].nativeElement.focus();
204193
}
205194

206195
// `"Spacebar"` is IE11 specific value
@@ -219,25 +208,12 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
219208
this.tabs.forEach(tab => tab.cacheActive = this.cacheActive);
220209
this.tabs.changes.subscribe(() => {
221210
this.setFirstTab();
222-
// also update the tab headers list
223-
this.allTabHeaders = this.headerContainer.nativeElement.querySelectorAll("li a");
224211
});
225212
this.setFirstTab();
226213
}
227214

228-
/**
229-
* Performs check to see if there is overflow and needs scrolling.
230-
* @memberof TabHeaders
231-
*/
232-
ngAfterViewInit() {
233-
this.allTabHeaders = this.headerContainer.nativeElement.querySelectorAll("li a");
234-
}
235-
236215
/**
237216
* Controls manually focusing tabs.
238-
* @param {HTMLElement} ref
239-
* @param {number} index
240-
* @memberof TabHeaders
241217
*/
242218
public onTabFocus(ref: HTMLElement, index: number) {
243219
this.currentSelectedTab = index;
@@ -259,10 +235,6 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
259235

260236
/**
261237
* Selects `Tab` 'tab' and moves it into view on the view DOM if it is not already.
262-
* @param ref
263-
* @param tab
264-
* @param tabIndex
265-
* @memberof TabHeaders
266238
*/
267239
public selectTab(ref: HTMLElement, tab: Tab, tabIndex: number) {
268240
if (tab.disabled) {
@@ -279,8 +251,6 @@ export class TabHeaders implements AfterViewInit, AfterContentInit {
279251

280252
/**
281253
* Determines which `Tab` is initially selected.
282-
* @protected
283-
* @memberof Tabs
284254
*/
285255
protected setFirstTab() {
286256
setTimeout(() => {

src/tabs/tabs.component.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,14 @@ export class Tabs implements AfterContentInit {
5959
/**
6060
* Takes either the string value 'top' or 'bottom' to place TabHeader
6161
* relative to the `TabPanel`s.
62-
* @type string
63-
* @memberof Tabs
6462
*/
6563
@Input() position: "top" | "bottom" = "top";
6664
/**
6765
* Set to 'true' to have `Tab` items cached and not reloaded on tab switching.
68-
* @memberof Tabs
6966
*/
7067
@Input() cacheActive = false;
7168
/**
72-
* Set to 'true' to have tabs automatically activated and have their content displayed when they recieve focus.
73-
* @memberof Tabs
69+
* Set to 'true' to have tabs automatically activated and have their content displayed when they receive focus.
7470
*/
7571
@Input() followFocus = true;
7672
/**
@@ -84,8 +80,6 @@ export class Tabs implements AfterContentInit {
8480

8581
/**
8682
* Maintains a `QueryList` of the `Tab` elements and updates if `Tab`s are added or removed.
87-
* @type {QueryList<Tab>}
88-
* @memberof Tabs
8983
*/
9084
@ContentChildren(Tab, { descendants: false }) tabs: QueryList<Tab>;
9185
/**
@@ -94,9 +88,8 @@ export class Tabs implements AfterContentInit {
9488
@ContentChild(TabHeaders) tabHeaders;
9589

9690
/**
97-
* After content is initialized update `Tab`s to cache (if turned on) and set the inital
91+
* After content is initialized update `Tab`s to cache (if turned on) and set the initial
9892
* selected Tab item.
99-
* @memberof Tabs
10093
*/
10194
ngAfterContentInit() {
10295
if (this.tabHeaders) {

src/tabs/tabs.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ storiesOf("Tabs", module)
4444
</ng-template>
4545
<ibm-tabs [followFocus]="followFocus" [isNavigation]="isNavigation">
4646
<ibm-tab *ngFor="let item of data; let i = index;" [heading]="customTabs" [context]="item">Tab Content {{i + 1}}</ibm-tab>
47-
<ibm-tab [heading]="iconTab">Tab Content 4</ibm-tab>
47+
<ibm-tab [heading]="iconTab">Tab Content Custom</ibm-tab>
4848
</ibm-tabs>
4949
`,
5050
props: {

0 commit comments

Comments
 (0)