Skip to content

Commit 8cabf64

Browse files
authored
Merge pull request #18 from edcarroll/develop
v0.4.2 into master
2 parents cb7efc0 + 3e95edc commit 8cabf64

File tree

9 files changed

+67
-45
lines changed

9 files changed

+67
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Now you're good to go!
4444

4545
## Dependencies
4646

47-
* [Angular 2](https://angular.io) (2.0.0-rc.7)
47+
* [Angular 2](https://angular.io) (^2.0.0 final)
4848
* [Semantic UI CSS](http://semantic-ui.com/) (jQuery is **not** required)
4949

5050
## Components

components/select/select.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class SuiSelect implements AfterContentInit, AfterViewInit {
212212
this._dropdownService.isOpen = false;
213213
this.renderSelectedItem();
214214

215-
this._searchService.updateQuery("");
215+
this._searchService.updateQuery("", false)
216216
}
217217

218218
private focusSearch() {
@@ -229,11 +229,10 @@ export class SuiSelect implements AfterContentInit, AfterViewInit {
229229
}
230230

231231
public writeValue(value:any) {
232-
if (value) {
232+
if (value !== null && value !== undefined) {
233233
this.selectedOption = value;
234234
if (this.options.length > 0) {
235-
let compareValue = this._searchService.deepValue(value, this.keyField);
236-
this.selectedOption = this.options.find(o => compareValue == o);
235+
this.selectedOption = this.options.find(o => value == this._searchService.deepValue(o, this.keyField));
237236
}
238237
}
239238
this.renderSelectedItem();

components/tabs/tab.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export class SuiTab {
1414
}
1515
}
1616

17+
public index:number;
18+
1719
private _content:SuiTabContent;
1820

1921
public set content(content:SuiTabContent) {
@@ -27,7 +29,10 @@ export class SuiTab {
2729
private _stateObserver: Observer<SuiTab>;
2830

2931
constructor() {
30-
this.stateChanged$ = new Observable<SuiTab>((observer:any) => this._stateObserver = observer);
32+
this.stateChanged$ = new Observable<SuiTab>((observer:any) => {
33+
this._stateObserver = observer;
34+
this._stateObserver.next(this);
35+
});
3136
}
3237

3338
private _isActive:boolean = false;
@@ -39,7 +44,9 @@ export class SuiTab {
3944
public set isActive(value:boolean) {
4045
var change = this._isActive != value;
4146
this._isActive = value;
42-
this._content.isActive = value;
47+
if (this._content) {
48+
this._content.isActive = value;
49+
}
4350
this.stateObserverNext(change);
4451
this.isActiveChange.emit(this._isActive);
4552

@@ -62,7 +69,7 @@ export class SuiTab {
6269
}
6370

6471
private stateObserverNext(change:boolean) {
65-
if (change) {
72+
if (change && this._stateObserver) {
6673
this._stateObserver.next(this);
6774
}
6875
}

components/tabs/tabset.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class SuiTabset implements AfterContentInit {
2929

3030
this._tabs.changes.subscribe(tabHeaders => {
3131
setTimeout(() => {
32-
this.loadTabs()
32+
this.loadTabs();
3333
});
3434
});
3535
}
@@ -41,7 +41,7 @@ export class SuiTabset implements AfterContentInit {
4141
throw new Error("You cannot have no tabs!");
4242
}
4343
//For every content header we have managed to find,
44-
this._loadedTabs.forEach((t:SuiTab) => {
44+
this._loadedTabs.forEach((t:SuiTab, i:number) => {
4545
//Assuming they have an associated content
4646
if (!t.content) {
4747
//Link the content header with the content with the same ID excluding ones that are already linked
@@ -56,6 +56,8 @@ export class SuiTabset implements AfterContentInit {
5656
t.content = possibleContents.pop();
5757
}
5858

59+
t.index = i;
60+
5961
//Next observe the content's state to catch any changes made anywhere
6062
t.stateChanged$.subscribe((t:SuiTab) => this.tabStateChanged(t));
6163
});
@@ -81,8 +83,8 @@ export class SuiTabset implements AfterContentInit {
8183
this._activeTab = tab;
8284
}
8385
//Otherwise check there are no active tabs
84-
else if (this._activeTab && !this._loadedTabs.filter((tH:SuiTab) => tH.isActive).length) {
85-
this.activateClosestTab(tab);
86+
else if (this._activeTab && !this._loadedTabs.find((tH:SuiTab) => tH.isActive)) {
87+
this.activateClosestTab(this._activeTab);
8688
}
8789

8890
//Check if the content is now disabled, and if so if is currently active
@@ -114,13 +116,14 @@ export class SuiTabset implements AfterContentInit {
114116
private activateClosestTab(tab:SuiTab) {
115117
//Grab a list of all of the loaded tabs that aren't disabled (excluding the one we are leaving)
116118
var availableTabs = this._loadedTabs
117-
.filter((tH:SuiTab) => !tH.isDisabled || tH == tab);
119+
.filter((tH:SuiTab) => !tH.isDisabled);
118120

119-
var tabIndex = availableTabs
120-
.findIndex((tH:SuiTab) => tH == tab);
121+
var tabIndex = tab.index;
121122

122-
//Go to the previous content, unless it is the 1st content.
123-
tabIndex += (tabIndex ? -1 : 1);
123+
// Only change the tabIndex if we have to.
124+
if (tabIndex >= availableTabs.length) {
125+
tabIndex = availableTabs.length - 1;
126+
}
124127

125128
availableTabs[tabIndex].isActive = true;
126129
//This if we just activated a disabled content, not to worry as it will bubble through

components/transition/transition.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import {Directive, HostBinding, ElementRef, AfterViewInit, Renderer} from "@angu
22

33
export interface ISuiAnimation {
44
name:string;
5-
classes?:string[];
65
duration?:number;
7-
static?:boolean;
86
display?:string;
97
direction?:string;
108
callback?:() => any;
119
}
1210

11+
interface ISuiConfiguredAnimation extends ISuiAnimation {
12+
classes?:string[];
13+
static?:boolean;
14+
}
15+
1316
@Directive({
1417
selector: '[suiTransition]',
1518
exportAs: 'transition'
@@ -37,7 +40,7 @@ export class SuiTransition {
3740
this.renderer.setElementClass(this.el.nativeElement, "animating", value);
3841
}
3942

40-
private animationTimeout:number;
43+
private animationTimeout:any;
4144

4245
private _isVisible = null;
4346

@@ -62,33 +65,40 @@ export class SuiTransition {
6265
this.renderer.setElementClass(this.el.nativeElement, "hidden", value);
6366
}
6467

65-
private queue:ISuiAnimation[] = [];
68+
private queue:ISuiConfiguredAnimation[] = [];
6669

6770
private queueFirst() {
6871
return this.queue.slice(0, 1).pop();
6972
}
7073

74+
private queueLast() {
75+
return this.queue.slice(-1).pop();
76+
}
77+
7178
public animate(animation:ISuiAnimation) {
7279
animation = Object.assign({}, animation);
73-
animation.classes = animation.name.split(" ");
74-
if (!animation.duration) {
75-
animation.duration = 250;
80+
let anim = animation as ISuiConfiguredAnimation;
81+
82+
anim.classes = animation.name.split(" ");
83+
if (!anim.duration) {
84+
anim.duration = 250;
7685
}
77-
if (!animation.display) {
78-
animation.display = 'block';
86+
if (!anim.display) {
87+
anim.display = 'block';
7988
}
80-
if (!animation.static) {
81-
animation.static = ["jiggle", "flash", "shake", "pulse", "tada", "bounce"].indexOf(animation.name) != -1;
89+
if (!anim.static) {
90+
anim.static = ["jiggle", "flash", "shake", "pulse", "tada", "bounce"].indexOf(anim.name) != -1;
8291
}
83-
if (!animation.direction) {
84-
animation.direction = this.isVisible ? "out" : "in";
85-
let queueLast = this.queueFirst();
92+
if (!anim.direction) {
93+
anim.direction = this.isVisible ? "out" : "in";
94+
let queueLast = this.queueLast();
8695
if (queueLast) {
87-
animation.direction = queueLast.direction == "in" ? "out" : "in"
96+
anim.direction = queueLast.direction == "in" ? "out" : "in"
8897
}
8998
}
9099

91100
this.queue.push(animation);
101+
92102
this.performAnimation();
93103
}
94104

@@ -115,7 +125,7 @@ export class SuiTransition {
115125
this.animationTimeout = setTimeout(() => this.finishAnimation(animation), animation.duration);
116126
}
117127

118-
private finishAnimation(animation:ISuiAnimation) {
128+
private finishAnimation(animation:ISuiConfiguredAnimation) {
119129
this.isAnimating = false;
120130
animation.classes.forEach(c => this.renderer.setElementClass(this.el.nativeElement, c, false));
121131
this.renderer.setElementClass(this.el.nativeElement, animation.direction, false);

demo/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="sidebar">
33
<div class="ui vertical inverted fluid menu">
44
<div class="item">
5-
<a class="ui mini images" href="/">
5+
<a class="ui mini images">
66
<img class="ui image" src="http://semantic-ui.com/images/logo.png">
77
<img class="ui image" src="https://angular.io/resources/images/logos/standard/shield-large.png">
88
</a>

demo/app/pages/getting-started/getting-started.page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h2 class="ui dividing header">Installation</h2>
3030
<p>Now you're good to go!</p>
3131
<h2 class="ui dividing header">Dependencies</h2>
3232
<div class="ui bulleted list">
33-
<div class="item"><a href="https://angular.io">Angular 2</a> (2.0.0-rc.5 <strong>or higher</strong>)</div>
33+
<div class="item"><a href="https://angular.io">Angular 2</a> (^2.0.0 final)</div>
3434
<div class="item"><a href="http://semantic-ui.com/">Semantic UI CSS</a> (jQuery is <strong>not</strong> required)</div>
3535
</div>
3636
</div>

demo/app/pages/tabs/tabs.page.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class TabsPage {
9292
<sui-tabset>
9393
<div class="ui top attached tabular menu">
9494
<a class="item" suiTabHeader="static">Static</a>
95-
<a class="item" *ngFor="let tab of tabs; let i = index" [suiTabHeader]="i">{{ tab.header }}</a>
95+
<a class="item" *ngFor="let tab of tabs; let i = index" [suiTabHeader]="i" [(isActive)]="active[i]">{{ tab.header }}</a>
9696
</div>
9797
<div class="ui bottom attached segment" *ngFor="let tab of tabs; let i = index" [suiTabContent]="i">{{ tab.content }}</div>
9898
<div class="ui bottom attached segment" suiTabContent="static">
@@ -149,18 +149,21 @@ export class TabExampleProperties {
149149
template: new TabsPage().exampleDynamicTemplate
150150
})
151151
export class TabExampleDynamic {
152+
public active:boolean[] = [];
152153
public tabs = [
153154
{ header: "1st", content: "Dynamic content" },
154155
{ header: "2nd", content: "More content" },
155156
{ header: "3rd", content: "Even more content" }
156157
];
157158
public addTab() {
159+
this.active.push(true);
158160
this.tabs.push({
159161
header: "New",
160162
content: "Another dynamic tab"
161163
});
162164
};
163165
public removeTab() {
166+
this.active.pop();
164167
this.tabs.pop();
165168
}
166169
}

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ng2-semantic-ui",
33
"main": "ng2-semantic-ui.js",
44
"typings": "ng2-semantic-ui.d.ts",
5-
"version": "0.4.0",
5+
"version": "0.4.2",
66
"description": "Angular 2 Semantic UI Components",
77
"repository": {
88
"type": "git",
@@ -30,14 +30,14 @@
3030
"prepublish": "tsc"
3131
},
3232
"dependencies": {
33-
"@angular/common": "^2.0.0-rc.7",
34-
"@angular/compiler": "^2.0.0-rc.7",
35-
"@angular/core": "^2.0.0-rc.7",
36-
"@angular/forms": "^2.0.0-rc.7",
37-
"@angular/http": "^2.0.0-rc.7",
38-
"@angular/platform-browser": "^2.0.0-rc.7",
39-
"@angular/platform-browser-dynamic": "^2.0.0-rc.7",
40-
"@angular/router": "^3.0.0-rc.3",
33+
"@angular/common": "^2.0.0",
34+
"@angular/compiler": "^2.0.0",
35+
"@angular/core": "^2.0.0",
36+
"@angular/forms": "^2.0.0",
37+
"@angular/http": "^2.0.0",
38+
"@angular/platform-browser": "^2.0.0",
39+
"@angular/platform-browser-dynamic": "^2.0.0",
40+
"@angular/router": "^3.0.0",
4141
"core-js": "^2.4.1",
4242
"reflect-metadata": "^0.1.3",
4343
"rxjs": "^5.0.0-beta.12",

0 commit comments

Comments
 (0)