Skip to content

Commit 5c94df8

Browse files
WIP
1 parent 68d6f0b commit 5c94df8

File tree

3 files changed

+54
-48
lines changed

3 files changed

+54
-48
lines changed

examples/bundle.js

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,14 +2227,14 @@ var SuperTreeview = function (_Component) {
22272227

22282228
var _props5 = this.props,
22292229
isCheckable = _props5.isCheckable,
2230-
keywordLabel = _props5.keywordLabel,
2230+
keywordName = _props5.keywordName,
22312231
depth = _props5.depth;
22322232

22332233

22342234
if (isCheckable(node, depth)) {
22352235
return _react2.default.createElement('input', {
22362236
type: 'checkbox',
2237-
name: node[keywordLabel],
2237+
name: node[keywordName],
22382238
onClick: function onClick(e) {
22392239
_this2.handleCheckToggle(node, e);
22402240
},
@@ -2354,6 +2354,7 @@ var SuperTreeview = function (_Component) {
23542354
null,
23552355
(0, _lodash.isEmpty)(nodeArray) ? this.printNoChildrenMessage() : nodeArray.map(function (node, index) {
23562356
var nodeText = (0, _lodash.get)(node, keywordLabel, '');
2357+
var nodeName = (0, _lodash.get)(node, keywordName, '');
23572358

23582359
return _react2.default.createElement(
23592360
_reactTransitionGroup.CSSTransition,
@@ -41802,55 +41803,55 @@ module.exports = function() {
4180241803
/* 205 */
4180341804
/***/ (function(module, exports) {
4180441805

41805-
var g;
41806-
41807-
// This works in non-strict mode
41808-
g = (function() {
41809-
return this;
41810-
})();
41811-
41812-
try {
41813-
// This works if eval is allowed (see CSP)
41814-
g = g || Function("return this")() || (1,eval)("this");
41815-
} catch(e) {
41816-
// This works if the window reference is available
41817-
if(typeof window === "object")
41818-
g = window;
41819-
}
41820-
41821-
// g can still be undefined, but nothing to do about it...
41822-
// We return undefined, instead of nothing here, so it's
41823-
// easier to handle this case. if(!global) { ...}
41824-
41825-
module.exports = g;
41806+
var g;
41807+
41808+
// This works in non-strict mode
41809+
g = (function() {
41810+
return this;
41811+
})();
41812+
41813+
try {
41814+
// This works if eval is allowed (see CSP)
41815+
g = g || Function("return this")() || (1,eval)("this");
41816+
} catch(e) {
41817+
// This works if the window reference is available
41818+
if(typeof window === "object")
41819+
g = window;
41820+
}
41821+
41822+
// g can still be undefined, but nothing to do about it...
41823+
// We return undefined, instead of nothing here, so it's
41824+
// easier to handle this case. if(!global) { ...}
41825+
41826+
module.exports = g;
4182641827

4182741828

4182841829
/***/ }),
4182941830
/* 206 */
4183041831
/***/ (function(module, exports) {
4183141832

41832-
module.exports = function(module) {
41833-
if(!module.webpackPolyfill) {
41834-
module.deprecate = function() {};
41835-
module.paths = [];
41836-
// module.parent = undefined by default
41837-
if(!module.children) module.children = [];
41838-
Object.defineProperty(module, "loaded", {
41839-
enumerable: true,
41840-
get: function() {
41841-
return module.l;
41842-
}
41843-
});
41844-
Object.defineProperty(module, "id", {
41845-
enumerable: true,
41846-
get: function() {
41847-
return module.i;
41848-
}
41849-
});
41850-
module.webpackPolyfill = 1;
41851-
}
41852-
return module;
41853-
};
41833+
module.exports = function(module) {
41834+
if(!module.webpackPolyfill) {
41835+
module.deprecate = function() {};
41836+
module.paths = [];
41837+
// module.parent = undefined by default
41838+
if(!module.children) module.children = [];
41839+
Object.defineProperty(module, "loaded", {
41840+
enumerable: true,
41841+
get: function() {
41842+
return module.l;
41843+
}
41844+
});
41845+
Object.defineProperty(module, "id", {
41846+
enumerable: true,
41847+
get: function() {
41848+
return module.i;
41849+
}
41850+
});
41851+
module.webpackPolyfill = 1;
41852+
}
41853+
return module;
41854+
};
4185441855

4185541856

4185641857
/***/ }),

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ Props | Type | Default | Description
131131
`keywordChildren`| string | `'children'`| Set the `key` where the component should look for the children elements.
132132
`keywordChildrenLoading`| string| `'isChildrenLoading'`|Set the `key` that indicates if the children nodes are loading or now. If `true` then the `loadingElement` is shown. NOTE: Make sure that the node is expanded (`isExpanded: true`) for the `loadingElement`.
133133
`keywordKey`| string | `'id'` | This is the value that is set as the `key` attribute on the node (`<div key={keywordKey}> node name </div>`). It defaults to the `id` key. This must be a unique key, if not provided or is not unique, will break the animation feature.
134-
`keywordLabel`|string|`'name'` | The node text is printed from the `name` key. If you want some other key value to be printed, provide the key here.
134+
`keywordName`|string|`'name'` | The node text is printed from the `name` key. If you want some other key value to be printed, provide the key here.
135+
`keywordLabel`|string|`'name'` | The node label text is printed from the `name` key. If you want some other key value to be printed, provide the key here.
135136
`loadingElement`| element | `<div>loading...</div>`|Element that shows when data is being loading. Provide your custom loading element with this prop.
136137
`noChildrenAvailableMessage` | string | `'no data found'` |Message that shows when the expanded node has no children.
137138
`onCheckToggleCb`| function |`(arrayOfNodes, depth) => {}`|Function callback when checkbox gets toggled. The callback provides an array of nodes (`arrayOfNodes`) that got checked/unchecked. Since `<SuperTreeview />` has a multi-select feature, hence its an array here. All nodes will have the same `isChecked` state, either `true` or `false`. The callback also provides the `depth` of the node that got checked/unchecked.

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ class SuperTreeview extends Component {
101101
}
102102

103103
printCheckbox(node) {
104-
const { isCheckable, keywordLabel, depth } = this.props;
104+
const { isCheckable, keywordName, depth } = this.props;
105105

106106
if (isCheckable(node, depth)) {
107107
return (
108108
<input
109109
type="checkbox"
110-
name={node[keywordLabel]}
110+
name={node[keywordName]}
111111
onClick={(e) => {
112112
this.handleCheckToggle(node, e);
113113
}}
@@ -186,6 +186,7 @@ class SuperTreeview extends Component {
186186
printNodes(nodeArray) {
187187
const {
188188
keywordKey,
189+
keywordName,
189190
keywordLabel,
190191
depth,
191192
transitionEnterTimeout,
@@ -216,6 +217,7 @@ class SuperTreeview extends Component {
216217
? this.printNoChildrenMessage()
217218
: nodeArray.map((node, index) => {
218219
const nodeText = get(node, keywordLabel, '');
220+
const nodeName = get(node, keywordName, '');
219221

220222
return (
221223
<CSSTransition
@@ -311,6 +313,7 @@ SuperTreeview.propTypes = {
311313
keywordChildrenLoading: PropTypes.string,
312314
keywordKey: PropTypes.string,
313315
keywordLabel: PropTypes.string,
316+
keywordName: PropTypes.string,
314317

315318
loadingElement: PropTypes.element,
316319
noChildrenAvailableMessage: PropTypes.string,
@@ -345,6 +348,7 @@ SuperTreeview.defaultProps = {
345348
keywordChildren: 'children',
346349
keywordChildrenLoading: 'isChildrenLoading',
347350
keywordLabel: 'name',
351+
keywordName: 'name',
348352
keywordKey: 'id',
349353

350354
loadingElement: <div>loading...</div>,

0 commit comments

Comments
 (0)