Skip to content

Commit fe9bb16

Browse files
committed
Merge branch 'master' of https://github.com/IBM/carbon-components-angular into radio
2 parents ce5e7e9 + 0145ae1 commit fe9bb16

31 files changed

+3664
-1517
lines changed

.storybook/manager-head.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
<!-- Open Graph -->
12
<meta property="og:title" content="Carbon Components Angular">
23
<meta property="og:description" content="An Angular implementation of the Carbon Design System for IBM.">
34
<meta property="og:image" content="https://angular.carbondesignsystem.com/carbon.jpg">
45
<meta property="og:url" content="https://angular.carbondesignsystem.com">
56

7+
<!-- Social -->
68
<meta name="twitter:title" content="Carbon Components Angular">
79
<meta name="twitter:description" content="An Angular implementation of the Carbon Design System for IBM.">
810
<meta name="twitter:image" content="https://angular.carbondesignsystem.com/carbon.jpg">
911
<meta name="twitter:card" content="summary_large_image">
1012

13+
<!-- Storybook override -->
14+
<script>
15+
document.title = "Carbon Components Angular";
16+
</script>
17+
1118
<style id="iframestyle">
1219
.sb-show-main:not(.welcome) {
1320
padding: 3em;

.storybook/webpack.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22

3-
module.exports = (baseConfig, env, defaultConfig) => {
4-
defaultConfig.module.rules.push({
3+
module.exports = ({config, mode}) => {
4+
config.module.rules.push({
55
test: [/\.stories\.tsx?$/, /index\.ts$/],
66
loaders: [
77
{
@@ -15,7 +15,7 @@ module.exports = (baseConfig, env, defaultConfig) => {
1515
enforce: 'pre',
1616
});
1717

18-
defaultConfig.mode = "development";
19-
defaultConfig.devtool = "source-map";
20-
return defaultConfig;
18+
config.mode = "development";
19+
config.devtool = "source-map";
20+
return config;
2121
};

package-lock.json

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

package.json

Lines changed: 10 additions & 10 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": "4.0.6",
90-
"@storybook/addon-knobs": "4.0.6",
91-
"@storybook/addon-links": "4.0.6",
92-
"@storybook/addon-notes": "4.0.6",
93-
"@storybook/addon-options": "4.1.4",
94-
"@storybook/addon-storysource": "4.1.2",
95-
"@storybook/addons": "4.0.6",
96-
"@storybook/angular": "4.0.6",
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",
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.70.3",
101+
"carbon-components": "9.82.17",
102102
"codelyzer": "4.5.0",
103103
"commitizen": "2.10.1",
104104
"core-js": "2.5.5",
@@ -148,6 +148,6 @@
148148
},
149149
"dependencies": {
150150
"flatpickr": "4.5.2",
151-
"ng2-flatpickr": "7.0.1"
151+
"ng2-flatpickr": "7.0.2"
152152
}
153153
}

src/combobox/combobox.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { AbstractDropdownView } from "./../dropdown/abstract-dropdown-view.class";
1717
import { ListItem } from "./../dropdown/list-item.interface";
1818
import { NG_VALUE_ACCESSOR } from "@angular/forms";
19+
import { filter } from "rxjs/operators";
1920

2021
/**
2122
* ComboBoxes are similar to dropdowns, except a combobox provides an input field for users to search items and (optionally) add their own.
@@ -262,6 +263,10 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
262263
setTimeout(() => {
263264
this.updateSelected();
264265
});
266+
267+
this.view.blurIntent.pipe(filter(v => v === "top")).subscribe(() => {
268+
this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
269+
});
265270
}
266271
}
267272

@@ -291,10 +296,6 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
291296
ev.stopPropagation();
292297
this.openDropdown();
293298
setTimeout(() => this.view.getCurrentElement().focus(), 0);
294-
} else if ((ev.key === "ArrowUp" || ev.key === "Up") // `"Up"` is IE specific value
295-
&& this.dropdownMenu.nativeElement.contains(ev.target)
296-
&& !this.view.hasPrevElement()) {
297-
this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
298299
}
299300
}
300301

src/dialog/dialog.directive.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
8787
/**
8888
* Config object passed to the rendered component
8989
*/
90-
@Output() onClose: EventEmitter<any> = new EventEmitter<any>();
9190
dialogConfig: DialogConfig;
91+
/**
92+
* Emits an event when the dialog is closed
93+
*/
94+
@Output() onClose: EventEmitter<any> = new EventEmitter();
95+
/**
96+
* Emits an event when the dialog is opened
97+
*/
98+
@Output() onOpen: EventEmitter<any> = new EventEmitter();
9299

93100
@HostBinding("attr.role") role = "button";
94101
@HostBinding("attr.aria-expanded") expanded = false;
@@ -197,6 +204,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
197204
open() {
198205
this.dialogService.open(this.viewContainerRef, this.dialogConfig);
199206
this.expanded = true;
207+
this.onOpen.emit();
200208
}
201209

202210
/**
@@ -206,6 +214,9 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
206214
toggle() {
207215
this.dialogService.toggle(this.viewContainerRef, this.dialogConfig);
208216
this.expanded = this.dialogService.isOpen;
217+
if (this.expanded) {
218+
this.onOpen.emit();
219+
}
209220
}
210221

211222
/**

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

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
Input,
55
ElementRef,
66
Output,
7-
EventEmitter
7+
EventEmitter,
8+
AfterViewInit
89
} from "@angular/core";
910

1011
/**
@@ -17,7 +18,7 @@ import {
1718
* <ibm-overflow-menu-option type="danger">Danger option</ibm-overflow-menu-option>
1819
* ```
1920
*
20-
* For content that expands beyod the overflow menu `OverflowMenuOption` automatically adds a title attribute.
21+
* For content that expands beyond the overflow menu `OverflowMenuOption` automatically adds a title attribute.
2122
*/
2223
@Component({
2324
selector: "ibm-overflow-menu-option",
@@ -30,12 +31,12 @@ import {
3031
(blur)="tabIndex = -1"
3132
(click)="onClick($event)"
3233
[disabled]="disabled"
33-
[title]="(titleEnabled ? content : '')">
34+
[title]="title">
3435
<ng-content></ng-content>
3536
</button>
3637
`
3738
})
38-
export class OverflowMenuOption {
39+
export class OverflowMenuOption implements AfterViewInit {
3940
@HostBinding("class") optionClass = "bx--overflow-menu-options__option";
4041
@HostBinding("attr.role") role = "presentation";
4142

@@ -60,30 +61,20 @@ export class OverflowMenuOption {
6061
@Output() selected: EventEmitter<any> = new EventEmitter();
6162

6263
public tabIndex = -1;
64+
// note: title must be a real attribute (i.e. not a getter) as of Angular@6 due to
65+
// change after checked errors
66+
public title = null;
6367

6468
constructor(protected elementRef: ElementRef) {}
6569

6670
onClick(event) {
6771
this.selected.emit();
6872
}
6973

70-
/**
71-
* Returns true if the content string is longer than the width of the containing button
72-
*
73-
* note: getter ties into the view check cycle so we always get an accurate value
74-
*/
75-
get titleEnabled() {
74+
ngAfterViewInit() {
7675
const button = this.elementRef.nativeElement.querySelector("button");
7776
if (button.scrollWidth > button.offsetWidth) {
78-
return true;
77+
this.title = this.elementRef.nativeElement.querySelector("button").textContent;
7978
}
80-
return false;
81-
}
82-
83-
/**
84-
* Returns the text content projected into the component
85-
*/
86-
get content(): string {
87-
return this.elementRef.nativeElement.querySelector("button").textContent;
8879
}
8980
}

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import {
22
Component,
33
ElementRef,
44
Input,
5-
ViewEncapsulation
5+
ViewEncapsulation,
6+
ContentChild
67
} from "@angular/core";
78
import { I18n } from "./../../i18n/i18n.module";
9+
import { OverflowMenuDirective } from "./overflow-menu.directive";
810

911
/**
1012
* The OverFlow menu component encapsulates the OverFlowMenu directive, and the menu iconography into one convienent component
@@ -22,9 +24,11 @@ import { I18n } from "./../../i18n/i18n.module";
2224
template: `
2325
<div
2426
[ibmOverflowMenu]="options"
25-
[ngClass]="{'bx--overflow-menu--open': open === true}"
27+
[ngClass]="{'bx--overflow-menu--open': open}"
2628
[attr.aria-label]="buttonLabel"
2729
[flip]="flip"
30+
(onOpen)="open = true"
31+
(onClose)="open = false"
2832
role="button"
2933
aria-haspopup="true"
3034
class="bx--overflow-menu"
@@ -67,12 +71,9 @@ export class OverflowMenu {
6771

6872
@Input() flip = false;
6973

70-
constructor(protected elementRef: ElementRef, protected i18n: I18n) {}
74+
@ContentChild(OverflowMenuDirective) overflowMenuDirective: OverflowMenuDirective;
7175

72-
get open() {
73-
if (this.elementRef.nativeElement.children[0].getAttribute("aria-expanded") === "true") {
74-
return true;
75-
}
76-
return false;
77-
}
76+
open = false;
77+
78+
constructor(protected elementRef: ElementRef, protected i18n: I18n) {}
7879
}

src/dropdown/abstract-dropdown-view.class.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ export class AbstractDropdownView {
1919
* Emits selection events to other class.
2020
*/
2121
@Output() select: EventEmitter<Object>;
22+
/**
23+
* Event to suggest a blur on the view.
24+
* Emits _after_ the first/last item has been focused.
25+
* ex.
26+
* ArrowUp -> focus first item
27+
* ArrowUp -> emit event
28+
*
29+
* It's recommended that the implementing view include a specific type union of possible blurs
30+
* ex. `@Output() blurIntent = new EventEmitter<"top" | "bottom">();`
31+
*/
32+
@Output() blurIntent: EventEmitter<any>;
2233
/**
2334
* Specifies whether or not the `DropdownList` supports selecting multiple items as opposed to single
2435
* item selection.

src/dropdown/dropdown.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { DropdownList } from "./list/dropdown-list.component";
88
import { ListItem } from "./list-item.interface";
99
import { ScrollableList } from "./scrollable-list.directive";
1010
import { I18nModule } from "../i18n/i18n.module";
11+
import { DropdownService } from "./dropdown.service";
12+
import { PlaceholderModule } from "./../placeholder/placeholder.module";
1113

1214
@Component({
1315
template: `
@@ -38,8 +40,10 @@ describe("Dropdown", () => {
3840
],
3941
imports: [
4042
StaticIconModule,
41-
I18nModule
42-
]
43+
I18nModule,
44+
PlaceholderModule
45+
],
46+
providers: [ DropdownService ]
4347
});
4448
});
4549

0 commit comments

Comments
 (0)