Skip to content

Commit 4f8e9d6

Browse files
committed
Added yarn file
Fixed lint errors Not mandatory to supply getChildren method Calling 'closest' using invokeElementMethod Removed onActiveChanged method Added 3rd party licenses
1 parent cfdc20a commit 4f8e9d6

File tree

9 files changed

+919
-17
lines changed

9 files changed

+919
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<a name="2.8.2"></a>
2+
# 2.8.2 (2017-02-21)
3+
* Added yarn file
4+
* Fixed lint errors
5+
* Not mandatory to supply getChildren method
6+
* Calling 'closest' using invokeElementMethod
7+
* Removed onActiveChanged method
8+
* Added 3rd party licenses
9+
110
<a name="2.8.1"></a>
211
# 2.8.1 (2017-02-09)
312
* Added UMD bundle

THIRD_PARTY_LICENSES

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
* https://github.com/ayamflow/virtual-scroll/
2+
// The MIT License (MIT)
3+
4+
// Copyright (c) 2014 Florian Morel
5+
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.

lib/components/tree-node-content.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Component, Input, TemplateRef } from '@angular/core';
1+
import { Component, Input, ViewEncapsulation, TemplateRef } from '@angular/core';
22
import { TreeNode } from '../models/tree-node.model';
33

44
@Component({
55
selector: 'TreeNodeContent',
6+
encapsulation: ViewEncapsulation.None,
67
template: `<span *ngIf="!template">{{ node.displayField }}</span>
78
<template
89
[ngTemplateOutlet]="template"

lib/components/tree.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
Component, Input, Output, OnChanges, SimpleChange, EventEmitter,
3-
ViewEncapsulation, ContentChild, TemplateRef, HostListener
3+
ViewEncapsulation, ContentChild, TemplateRef, HostListener, Renderer
44
} from '@angular/core';
55
import { TreeModel } from '../models/tree.model';
66
import { TreeDraggedElement } from '../models/tree-dragged-element.model';
@@ -66,7 +66,6 @@ export class TreeComponent implements OnChanges {
6666

6767
@Output() onToggle;
6868
@Output() onToggleExpanded;
69-
@Output() onActiveChanged;
7069
@Output() onActivate;
7170
@Output() onDeactivate;
7271
@Output() onFocus;
@@ -78,7 +77,11 @@ export class TreeComponent implements OnChanges {
7877
@Output() onMoveNode;
7978
@Output() onEvent;
8079

81-
constructor(public treeModel: TreeModel, public treeDraggedElement: TreeDraggedElement) {
80+
constructor(
81+
public treeModel: TreeModel,
82+
public treeDraggedElement: TreeDraggedElement,
83+
private renderer: Renderer) {
84+
8285
treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
8386
}
8487

@@ -95,7 +98,8 @@ export class TreeComponent implements OnChanges {
9598

9699
@HostListener('body: mousedown', ['$event'])
97100
onMousedown($event) {
98-
let insideClick = $event.target.closest('Tree');
101+
const insideClick = this.renderer.invokeElementMethod($event.target, 'closest', ['Tree']);
102+
99103
if (!insideClick) {
100104
this.treeModel.setFocus(false);
101105
}

lib/constants/events.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export const TREE_EVENTS = {
22
onToggle: 'onToggle',
33
onToggleExpanded: 'onToggleExpanded',
4-
onActiveChanged: 'onActiveChanged',
54
onActivate: 'onActivate',
65
onDeactivate: 'onDeactivate',
76
onFocus: 'onFocus',

lib/models/tree-node.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class TreeNode implements ITreeNode {
160160
// helper methods:
161161
loadChildren() {
162162
if (!this.options.getChildren) {
163-
throw new Error('Node doesn\'t have children, or a getChildren method');
163+
return Promise.resolve(); // Not getChildren method - for using redux
164164
}
165165
return Promise.resolve(this.options.getChildren(this))
166166
.then((children) => {

package.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-tree-component",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "A simple yet powerful tree component for Angular2",
55
"author": "Adam Klein <adam@500tech.com>",
66
"homepage": "https://github.com/500tech/angular2-tree-component",
@@ -24,7 +24,7 @@
2424
"lint": "tslint lib/**/*.ts",
2525
"rollup": "rollup -c rollup.config.js dist/angular2-tree-component.js > dist/angular2-tree-component.umd.js",
2626
"build": "npm run lint && npm run clean:typescript && ngc && npm run rollup",
27-
"example:cli": "npm run build && cp -rf dist example/cli/node_modules/angular2-tree-component/ && cd example/cli && ng serve",
27+
"example:cli": "ngc && cp -rf dist example/cli/node_modules/angular2-tree-component/ && cd example/cli && ng serve",
2828
"example:cli:build": "cd example/cli && ng build --aot"
2929
},
3030
"files": [
@@ -35,8 +35,8 @@
3535
"Adam Klein <adam@500tech.com>"
3636
],
3737
"peerDependencies": {
38-
"@angular/core": "^2.0.0",
39-
"@angular/common": "^2.0.0"
38+
"@angular/common": "^2.0.0",
39+
"@angular/core": "^2.0.0"
4040
},
4141
"dependencies": {
4242
"lodash": "^4.6.1",
@@ -53,25 +53,22 @@
5353
"@angular/platform-browser-dynamic": "^2.3.0",
5454
"@angular/platform-server": "^2.3.0",
5555
"@types/jasmine": "2.5.38",
56-
"@types/lodash": "4.14.40",
56+
"@types/lodash": "^4.14.52",
5757
"@types/node": "^6.0.38",
5858
"@types/rx": "2.5.34",
5959
"@types/webpack": "^1.12.29",
6060
"codelyzer": "2.0.0-beta.4",
6161
"core-js": "^2.4.0",
6262
"lodash": "^4.6.1",
6363
"rimraf": "^2.5.1",
64-
"rollup": "0.41.4",
64+
"rollup": "^0.41.4",
6565
"rxjs": "^5.0.0",
6666
"tslint": "4.4.2",
6767
"typedoc": "^0.3.12",
6868
"typescript": "^2.1.4",
6969
"zone.js": "^0.7.2"
7070
},
71-
"repository": {
72-
"type": "git",
73-
"url": "https://github.com/500tech/angular2-tree-component.git"
74-
},
71+
"repository": "https://github.com/500tech/angular2-tree-component.git",
7572
"bugs": {
7673
"url": "https://github.com/500tech/angular2-tree-component/issues"
7774
},

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"inlineSourceMap": true,
1010
"inlineSources": true,
1111
"declaration": true,
12+
"skipLibCheck": true,
1213
"lib": ["es2015", "dom"]
1314
},
1415
"files": [

0 commit comments

Comments
 (0)