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 2.1.0 to 3.0.0

6

CHANGELOG.md
## treetabular
3.0.0 / 2017-02-09
==================
* Breaking fix - Allow children that have sub-children to be displayed. #4
* Fix - Allow `tree.hasChildren` to receive `parentField`. #4
2.1.0 / 2017-02-06

@@ -4,0 +10,0 @@ ==================

4

dist/filter.js

@@ -16,2 +16,4 @@ 'use strict';

fieldName = _ref.fieldName,
_ref$idField = _ref.idField,
idField = _ref$idField === undefined ? 'id' : _ref$idField,
_ref$parentField = _ref.parentField,

@@ -30,3 +32,3 @@ parentField = _ref$parentField === undefined ? 'parent' : _ref$parentField;

var parents = (0, _getParents2.default)({ index: index, parentField: parentField })(rows);
var parents = (0, _getParents2.default)({ index: index, idField: idField, parentField: parentField })(rows);

@@ -33,0 +35,0 @@ return parents.filter(function (parent) {

@@ -16,2 +16,4 @@ 'use strict';

index = _ref.index,
_ref$idField = _ref.idField,
idField = _ref$idField === undefined ? 'id' : _ref$idField,
_ref$parentField = _ref.parentField,

@@ -21,3 +23,3 @@ parentField = _ref$parentField === undefined ? 'parent' : _ref$parentField;

return function (rows) {
return (0, _getParents2.default)({ index: index, parentField: parentField })(rows).length;
return (0, _getParents2.default)({ index: index, idField: idField, parentField: parentField })(rows).length;
};

@@ -24,0 +26,0 @@ };

@@ -6,5 +6,14 @@ 'use strict';

});
var _isNil2 = require('lodash/isNil');
var _isNil3 = _interopRequireDefault(_isNil2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getParents() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
index = _ref.index,
_ref$idField = _ref.idField,
idField = _ref$idField === undefined ? 'id' : _ref$idField,
_ref$parentField = _ref.parentField,

@@ -17,5 +26,5 @@ parentField = _ref$parentField === undefined ? 'parent' : _ref$parentField;

var cell = rows[index];
var previousParent = void 0;
var searchingParent = void 0;
if (!cell || typeof cell[parentField] === 'undefined' || cell[parentField] === null) {
if (!cell || (0, _isNil3.default)(cell[parentField])) {
return parents;

@@ -25,18 +34,10 @@ }

while (cell) {
if (cell[parentField] === null) {
if (previousParent !== cell[parentField]) {
parents.unshift(cell);
}
break;
if (typeof searchingParent === 'undefined') {
searchingParent = cell[parentField];
} else if (searchingParent === cell[idField]) {
parents.unshift(cell);
searchingParent = cell[parentField];
}
if (typeof cell[parentField] !== 'undefined') {
if (typeof previousParent !== 'undefined' && previousParent !== cell[parentField]) {
parents.unshift(cell);
}
} else {
if (typeof previousParent !== 'undefined') {
parents.unshift(cell);
}
if (cell[parentField] === null) {
break;

@@ -46,4 +47,2 @@ }

currentIndex -= 1;
previousParent = cell[parentField];
cell = rows[currentIndex];

@@ -50,0 +49,0 @@ }

@@ -51,3 +51,3 @@ 'use strict';

var children = (0, _getChildren2.default)({ index: row._index, idField: idField, parentField: parentField })(rows);
var parents = (0, _getParents2.default)({ index: row._index, parentField: parentField })(rows);
var parents = (0, _getParents2.default)({ index: row._index, idField: idField, parentField: parentField })(rows);

@@ -54,0 +54,0 @@ return parents.concat(row).concat(children);

@@ -31,3 +31,4 @@ 'use strict';

props = _ref.props,
idField = _ref.idField,
_ref$idField = _ref.idField,
idField = _ref$idField === undefined ? 'id' : _ref$idField,
parentField = _ref.parentField;

@@ -60,9 +61,10 @@

var rowData = extra.rowData;
var rows = getRows();
var showingChildren = getShowingChildren(extra);
var index = rowData._index;
var containsChildren = (0, _hasChildren2.default)({ index: index, idField: idField })(rows) ? 'has-children' : '';
var level = (0, _getLevel2.default)({ index: index, parentField: parentField })(rows);
// index must be the index of original rows, but filtered rows
var index = rows.findIndex(function (row) {
return row[idField] === value;
});
var containsChildren = (0, _hasChildren2.default)({ index: index, idField: idField, parentField: parentField })(rows) ? 'has-children' : '';
var level = (0, _getLevel2.default)({ index: index, idField: idField, parentField: parentField })(rows);
var hasParent = level > 0 ? 'has-parent' : '';

@@ -73,5 +75,8 @@

_extends({
style: { paddingLeft: level + 'em' },
onClick: function onClick(e) {
return toggle(e, index);
style: { paddingLeft: level + 'em' }
// toggling children with a doubleClick would provide better UX
// since toggling with a click makes it difficult to select each item.
, onDoubleClick: function onDoubleClick(e) {
toggle(e, index);
window.getSelection && window.getSelection().removeAllRanges();
},

@@ -78,0 +83,0 @@ className: containsChildren + ' ' + hasParent + ' ' + (className || '')

{
"name": "treetabular",
"version": "2.1.0",
"version": "3.0.0",
"description": "Tree utilities",

@@ -52,32 +52,32 @@ "scripts": {

"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.20.0",
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-jest": "^18.0.0",
"babel-plugin-lodash": "^3.2.10",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-object-rest-spread": "^6.20.2",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"classnames": "^2.2.5",
"eslint": "^3.12.2",
"eslint-config-airbnb": "^13.0.0",
"eslint": "^3.15.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.8.0",
"git-prepush-hook": "^1.0.1",
"jest": "^18.0.0",
"lodash": "^4.17.2",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dnd": "^2.1.4",
"react-dom": "^15.4.1",
"reactabular-dnd": "^8.4.1",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.9.0",
"git-prepush-hook": "^1.0.2",
"jest": "^18.1.0",
"lodash": "^4.17.4",
"react": "^15.4.2",
"react-addons-test-utils": "^15.4.2",
"react-dnd": "^2.2.3",
"react-dom": "^15.4.2",
"reactabular-dnd": "^8.6.0",
"redux": "^3.6.0",
"rimraf": "^2.5.4",
"searchtabular": "^1.2.3",
"sortabular": "^1.0.4"
"searchtabular": "^1.3.2",
"sortabular": "^1.2.0"
},
"peerDependencies": {
"lodash": ">= 3.0.0 < 5.0.0",
"lodash": ">= 4.0.0 < 5.0.0",
"react": ">= 15.0.0 < 16.0.0",

@@ -84,0 +84,0 @@ "redux": ">= 3.0.0 < 4.0.0"

@@ -56,3 +56,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)

**`tree.filter = ({ fieldName, parentField = 'parent' }) => (rows) => [<filteredRow>]`**
**`tree.filter = ({ fieldName, idField = 'parentId', parentField = 'parent' }) => (rows) => [<filteredRow>]`**

@@ -63,3 +63,3 @@ Filters the given rows using `fieldName`. This is handy if you want only rows that are visible assuming visibility logic has been defined.

**`tree.getLevel = ({ index, parentField = 'parent' }) => (rows) => <level>`**
**`tree.getLevel = ({ index, idField = 'parentId', parentField = 'parent' }) => (rows) => <level>`**

@@ -76,3 +76,3 @@ Returns the nesting level of the row at the given `index` within `rows`.

**`tree.getParents = ({ index, parentField = 'parent' }) => (rows) => [<parent>]`**
**`tree.getParents = ({ index, idField = 'parentId', parentField = 'parent' }) => (rows) => [<parent>]`**

@@ -127,3 +127,3 @@ Returns parents based on given `rows` and `index`.

**`tree.toggleChildren = ({ getRows, getShowingChildren, toggleShowingChildren, props, idField, parentField }) => (value, extra) => <React element>`**
**`tree.toggleChildren = ({ getRows, getShowingChildren, toggleShowingChildren, props, idField = 'id', parentField }) => (value, extra) => <React element>`**

@@ -130,0 +130,0 @@ Makes it possible to toggle node children through a user interface.

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