From 3c774fde50ab2dc2cfc6eb5a239346fe07d6e967 Mon Sep 17 00:00:00 2001 From: Lucas Villela Neder Issa Date: Fri, 14 Jul 2017 10:25:15 -0300 Subject: [PATCH 1/4] Add a feature to disable a node. --- README.md | 1 + src/js/CheckboxTree.js | 4 +++- src/js/TreeNode.js | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8de3ef6e..59c80982 100644 --- a/README.md +++ b/README.md @@ -115,3 +115,4 @@ Individual nodes within the `nodes` property can have the following structure: | `children` | array | An array of child nodes. | | `className` | string | A className to add to the node. | | `icon` | mixed | A custom icon for the node. | +| `disabled` | bool | Disable node. | diff --git a/src/js/CheckboxTree.js b/src/js/CheckboxTree.js index c71c3084..db85fa84 100644 --- a/src/js/CheckboxTree.js +++ b/src/js/CheckboxTree.js @@ -191,12 +191,14 @@ class CheckboxTree extends React.Component { const checked = this.getCheckState(node, noCascade); const children = this.renderChildNodes(node); + const nodeDisabled = !!(disabled || node.disabled); + return ( Date: Fri, 14 Jul 2017 11:13:55 -0300 Subject: [PATCH 2/4] Reduce around 400kB in the transpiled code. --- src/js/CheckboxTree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/CheckboxTree.js b/src/js/CheckboxTree.js index db85fa84..5bcb0060 100644 --- a/src/js/CheckboxTree.js +++ b/src/js/CheckboxTree.js @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { isEqual } from 'lodash'; +import isEqual from 'lodash/isEqual'; import PropTypes from 'prop-types'; import React from 'react'; import shortid from 'shortid'; From cb6ccb9d9fb311e190befadb9f5c4b99b7fadd32 Mon Sep 17 00:00:00 2001 From: Lucas Villela Neder Issa Date: Fri, 14 Jul 2017 12:52:07 -0300 Subject: [PATCH 3/4] Adding support to React node type (string or jsx tags) to the node label. --- README.md | 2 +- src/js/TreeNode.js | 2 +- src/js/nodeShape.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 59c80982..835d6411 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Individual nodes within the `nodes` property can have the following structure: | Property | Type | Description | | ----------- | ------ | ------------------------------- | -| `label` | string | **Required**. The node's label. | +| `label` | mixed | **Required**. The node's label. | | `value` | mixed | **Required**. The node's value. | | `children` | array | An array of child nodes. | | `className` | string | A className to add to the node. | diff --git a/src/js/TreeNode.js b/src/js/TreeNode.js index 2835355b..493eade9 100644 --- a/src/js/TreeNode.js +++ b/src/js/TreeNode.js @@ -10,7 +10,7 @@ class TreeNode extends React.Component { disabled: PropTypes.bool.isRequired, expandDisabled: PropTypes.bool.isRequired, expanded: PropTypes.bool.isRequired, - label: PropTypes.string.isRequired, + label: PropTypes.node.isRequired, optimisticToggle: PropTypes.bool.isRequired, showNodeIcon: PropTypes.bool.isRequired, treeId: PropTypes.string.isRequired, diff --git a/src/js/nodeShape.js b/src/js/nodeShape.js index 61f7ccb4..f28dd6ff 100644 --- a/src/js/nodeShape.js +++ b/src/js/nodeShape.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; const nodeShape = { - label: PropTypes.string.isRequired, + label: PropTypes.node.isRequired, value: PropTypes.oneOfType([ PropTypes.string, PropTypes.number, From d8324b2c2066f733755508f5a59de3fad44798c8 Mon Sep 17 00:00:00 2001 From: Lucas Villela Neder Issa Date: Sat, 15 Jul 2017 11:53:17 -0300 Subject: [PATCH 4/4] Change order of disabled property as requested. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b97c29b7..5da20f5e 100644 --- a/README.md +++ b/README.md @@ -114,5 +114,5 @@ Individual nodes within the `nodes` property can have the following structure: | `value` | mixed | **Required**. The node's value. | | `children` | array | An array of child nodes. | | `className` | string | A className to add to the node. | -| `icon` | mixed | A custom icon for the node. | | `disabled` | bool | Disable node. | +| `icon` | mixed | A custom icon for the node. |