Skip to content

Commit 6fc37f3

Browse files
committed
Merge branch 'master' of github.com:IBM/carbon-components-angular
2 parents b22506e + 020a017 commit 6fc37f3

File tree

8 files changed

+66
-47
lines changed

8 files changed

+66
-47
lines changed

src/checkbox/checkbox.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class CheckboxChange {
6767
[indeterminate]="indeterminate"
6868
[attr.aria-label]="ariaLabel"
6969
[attr.aria-labelledby]="ariaLabelledby"
70-
[attr.aria-checked]="indeterminate ? 'mixed' : checked"
70+
[attr.aria-checked]="(indeterminate ? 'mixed' : checked)"
7171
(change)="onChange($event)"
7272
(click)="onClick($event)">
7373
<label [for]="id" class="bx--checkbox-label">

src/combobox/combobox.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,11 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
6161
</div>
6262
<input
6363
[disabled]="disabled"
64-
[attr.aria-expanded]="open"
6564
(click)="toggleDropdown()"
6665
(keyup)="onSearch($event.target.value)"
6766
[value]="selectedValue"
6867
class="bx--text-input"
6968
aria-label="ListBox input field"
70-
role="combobox"
71-
aria-autocomplete="list"
7269
autocomplete="off"
7370
placeholder="Filter..."/>
7471
<div
@@ -200,7 +197,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
200197
@ContentChild(AbstractDropdownView) view: AbstractDropdownView;
201198
@ViewChild("dropdownMenu") dropdownMenu;
202199
@HostBinding("class") class = "bx--combo-box bx--list-box";
203-
@HostBinding("attr.role") role = "listbox";
200+
@HostBinding("attr.role") role = "combobox";
204201
@HostBinding("style.display") display = "block";
205202

206203
public open = false;

src/dialog/overflow-menu/overflow-menu.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ const EN = require("./../../i18n/en.json");
77
*
88
* html:
99
* ```
10-
* <ibm-overflow-menu [options]="overflowContent"></ibm-overflow-menu>
11-
* <ng-template #overflowContent>
10+
* <ibm-overflow-menu>
1211
* <ibm-overflow-menu-option>Option 1</ibm-overflow-menu-option>
1312
* <ibm-overflow-menu-option>Option 2</ibm-overflow-menu-option>
14-
* </ng-template>
13+
* </ibm-overflow-menu>
1514
* ```
1615
*/
1716
@Component({

src/dropdown/dropdown.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ import {
44
Output,
55
EventEmitter,
66
ElementRef,
7-
ViewEncapsulation,
87
ContentChild,
98
OnInit,
109
ViewChild,
1110
AfterContentInit,
12-
AfterViewInit,
1311
HostListener,
14-
forwardRef,
15-
OnDestroy,
16-
HostBinding
12+
OnDestroy
1713
} from "@angular/core";
1814
import { NG_VALUE_ACCESSOR } from "@angular/forms";
1915

16+
// Observable import is required here so typescript can compile correctly
2017
import { Observable, fromEvent, of, Subscription } from "rxjs";
2118
import { throttleTime } from "rxjs/operators";
2219

src/dropdown/list/dropdown-list.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ import { ScrollableList } from "./../scrollable-list.directive";
5353
@Component({
5454
selector: "ibm-dropdown-list",
5555
template: `
56-
<ul #list class="bx--list-box__menu">
56+
<ul
57+
#list
58+
role="listbox"
59+
class="bx--list-box__menu">
5760
<li tabindex="{{item.disabled? -1 : 0}}"
5861
role="option"
5962
*ngFor="let item of displayItems"
@@ -72,7 +75,8 @@ import { ScrollableList } from "./../scrollable-list.directive";
7275
type="checkbox"
7376
[checked]="item.selected"
7477
[disabled]="item.disabled"
75-
(click)="doClick($event, item)">
78+
(click)="doClick($event, item)"
79+
tabindex="-1">
7680
<label class="bx--checkbox-label">{{item.content}}</label>
7781
</div>
7882
<ng-container *ngIf="!listTpl && type === 'single'">{{item.content}}</ng-container>

src/table/table-model.class.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ describe("Table", () => {
88
expect(tableModel.totalDataLength).toEqual(0);
99
});
1010

11+
it("model should handle different variants of empty data", () => {
12+
let tableModel = new TableModel();
13+
tableModel.data = undefined;
14+
15+
expect(tableModel.data).toEqual([[]]);
16+
expect(tableModel.totalDataLength).toEqual(0);
17+
18+
tableModel.data = null;
19+
20+
expect(tableModel.data).toEqual([[]]);
21+
expect(tableModel.totalDataLength).toEqual(0);
22+
23+
tableModel.data = [];
24+
25+
expect(tableModel.data).toEqual([[]]);
26+
expect(tableModel.totalDataLength).toEqual(0);
27+
});
28+
1129
it("should set rowsSelected when setting data", () => {
1230
let tableModel = new TableModel();
1331
tableModel.data = [

src/table/table-model.class.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export class TableModel implements PaginationModel {
1515
* @memberof TableModel
1616
*/
1717
set data(newData: Array<Array<TableItem>>) {
18+
if (!newData || (Array.isArray(newData) && newData.length === 0) ) {
19+
newData = [[]];
20+
}
21+
1822
this._data = newData;
1923

2024
// init rowsSelected

src/table/table.component.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ const EN = require("./../i18n/en.json");
1515
/**
1616
* Build your table with this component by extending things that differ from default.
1717
*
18-
* demo: [https://pages.github.ibm.com/peretz/neutrino/#/table](https://pages.github.ibm.com/peretz/neutrino/#/table)
18+
* demo: [https://angular.carbondesignsystem.com/?selectedKind=Table](https://angular.carbondesignsystem.com/?selectedKind=Table)
1919
*
2020
* Instead of the usual write-your-own-html approach you had with `<table>`,
21-
* neutrino table uses model-view-controller approach.
21+
* carbon table uses model-view-controller approach.
2222
*
2323
* Here, you create a view (with built-in controller) and provide it a model.
2424
* Changes you make to the model are reflected in the view. Provide same model you use
25-
* in the table to the `<ibm-table-pagination>` and `<ibm-table-goto-page>` components.
25+
* in the table to the `<ibm-pagination>` components.
2626
* They provide a different view over the same data.
2727
*
2828
* ## Basic usage
2929
*
3030
* ```html
31-
* <ibm-table [model]="simpleModel"></ibm-table>
31+
* <ibm-table [model]="model"></ibm-table>
3232
* ```
3333
*
3434
* ```typescript
35-
* public simpleModel = new TableModel();
35+
* public model = new TableModel();
3636
*
37-
* this.simpleModel.data = [
37+
* this.model.data = [
3838
* [new TableItem({data: "asdf"}), new TableItem({data: "qwer"})],
3939
* [new TableItem({data: "csdf"}), new TableItem({data: "zwer"})],
4040
* [new TableItem({data: "bsdf"}), new TableItem({data: "swer"})],
@@ -104,14 +104,10 @@ const EN = require("./../i18n/en.json");
104104
*
105105
* See `TableHeaderItem` class for more information.
106106
*
107-
* ## Build your own table footer with neutrino components
107+
* ## Use pagination as table footer
108108
*
109109
* ```html
110-
* <p class="table-footer">
111-
* <span class="table-selection-info">{{model.selectedRowsCount()}} of {{model.totalDataLength}} rows selected</span>
112-
* <ibm-table-pagination [model]="model" (selectPage)="selectPage($event)"></ibm-table-pagination>
113-
* <ibm-table-goto-page (selectPage)="selectPage($event)"></ibm-table-goto-page>
114-
* </p>
110+
* <ibm-pagination [model]="model" (selectPage)="selectPage($event)"></ibm-pagination>
115111
* ```
116112
*
117113
* `selectPage()` function should fetch the data from backend, create new `data`, apply it to `model.data`,
@@ -121,28 +117,30 @@ const EN = require("./../i18n/en.json");
121117
*
122118
* ```typescript
123119
* selectPage(page) {
124-
* this.service.getPage(page).then((data: Array<Array<any>>) => {
125-
* let newData = [];
126-
*
127-
* // create new data from the service data
128-
* data.forEach(dataRow => {
129-
* let row = [];
130-
* dataRow.forEach(dataElement => {
131-
* row.push(new TableItem({
132-
* data: dataElement,
133-
* template: typeof dataElement === "string" ? undefined : this.customTableItemTemplate
134-
* // your template can handle all the data types so you don't have to conditionally set it
135-
* // you can also set different templates for different columns based on index
136-
* }));
137-
* });
138-
* newData.push(row);
139-
* });
140-
*
120+
* this.getPage(page).then((data: Array<Array<any>>) => {
141121
* // set the data and update page
142-
* this.model.data = newData;
122+
* this.model.data = this.prepareData(data);
143123
* this.model.currentPage = page;
144124
* });
145125
* }
126+
*
127+
* private prepareData(data: Array<Array<any>>) {
128+
* // create new data from the service data
129+
* let newData = [];
130+
* data.forEach(dataRow => {
131+
* let row = [];
132+
* dataRow.forEach(dataElement => {
133+
* row.push(new TableItem({
134+
* data: dataElement,
135+
* template: typeof dataElement === "string" ? undefined : this.paginationTableItemTemplate
136+
* // your template can handle all the data types so you don't have to conditionally set it
137+
* // you can also set different templates for different columns based on index
138+
* }));
139+
* });
140+
* newData.push(row);
141+
* });
142+
* return newData;
143+
* }
146144
* ```
147145
*
148146
* @export
@@ -164,9 +162,10 @@ const EN = require("./../i18n/en.json");
164162
<th *ngIf="model.hasExpandableRows()"></th>
165163
<th *ngIf="showSelectionColumn">
166164
<ibm-checkbox
167-
[size]="size !== 'lg' ? 'sm' : 'md'"
165+
[size]="size !== ('lg' ? 'sm' : 'md')"
168166
[(ngModel)]="selectAllCheckbox"
169167
[indeterminate]="selectAllCheckboxSomeSelected"
168+
aria-label="Select all rows"
170169
(change)="onSelectAllCheckboxChange()">
171170
</ibm-checkbox>
172171
</th>
@@ -303,6 +302,7 @@ const EN = require("./../i18n/en.json");
303302
</td>
304303
<td *ngIf="showSelectionColumn">
305304
<ibm-checkbox
305+
aria-label="Select row"
306306
[size]="size !== ('lg' ? 'sm' : 'md')"
307307
[(ngModel)]="model.rowsSelected[i]"
308308
(change)="onRowCheckboxChange(i)">
@@ -387,7 +387,7 @@ export class Table {
387387
/**
388388
* Controls whether to show the selection checkboxes column or not.
389389
*
390-
* @deprecated in the next major neutrino version in favour of
390+
* @deprecated in the next major carbon-components-angular version in favour of
391391
* `showSelectionColumn` because of new attribute `enableSingleSelect`
392392
* please use `showSelectionColumn` instead
393393
*/

0 commit comments

Comments
 (0)