Skip to content

Commit

Permalink
Release version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
awendland committed Jan 9, 2019
1 parent 212bbe4 commit 1338302
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!README.md
!package.json
!LICENSE
!bower.json
!dist/*
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ A live implementation of this directive can be found at [https://awendland.githu

**Requirements:** AngularJS 1.2+

**File Size:** v1.0.1
**File Size:** v1.1.0

* **JS**: 8.3Kb raw, 2.3Kb minified, 982b gzipped
* **JS + CSS**: 9.6Kb raw, 3.3Kb minified, 1.42Kb gzipped
* **JS**: 9.15kB raw, 2.56kB minified, 1.04kB gzipped
* **JS + CSS**: 10.28kB raw, 3.69kB minified, 1.53kB gzipped

## Usage:

Expand Down Expand Up @@ -72,6 +72,8 @@ This is an optional attribute that designates if the tree's root should display
<json-tree object="someobj" start-expanded="true"></json-tree>
```

Besides `true` or `false`, you can also set it to `'recursive'` to cause the entire tree to be expanded initially (instead of just the top level if `true` was used).

### root-name [optional, default='Object']

This is an optional attribute that sets the title displayed at the root node. This is useful when you are showing sub-portions of an object or want the object root node to have a different string than 'Object'.
Expand Down Expand Up @@ -122,6 +124,8 @@ The expanded state is different and contains further subnodes that are generated
```
The `.expandable` class adds several features to the normal `json-node` element. Particularly, by the default looks CSS, a carrot-style toggle pseudo-element will be created. This `::before` element will rotate 90 deg downward when the element is expanded.

Furthermore, if an `.expandable` element does not have any children, then `.empty` will be added to the class list as well. This can be used to remove any expansion UI from nodes representing empty objects/arrays.

Additionally, `json-node` elements receive a class corresponding to their object type. For example, the `.array` class or `.object` may be placed on a `json-node`. These classes can be used for special stylings.

## Further Explanation:
Expand All @@ -130,6 +134,15 @@ An example implementation of this project can be found at the [gh-pages branch](

## Changelog

#### v1.1.0
* Set *angular* as a peer dependency instead of as a normal dependency (allowing for better user control of the *angular* version) ([Issue #52](https://github.com/awendland/angular-json-tree/issues/52))
* Add `start-expanded="'recursive'"` to cause the entire tree to be expanded initially (instead of just the top-level, which setting the value to `true` previously allowed) ([Issue #56](https://github.com/awendland/angular-json-tree/issues/56))
* Add `track by` to remove `$$hashKey` attributes ([Issue #59](https://github.com/awendland/angular-json-tree/issues/59), [PR #60](https://github.com/awendland/angular-json-tree/pull/60))
* Add `.empty` to the class list of nodes that are expandable but have no children ([Issue #63](https://github.com/awendland/angular-json-tree/issues/63))

#### v1.0.1
* Remove css files from the `main` entry in package.json.

#### v1.0.0
* Update *npm* dev dependencies to latest (as of 2016-05-24) and remove unnecessary ones
* Update *angular* dependency to accept all 1.x versions
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-json-tree",
"version": "1.0.1",
"version": "1.1.0",
"description": "Angular directive for displaying a JSON object in an expandable tree structure",
"main": [
"dist/angular-json-tree.js",
Expand Down
12 changes: 11 additions & 1 deletion dist/angular-json-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ angular.module('angular-json-tree', ['ajs.RecursiveDirectiveHelper'])
' <span class="leaf-value" ng-if="!isExpandable">{{value}}</span>' +
' <span class="branch-preview" ng-if="isExpandable" ng-show="!isExpanded" ng-click="toggleExpanded()">{{preview}}</span>' +
' <ul class="branch-value" ng-if="isExpandable && shouldRender" ng-show="isExpanded">' +
' <li ng-repeat="(subkey,subval) in value">' +
' <li ng-repeat="(subkey,subval) in value track by subkey">' +
' <json-node key="subkey" value="subval"></json-node>' +
' </li>' +
' </ul>',
Expand All @@ -112,6 +112,10 @@ angular.module('angular-json-tree', ['ajs.RecursiveDirectiveHelper'])
scope.isExpandable = true;
// Add expandable class for CSS usage
elem.addClass('expandable');
// Add a class indicating an empty Object/Array (for removing expandable UI, if desired)
if (Object.keys(scope.value).length < 1) {
elem.addClass('empty');
}
// Setup preview text
var isArray = utils.is(scope.value, 'Array');
scope.preview = isArray ? '[ ' : '{ ';
Expand All @@ -123,13 +127,19 @@ angular.module('angular-json-tree', ['ajs.RecursiveDirectiveHelper'])
}
});
scope.preview = scope.preview.substring(0, scope.preview.length - (scope.preview.length > 2 ? 2 : 0)) + (isArray ? ' ]' : ' }');
// If parent directive has startExpanded set to recursive, inherit startExpanded
if (scope.$parent && scope.$parent.startExpanded &&
scope.$parent.startExpanded() == 'recursive') {
scope.startExpanded = scope.$parent.startExpanded;
}
// If directive initially has isExpanded set, also set shouldRender to true
if (scope.startExpanded && scope.startExpanded()) {
scope.shouldRender = true;
elem.addClass('expanded');
}
// Setup isExpanded state handling
scope.isExpanded = scope.startExpanded ? scope.startExpanded() : false;
if (scope.isExpanded == 'recursive') scope.isExpanded = true;
scope.toggleExpanded = function jsonNodeDirectiveToggleExpanded() {
scope.isExpanded = !scope.isExpanded;
if (scope.isExpanded) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-json-tree.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-json-tree",
"version": "1.0.1",
"version": "1.1.0",
"description": "Angular directive for displaying a JSON object in an expandable tree structure",
"main": "dist/angular-json-tree.js",
"directories": {
Expand Down

0 comments on commit 1338302

Please sign in to comment.