Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

treetabular

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

treetabular - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

5

CHANGELOG.md
## treetabular
3.4.0 / 2017-09-13
==================
* Fix - `tree.fixOrder` works with deeply nested data now. #13, #20
3.3.0 / 2017-03-14

@@ -4,0 +9,0 @@ ==================

38

dist/fix-order.js

@@ -15,2 +15,6 @@ 'use strict';

var _keys2 = require('lodash/keys');
var _keys3 = _interopRequireDefault(_keys2);
var _isEqual2 = require('lodash/isEqual');

@@ -86,13 +90,10 @@

var rowsWithoutChildren = (0, _differenceWith3.default)(rows, children, _isEqual3.default);
var childrenCount = (0, _keys3.default)(childrenPerParent).length;
var prevChildrenCount = void 0;
do {
prevChildrenCount = childrenCount;
childrenPerParent = attachChildren(rowsWithoutChildren, childrenPerParent, idField);
childrenCount = (0, _keys3.default)(childrenPerParent).length;
} while (childrenCount < prevChildrenCount);
(0, _forOwn3.default)(childrenPerParent, function (childrenFromParent, parentId) {
var parentPosition = (0, _findIndex3.default)(rowsWithoutChildren, function (x) {
var hasId = !(0, _isNil3.default)(x[idField]);
var matchesParentId = hasId && parentId === x[idField].toString();
return hasId && matchesParentId;
});
// puts children right after their parent so correct order will be kept
rowsWithoutChildren.splice.apply(rowsWithoutChildren, [parentPosition + 1, 0].concat(_toConsumableArray(childrenFromParent)));
});
return rowsWithoutChildren;

@@ -102,2 +103,19 @@ };

function attachChildren(rowsWithoutChildren, childrenPerParent, idField) {
var remainingChildrenPerParent = childrenPerParent;
(0, _forOwn3.default)(childrenPerParent, function (childrenFromParent, parentId) {
var parentPosition = (0, _findIndex3.default)(rowsWithoutChildren, function (x) {
var hasId = !(0, _isNil3.default)(x[idField]);
var matchesParentId = hasId && parentId === x[idField].toString();
return hasId && matchesParentId;
});
// puts children right after their parent so correct order will be kept
if (parentPosition !== -1) {
rowsWithoutChildren.splice.apply(rowsWithoutChildren, [parentPosition + 1, 0].concat(_toConsumableArray(childrenFromParent)));
delete remainingChildrenPerParent[parentId];
}
});
return remainingChildrenPerParent;
}
exports.default = fixOrder;
{
"name": "treetabular",
"version": "3.3.0",
"version": "3.4.0",
"description": "Tree utilities",

@@ -70,2 +70,3 @@ "scripts": {

"lodash": "^4.17.4",
"prop-types": "^15.5.10",
"react": "^15.4.2",

@@ -72,0 +73,0 @@ "react-addons-test-utils": "^15.4.2",

@@ -12,2 +12,3 @@ [![build status](https://secure.travis-ci.org/reactabular/treetabular.svg)](http://travis-ci.org/reactabular/treetabular) [![bitHound Score](https://www.bithound.io/github/reactabular/treetabular/badges/score.svg)](https://www.bithound.io/github/reactabular/treetabular) [![codecov](https://codecov.io/gh/reactabular/treetabular/branch/master/graph/badge.svg)](https://codecov.io/gh/reactabular/treetabular)

{
_index: 0,
id: 123,

@@ -17,2 +18,3 @@ name: 'Demo'

{
_index: 1,
id: 456,

@@ -23,2 +25,3 @@ name: 'Another',

{
_index: 2,
id: 789,

@@ -29,2 +32,3 @@ name: 'Yet Another',

{
_index: 3,
id: 532,

@@ -130,6 +134,6 @@ name: 'Foobar'

Makes it possible to toggle node children through a user interface.
Makes it possible to toggle node children through a user interface.
Pass `"indent":false` inside `props` object if you want to disable automatic indentation.
The default implementation of `getIndex(rowData)` depends on [resolve.resolve](https://www.npmjs.com/package/table-resolver#resolveresolve) as it looks for index of the row to toggle based on that. This can be customized through.
The default implementation of `getIndex(rowData)` depends on [resolve.resolve](https://www.npmjs.com/package/table-resolver#resolveresolve) as it looks for index of the row to toggle based on that. This can be customized though.

@@ -136,0 +140,0 @@ ### Helpers

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc