react-checkbox-tree
Advanced tools
Comparing version 0.3.0-rc.0 to 0.3.0-rc.1
@@ -1,2 +0,2 @@ | ||
/*! react-checkbox-tree - v0.3.0-rc.0 | 2016 */ | ||
/*! react-checkbox-tree - v0.3.0-rc.1 | 2016 */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -77,4 +77,2 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -92,2 +90,4 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -115,4 +115,3 @@ | ||
value: function onCheck(node) { | ||
var checked = this.props.checked; | ||
var checked = [].concat(_toConsumableArray(this.props.checked)); | ||
var isChecked = node.checked; | ||
@@ -128,3 +127,3 @@ | ||
var isExpanded = node.expanded; | ||
var expanded = this.props.expanded; | ||
var expanded = [].concat(_toConsumableArray(this.props.expanded)); | ||
var nodeIndex = expanded.indexOf(node.value); | ||
@@ -158,4 +157,6 @@ | ||
if (_this2.hasChildren(node)) { | ||
if (Array.isArray(node.children) && node.children.length > 0) { | ||
formatted.children = _this2.getFormattedNodes(formatted.children); | ||
} else { | ||
formatted.children = null; | ||
} | ||
@@ -169,3 +170,3 @@ | ||
value: function getCheckState(node) { | ||
if (this.hasChildren(node) === false) { | ||
if (node.children === null) { | ||
return node.checked ? 1 : 0; | ||
@@ -189,3 +190,3 @@ } | ||
if (this.hasChildren(node)) { | ||
if (node.children !== null) { | ||
// Percolate check status down to all children | ||
@@ -214,3 +215,3 @@ node.children.forEach(function (child) { | ||
return node.children.every(function (child) { | ||
if (_this4.hasChildren(child)) { | ||
if (child.children !== null) { | ||
return _this4.isEveryChildChecked(child); | ||
@@ -228,3 +229,3 @@ } | ||
return node.children.some(function (child) { | ||
if (_this5.hasChildren(child)) { | ||
if (child.children !== null) { | ||
return _this5.isSomeChildChecked(child); | ||
@@ -237,11 +238,2 @@ } | ||
}, { | ||
key: 'hasChildren', | ||
value: function hasChildren(node) { | ||
if (_typeof(node.children) !== 'object') { | ||
return false; | ||
} | ||
return node.children.length > 0; | ||
} | ||
}, { | ||
key: 'renderTreeNodes', | ||
@@ -280,3 +272,3 @@ value: function renderTreeNodes(nodes) { | ||
value: function renderChildNodes(node) { | ||
if (this.hasChildren(node)) { | ||
if (node.children !== null && node.expanded) { | ||
return this.renderTreeNodes(node.children); | ||
@@ -417,3 +409,3 @@ } | ||
value: function renderCollapseIcon() { | ||
if (this.props.children === null) { | ||
if (this.props.rawChildren === null) { | ||
return _react2.default.createElement("i", { className: "fa" }); | ||
@@ -444,3 +436,3 @@ } | ||
value: function renderNodeIcon() { | ||
if (this.props.children !== null) { | ||
if (this.props.rawChildren !== null) { | ||
if (!this.props.expanded) { | ||
@@ -447,0 +439,0 @@ return _react2.default.createElement("i", { className: "fa fa-folder-o" }); |
{ | ||
"name": "react-checkbox-tree", | ||
"version": "0.3.0-rc.0", | ||
"version": "0.3.0-rc.1", | ||
"description": "React component for checkbox trees.", | ||
@@ -5,0 +5,0 @@ "author": "Jake Zatecky", |
@@ -24,3 +24,3 @@ import React from 'react'; | ||
onCheck(node) { | ||
const { checked } = this.props; | ||
const checked = [...this.props.checked]; | ||
const isChecked = node.checked; | ||
@@ -35,3 +35,3 @@ | ||
const isExpanded = node.expanded; | ||
const expanded = this.props.expanded; | ||
const expanded = [...this.props.expanded]; | ||
const nodeIndex = expanded.indexOf(node.value); | ||
@@ -59,4 +59,6 @@ | ||
if (this.hasChildren(node)) { | ||
if (Array.isArray(node.children) && node.children.length > 0) { | ||
formatted.children = this.getFormattedNodes(formatted.children); | ||
} else { | ||
formatted.children = null; | ||
} | ||
@@ -69,3 +71,3 @@ | ||
getCheckState(node) { | ||
if (this.hasChildren(node) === false) { | ||
if (node.children === null) { | ||
return node.checked ? 1 : 0; | ||
@@ -86,3 +88,3 @@ } | ||
setCheckState(checked, node, isChecked) { | ||
if (this.hasChildren(node)) { | ||
if (node.children !== null) { | ||
// Percolate check status down to all children | ||
@@ -108,3 +110,3 @@ node.children.forEach((child) => { | ||
return node.children.every((child) => { | ||
if (this.hasChildren(child)) { | ||
if (child.children !== null) { | ||
return this.isEveryChildChecked(child); | ||
@@ -119,3 +121,3 @@ } | ||
return node.children.some((child) => { | ||
if (this.hasChildren(child)) { | ||
if (child.children !== null) { | ||
return this.isSomeChildChecked(child); | ||
@@ -128,10 +130,2 @@ } | ||
hasChildren(node) { | ||
if (typeof node.children !== 'object') { | ||
return false; | ||
} | ||
return node.children.length > 0; | ||
} | ||
renderTreeNodes(nodes) { | ||
@@ -166,3 +160,3 @@ const treeNodes = nodes.map((node, index) => { | ||
renderChildNodes(node) { | ||
if (this.hasChildren(node)) { | ||
if (node.children !== null && node.expanded) { | ||
return this.renderTreeNodes(node.children); | ||
@@ -169,0 +163,0 @@ } |
@@ -45,3 +45,3 @@ import React from 'react'; | ||
renderCollapseIcon() { | ||
if (this.props.children === null) { | ||
if (this.props.rawChildren === null) { | ||
return <i className="fa" />; | ||
@@ -70,3 +70,3 @@ } | ||
renderNodeIcon() { | ||
if (this.props.children !== null) { | ||
if (this.props.rawChildren !== null) { | ||
if (!this.props.expanded) { | ||
@@ -73,0 +73,0 @@ return <i className="fa fa-folder-o" />; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
197837
824