Skip to content

Commit 93d1d44

Browse files
committed
Merge branch 'master' of github.com:IBM/carbon-components-angular into tooltip-a11y
2 parents d831cc3 + 6e31536 commit 93d1d44

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

src/combobox/combobox.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
6767
class="bx--text-input"
6868
aria-label="ListBox input field"
6969
autocomplete="off"
70-
placeholder="Filter..."/>
70+
[placeholder]="placeholder"/>
7171
<div
7272
[ngClass]="{'bx--list-box__menu-icon--open': open}"
7373
class="bx--list-box__menu-icon">
@@ -132,7 +132,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
132132
* Text to show when nothing is selected.
133133
* @memberof ComboBox
134134
*/
135-
@Input() placeholder = "";
135+
@Input() placeholder = "Filter...";
136136
/**
137137
* Combo box type (supporting single or multi selection of items).
138138
* @type {("single" | "multi")}
@@ -351,6 +351,9 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
351351
});
352352
this.view["updateList"](this.items);
353353
this.updatePills();
354+
// clearSelected can only fire on type=multi
355+
// so we just emit getSelected() (just in case there's any disabled but selected items)
356+
this.selected.emit(this.view.getSelected() as any);
354357
}
355358

356359
/**

src/combobox/combobox.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ storiesOf("Combobox", module)
1616
.addDecorator(withKnobs)
1717
.add("Basic", () => ({
1818
template: `
19-
<ibm-combo-box [items]="items">
19+
<ibm-combo-box [items]="items" (selected)="selected($event)">
2020
<ibm-dropdown-list></ibm-dropdown-list>
2121
</ibm-combo-box>
2222
`,
@@ -40,7 +40,7 @@ storiesOf("Combobox", module)
4040
}))
4141
.add("Multi-select", () => ({
4242
template: `
43-
<ibm-combo-box [items]="items" type="multi">
43+
<ibm-combo-box [items]="items" type="multi" (selected)="selected($event)">
4444
<ibm-dropdown-list></ibm-dropdown-list>
4545
</ibm-combo-box>
4646
`,

src/table/table.component.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ import { getScrollbarWidth } from "../common/utils";
102102
*
103103
* See `TableHeaderItem` class for more information.
104104
*
105+
* ## No data template
106+
*
107+
* When table has no data to show, it can show a message you provide it instead.
108+
*
109+
* ```html
110+
* <ibm-table [model]="model">No data.</ibm-table>
111+
* ```
112+
*
113+
* ... will show `No data.` message, but you can get creative and provide any template you want
114+
* to replace table's default `tbody`.
115+
*
105116
* ## Use pagination as table footer
106117
*
107118
* ```html
@@ -269,6 +280,7 @@ import { getScrollbarWidth } from "../common/utils";
269280
</tr>
270281
</thead>
271282
<tbody
283+
*ngIf="!noData; else noDataTemplate"
272284
[ngStyle]="{'overflow-y': 'scroll'}"
273285
(scroll)="onScroll($event)">
274286
<ng-container *ngFor="let row of model.data; let i = index">
@@ -331,6 +343,7 @@ import { getScrollbarWidth } from "../common/utils";
331343
</tr>
332344
</ng-container>
333345
</tbody>
346+
<ng-template #noDataTemplate><ng-content></ng-content></ng-template>
334347
<tfoot>
335348
<tr *ngIf="this.model.isLoading">
336349
<td class="table_loading-indicator">
@@ -511,6 +524,12 @@ export class Table {
511524
*/
512525
@Output() scrollLoad = new EventEmitter<TableModel>();
513526

527+
get noData() {
528+
return !this.model.data ||
529+
this.model.data.length === 0 ||
530+
this.model.data.length === 1 && this.model.data[0].length === 0;
531+
}
532+
514533
private _model: TableModel;
515534

516535
private columnResizeWidth: number;

src/table/table.stories.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const en = require("./../../src/i18n/en.json");
4040
[showSelectionColumn]="showSelectionColumn"
4141
[striped]="striped"
4242
(sort)="simpleSort($event)">
43+
<ng-content></ng-content>
4344
</ibm-table>
4445
`
4546
})
@@ -429,6 +430,11 @@ simpleModel.header = [
429430
new TableHeaderItem({data: "Name"}), new TableHeaderItem({data: "hwer", style: {"width": "auto"} })
430431
];
431432

433+
const emptyModel = new TableModel();
434+
emptyModel.header = [
435+
new TableHeaderItem({data: "Name"}), new TableHeaderItem({data: "hwer", style: {"width": "auto"} })
436+
];
437+
432438
function sort(model, index: number) {
433439
if (model.header[index].sorted) {
434440
// if already sorted flip sorting direction
@@ -475,6 +481,30 @@ storiesOf("Table", module).addDecorator(
475481
sortable: boolean("sortable", true)
476482
}
477483
}))
484+
.add("with no data", () => ({
485+
template: `
486+
<app-table
487+
[model]="model"
488+
[size]="size"
489+
[showSelectionColumn]="showSelectionColumn"
490+
[striped]="striped">
491+
<tbody><tr><td class="no-data" colspan="3"><div>No data.</div></td></tr></tbody>
492+
</app-table>
493+
`,
494+
styles: [`
495+
.no-data {
496+
width: 100%;
497+
height: 150px;
498+
text-align: center;
499+
}
500+
`],
501+
props: {
502+
model: emptyModel,
503+
size: selectV2("size", {Small: "sm", Normal: "md", Large: "lg"}, "md", "table-size-selection"),
504+
showSelectionColumn: boolean("showSelectionColumn", true),
505+
striped: boolean("striped", true)
506+
}
507+
}))
478508
.add("with expansion", () => ({
479509
template: `
480510
<app-expansion-table

0 commit comments

Comments
 (0)