Skip to content

Commit 27bf3b2

Browse files
authored
Merge pull request #40 from lucas-issa/v1.1.0-dev
1) Add a feature to disable a node. 2) Reduce around 400kB in the transpiled code. 3) Adding support to React node type (string or jsx tags) to the node label.
2 parents ed01cdc + d8324b2 commit 27bf3b2

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ Individual nodes within the `nodes` property can have the following structure:
110110

111111
| Property | Type | Description |
112112
| ----------- | ------ | ------------------------------- |
113-
| `label` | string | **Required**. The node's label. |
113+
| `label` | mixed | **Required**. The node's label. |
114114
| `value` | mixed | **Required**. The node's value. |
115115
| `children` | array | An array of child nodes. |
116116
| `className` | string | A className to add to the node. |
117+
| `disabled` | bool | Disable node. |
117118
| `icon` | mixed | A custom icon for the node. |

src/js/CheckboxTree.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import { isEqual } from 'lodash';
2+
import isEqual from 'lodash/isEqual';
33
import PropTypes from 'prop-types';
44
import React from 'react';
55
import shortid from 'shortid';
@@ -190,13 +190,14 @@ class CheckboxTree extends React.Component {
190190
const key = `${node.value}`;
191191
const checked = this.getCheckState(node, noCascade);
192192
const children = this.renderChildNodes(node);
193+
const nodeDisabled = !!(disabled || node.disabled);
193194

194195
return (
195196
<TreeNode
196197
key={key}
197198
checked={checked}
198199
className={node.className}
199-
disabled={disabled}
200+
disabled={nodeDisabled}
200201
expandDisabled={expandDisabled}
201202
expanded={node.expanded}
202203
icon={node.icon}

src/js/TreeNode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TreeNode extends React.Component {
1010
disabled: PropTypes.bool.isRequired,
1111
expandDisabled: PropTypes.bool.isRequired,
1212
expanded: PropTypes.bool.isRequired,
13-
label: PropTypes.string.isRequired,
13+
label: PropTypes.node.isRequired,
1414
optimisticToggle: PropTypes.bool.isRequired,
1515
showNodeIcon: PropTypes.bool.isRequired,
1616
treeId: PropTypes.string.isRequired,
@@ -145,6 +145,7 @@ class TreeNode extends React.Component {
145145
'rct-node': true,
146146
'rct-node-parent': this.hasChildren(),
147147
'rct-node-leaf': !this.hasChildren(),
148+
'rct-disabled': disabled,
148149
}, className);
149150

150151
return (

src/js/nodeShape.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import PropTypes from 'prop-types';
22

33
const nodeShape = {
4-
label: PropTypes.string.isRequired,
4+
label: PropTypes.node.isRequired,
55
value: PropTypes.oneOfType([
66
PropTypes.string,
77
PropTypes.number,

0 commit comments

Comments
 (0)