Skip to content

Commit

Permalink
Added yarn file
Browse files Browse the repository at this point in the history
Fixed lint errors
Not mandatory to supply getChildren method
Calling 'closest' using invokeElementMethod
Removed onActiveChanged method
Added 3rd party licenses
  • Loading branch information
adamkleingit committed Feb 20, 2017
1 parent cfdc20a commit 4f8e9d6
Show file tree
Hide file tree
Showing 9 changed files with 919 additions and 17 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<a name="2.8.2"></a>
# 2.8.2 (2017-02-21)
* Added yarn file
* Fixed lint errors
* Not mandatory to supply getChildren method
* Calling 'closest' using invokeElementMethod
* Removed onActiveChanged method
* Added 3rd party licenses

<a name="2.8.1"></a>
# 2.8.1 (2017-02-09)
* Added UMD bundle
Expand Down
22 changes: 22 additions & 0 deletions THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
* https://github.com/ayamflow/virtual-scroll/
// The MIT License (MIT)

// Copyright (c) 2014 Florian Morel

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
3 changes: 2 additions & 1 deletion lib/components/tree-node-content.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, Input, TemplateRef } from '@angular/core';
import { Component, Input, ViewEncapsulation, TemplateRef } from '@angular/core';
import { TreeNode } from '../models/tree-node.model';

@Component({
selector: 'TreeNodeContent',
encapsulation: ViewEncapsulation.None,
template: `<span *ngIf="!template">{{ node.displayField }}</span>
<template
[ngTemplateOutlet]="template"
Expand Down
12 changes: 8 additions & 4 deletions lib/components/tree.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Component, Input, Output, OnChanges, SimpleChange, EventEmitter,
ViewEncapsulation, ContentChild, TemplateRef, HostListener
ViewEncapsulation, ContentChild, TemplateRef, HostListener, Renderer
} from '@angular/core';
import { TreeModel } from '../models/tree.model';
import { TreeDraggedElement } from '../models/tree-dragged-element.model';
Expand Down Expand Up @@ -66,7 +66,6 @@ export class TreeComponent implements OnChanges {

@Output() onToggle;
@Output() onToggleExpanded;
@Output() onActiveChanged;
@Output() onActivate;
@Output() onDeactivate;
@Output() onFocus;
Expand All @@ -78,7 +77,11 @@ export class TreeComponent implements OnChanges {
@Output() onMoveNode;
@Output() onEvent;

constructor(public treeModel: TreeModel, public treeDraggedElement: TreeDraggedElement) {
constructor(
public treeModel: TreeModel,
public treeDraggedElement: TreeDraggedElement,
private renderer: Renderer) {

treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
}

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

@HostListener('body: mousedown', ['$event'])
onMousedown($event) {
let insideClick = $event.target.closest('Tree');
const insideClick = this.renderer.invokeElementMethod($event.target, 'closest', ['Tree']);

if (!insideClick) {
this.treeModel.setFocus(false);
}
Expand Down
1 change: 0 additions & 1 deletion lib/constants/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export const TREE_EVENTS = {
onToggle: 'onToggle',
onToggleExpanded: 'onToggleExpanded',
onActiveChanged: 'onActiveChanged',
onActivate: 'onActivate',
onDeactivate: 'onDeactivate',
onFocus: 'onFocus',
Expand Down
2 changes: 1 addition & 1 deletion lib/models/tree-node.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class TreeNode implements ITreeNode {
// helper methods:
loadChildren() {
if (!this.options.getChildren) {
throw new Error('Node doesn\'t have children, or a getChildren method');
return Promise.resolve(); // Not getChildren method - for using redux
}
return Promise.resolve(this.options.getChildren(this))
.then((children) => {
Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular2-tree-component",
"version": "2.8.1",
"version": "2.8.2",
"description": "A simple yet powerful tree component for Angular2",
"author": "Adam Klein <[email protected]>",
"homepage": "https://github.com/500tech/angular2-tree-component",
Expand All @@ -24,7 +24,7 @@
"lint": "tslint lib/**/*.ts",
"rollup": "rollup -c rollup.config.js dist/angular2-tree-component.js > dist/angular2-tree-component.umd.js",
"build": "npm run lint && npm run clean:typescript && ngc && npm run rollup",
"example:cli": "npm run build && cp -rf dist example/cli/node_modules/angular2-tree-component/ && cd example/cli && ng serve",
"example:cli": "ngc && cp -rf dist example/cli/node_modules/angular2-tree-component/ && cd example/cli && ng serve",
"example:cli:build": "cd example/cli && ng build --aot"
},
"files": [
Expand All @@ -35,8 +35,8 @@
"Adam Klein <[email protected]>"
],
"peerDependencies": {
"@angular/core": "^2.0.0",
"@angular/common": "^2.0.0"
"@angular/common": "^2.0.0",
"@angular/core": "^2.0.0"
},
"dependencies": {
"lodash": "^4.6.1",
Expand All @@ -53,25 +53,22 @@
"@angular/platform-browser-dynamic": "^2.3.0",
"@angular/platform-server": "^2.3.0",
"@types/jasmine": "2.5.38",
"@types/lodash": "4.14.40",
"@types/lodash": "^4.14.52",
"@types/node": "^6.0.38",
"@types/rx": "2.5.34",
"@types/webpack": "^1.12.29",
"codelyzer": "2.0.0-beta.4",
"core-js": "^2.4.0",
"lodash": "^4.6.1",
"rimraf": "^2.5.1",
"rollup": "0.41.4",
"rollup": "^0.41.4",
"rxjs": "^5.0.0",
"tslint": "4.4.2",
"typedoc": "^0.3.12",
"typescript": "^2.1.4",
"zone.js": "^0.7.2"
},
"repository": {
"type": "git",
"url": "https://github.com/500tech/angular2-tree-component.git"
},
"repository": "https://github.com/500tech/angular2-tree-component.git",
"bugs": {
"url": "https://github.com/500tech/angular2-tree-component/issues"
},
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"inlineSourceMap": true,
"inlineSources": true,
"declaration": true,
"skipLibCheck": true,
"lib": ["es2015", "dom"]
},
"files": [
Expand Down
Loading

0 comments on commit 4f8e9d6

Please sign in to comment.