1+ import classNames from 'classnames' ;
12import { isEqual } from 'lodash' ;
23import PropTypes from 'prop-types' ;
34import React from 'react' ;
@@ -11,6 +12,8 @@ class CheckboxTree extends React.Component {
1112 nodes : PropTypes . arrayOf ( nodeShape ) . isRequired ,
1213
1314 checked : PropTypes . arrayOf ( PropTypes . string ) ,
15+ disabled : PropTypes . bool ,
16+ expandDisabled : PropTypes . bool ,
1417 expanded : PropTypes . arrayOf ( PropTypes . string ) ,
1518 name : PropTypes . string ,
1619 nameAsArray : PropTypes . bool ,
@@ -23,6 +26,8 @@ class CheckboxTree extends React.Component {
2326
2427 static defaultProps = {
2528 checked : [ ] ,
29+ disabled : false ,
30+ expandDisabled : false ,
2631 expanded : [ ] ,
2732 name : undefined ,
2833 nameAsArray : false ,
@@ -180,7 +185,7 @@ class CheckboxTree extends React.Component {
180185 }
181186
182187 renderTreeNodes ( nodes ) {
183- const { noCascade, optimisticToggle, showNodeIcon } = this . props ;
188+ const { disabled , expandDisabled , noCascade, optimisticToggle, showNodeIcon } = this . props ;
184189 const treeNodes = nodes . map ( ( node ) => {
185190 const key = `${ node . value } ` ;
186191 const checked = this . getCheckState ( node , noCascade ) ;
@@ -191,6 +196,8 @@ class CheckboxTree extends React.Component {
191196 key = { key }
192197 checked = { checked }
193198 className = { node . className }
199+ disabled = { disabled }
200+ expandDisabled = { expandDisabled }
194201 expanded = { node . expanded }
195202 icon = { node . icon }
196203 label = { node . label }
@@ -251,9 +258,13 @@ class CheckboxTree extends React.Component {
251258 render ( ) {
252259 const nodes = this . getFormattedNodes ( this . props . nodes ) ;
253260 const treeNodes = this . renderTreeNodes ( nodes ) ;
261+ const className = classNames ( {
262+ 'react-checkbox-tree' : true ,
263+ 'rct-disabled' : this . props . disabled ,
264+ } ) ;
254265
255266 return (
256- < div className = "react-checkbox-tree" >
267+ < div className = { className } >
257268 { this . renderHiddenInput ( ) }
258269 { treeNodes }
259270 </ div >
0 commit comments