Socket
Socket
Sign inDemoInstall

react-infinity-menu

Package Overview
Dependencies
5
Maintainers
31
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 3.2.0

.babelrc

184

dist/infinity-menu.js

@@ -9,12 +9,4 @@ "use strict";

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; }; })();
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; }; }();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require("react");

@@ -32,11 +24,18 @@

var _lodash = require('lodash');
var _get2 = require("lodash/get");
var _lodash2 = _interopRequireDefault(_lodash);
var _get3 = _interopRequireDefault(_get2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/*
* @class InfinityMenu
*/
var InfinityMenu = (function (_React$Component) {
var InfinityMenu = function (_React$Component) {
_inherits(InfinityMenu, _React$Component);

@@ -47,8 +46,8 @@

*/
function InfinityMenu(props) {
_classCallCheck(this, InfinityMenu);
_get(Object.getPrototypeOf(InfinityMenu.prototype), "constructor", this).call(this, props);
this.state = {
var _this = _possibleConstructorReturn(this, (InfinityMenu.__proto__ || Object.getPrototypeOf(InfinityMenu)).call(this, props));
_this.state = {
search: {

@@ -59,7 +58,7 @@ isSearching: false,

};
this.setSearchInput = this.setSearchInput.bind(this);
this.stopSearching = this.stopSearching.bind(this);
this.startSearching = this.startSearching.bind(this);
_this.setSearchInput = _this.setSearchInput.bind(_this);
_this.stopSearching = _this.stopSearching.bind(_this);
_this.startSearching = _this.startSearching.bind(_this);
return _this;
}
/*

@@ -72,2 +71,3 @@ * @function onNodeClick

_createClass(InfinityMenu, [{

@@ -80,3 +80,3 @@ key: "onNodeClick",

node.maxLeaves = this.props.maxLeaves;
_nestedObjects2["default"].set(tree, keyPath, node);
_nestedObjects2.default.set(tree, keyPath, node);
if (this.props.onNodeMouseClick) {

@@ -93,5 +93,5 @@ var currLevel = Math.floor(keyPath.split(".").length / 2);

// get parent node so we can increment it's unique max leaves property
var keyPathArray = keyPath.split('.');
var keyPathArray = keyPath.split(".");
var parentPath = Object.assign([], keyPathArray).splice(0, keyPathArray.length - 2);
var parentNode = _lodash2["default"].get(this.props.tree, parentPath);
var parentNode = (0, _get3.default)(this.props.tree, parentPath);
// set new max leaves - if none exist use component default property

@@ -104,3 +104,2 @@ parentNode.maxLeaves = !parentNode.maxLeaves ? this.props.maxLeaves : parentNode.maxLeaves + this.props.maxLeaves;

}
/*

@@ -110,2 +109,3 @@ * @function shouldComponentUpdate

*/
}, {

@@ -120,3 +120,2 @@ key: "shouldComponentUpdate",

}
/*

@@ -126,2 +125,3 @@ * @function startSearching

*/
}, {

@@ -137,3 +137,2 @@ key: "startSearching",

}
/*

@@ -143,2 +142,3 @@ * @function stopSearching

*/
}, {

@@ -154,3 +154,2 @@ key: "stopSearching",

}
/*

@@ -160,2 +159,3 @@ * @function setSearchInput

*/
}, {

@@ -174,3 +174,3 @@ key: "setSearchInput",

value: function findFiltered(trees, node, key) {
var _this = this;
var _this2 = this;

@@ -190,3 +190,3 @@ if (!node.children) {

var filteredSubFolder = node.children.length ? node.children.reduce(function (p, c, k) {
return _this.findFiltered(p, c, k);
return _this2.findFiltered(p, c, k);
}, []) : [];

@@ -222,9 +222,10 @@ var shouldDisplay = filteredSubFolder.some(function (child) {

*/
}, {
key: "setDisplayTree",
value: function setDisplayTree(tree, prevs, curr, keyPath) {
var _this2 = this;
var _this3 = this;
var currLevel = Math.floor(keyPath.length / 2);
var currCustomComponent = typeof curr.customComponent === 'string' ? this.props.customComponentMappings[curr.customComponent] : curr.customComponent;
var currCustomComponent = typeof curr.customComponent === "string" ? this.props.customComponentMappings[curr.customComponent] : curr.customComponent;
var currCustomloadMoreComponent = this.props.loadMoreComponent ? this.props.loadMoreComponent : null;

@@ -237,6 +238,10 @@ var isSearching = this.state.search.isSearching && this.state.search.searchInput;

if (!curr.children) {
var keyPathArray = keyPath.split('.');
var keyPathArray = keyPath.split(".");
var parentPath = Object.assign([], keyPathArray).splice(0, keyPathArray.length - 2);
var parentNode = _lodash2["default"].get(this.props.tree, parentPath);
var filteredChildren = _lodash2["default"].some(parentNode.children, { isSearchDisplay: true }) ? _lodash2["default"].filter(parentNode.children, { isSearchDisplay: true }) : parentNode.children;
var parentNode = (0, _get3.default)(this.props.tree, parentPath);
var filteredChildren = parentNode.children.some(function (child) {
return child.isSearchDisplay === true;
}) ? parentNode.children.filter(function (child) {
return child.isSearchDisplay === true;
}) : parentNode.children;
var itemKey = "infinity-menu-leaf-" + curr.id;

@@ -256,9 +261,9 @@ var visIds = filteredChildren.map(function (e) {

onMouseDown: function onMouseDown(e) {
_this2.props.onLeafMouseDown ? _this2.props.onLeafMouseDown(e, curr) : null;
_this3.props.onLeafMouseDown ? _this3.props.onLeafMouseDown(e, curr) : null;
},
onMouseUp: function onMouseUp(e) {
_this2.props.onLeafMouseUp ? _this2.props.onLeafMouseUp(e, curr) : null;
_this3.props.onLeafMouseUp ? _this3.props.onLeafMouseUp(e, curr) : null;
},
onClick: function onClick(e) {
_this2.props.onLeafMouseClick ? _this2.props.onLeafMouseClick(e, curr) : null;
_this3.props.onLeafMouseClick ? _this3.props.onLeafMouseClick(e, curr) : null;
},

@@ -269,19 +274,19 @@ name: curr.name,

};
prevs.push(_react2["default"].createElement(currCustomComponent, componentProps));
prevs.push(_react2.default.createElement(currCustomComponent, componentProps));
} else {
prevs.push(_react2["default"].createElement(
prevs.push(_react2.default.createElement(
"li",
{ key: itemKey,
className: "infinity-menu-leaf-container",
onMouseDown: function (e) {
return _this2.props.onLeafMouseDown ? _this2.props.onLeafMouseDown(e, curr) : null;
onMouseDown: function onMouseDown(e) {
return _this3.props.onLeafMouseDown ? _this3.props.onLeafMouseDown(e, curr) : null;
},
onMouseUp: function (e) {
return _this2.props.onLeafMouseUp ? _this2.props.onLeafMouseUp(e, curr) : null;
onMouseUp: function onMouseUp(e) {
return _this3.props.onLeafMouseUp ? _this3.props.onLeafMouseUp(e, curr) : null;
},
onClick: function (e) {
return _this2.props.onLeafMouseClick ? _this2.props.onLeafMouseClick(e, curr) : null;
onClick: function onClick(e) {
return _this3.props.onLeafMouseClick ? _this3.props.onLeafMouseClick(e, curr) : null;
}
},
_react2["default"].createElement(
_react2.default.createElement(
"span",

@@ -300,5 +305,5 @@ null,

};
prevs.push(_react2["default"].createElement(currCustomloadMoreComponent, loadMoreProps));
prevs.push(_react2.default.createElement(currCustomloadMoreComponent, loadMoreProps));
} else {
prevs.push(_react2["default"].createElement(
prevs.push(_react2.default.createElement(
"li",

@@ -309,3 +314,3 @@ { key: itemKey,

},
_react2["default"].createElement(
_react2.default.createElement(
"span",

@@ -336,5 +341,5 @@ null,

};
prevs.push(_react2["default"].createElement(currCustomComponent, nodeProps));
prevs.push(_react2.default.createElement(currCustomComponent, nodeProps));
} else {
prevs.push(_react2["default"].createElement(
prevs.push(_react2.default.createElement(
"div",

@@ -345,3 +350,3 @@ { key: key,

},
_react2["default"].createElement(
_react2.default.createElement(
"label",

@@ -359,3 +364,3 @@ null,

if (curr.customComponent) {
var nodeProps = {
var _nodeProps = {
onClick: this.onNodeClick.bind(this, tree, curr, keyPath),

@@ -368,5 +373,5 @@ name: nodeName,

};
openedNode.push(_react2["default"].createElement(currCustomComponent, nodeProps));
openedNode.push(_react2.default.createElement(currCustomComponent, _nodeProps));
} else {
openedNode.push(_react2["default"].createElement(
openedNode.push(_react2.default.createElement(
"div",

@@ -377,3 +382,3 @@ { key: key,

},
_react2["default"].createElement(
_react2.default.createElement(
"label",

@@ -390,7 +395,7 @@ null,

}
return _this2.setDisplayTree(tree, p, c, keyPath + ".children." + k);
return _this3.setDisplayTree(tree, p, c, keyPath + ".children." + k);
}, []) : [];
if (childrenList.length > 0) {
openedNode.push(_react2["default"].createElement(
openedNode.push(_react2.default.createElement(
"ul",

@@ -407,3 +412,2 @@ { key: "infinity-menu-children-list" + currLevel },

}
/*

@@ -413,13 +417,15 @@ * @function _renderBody

*/
}, {
key: "renderBody",
value: function renderBody(displayTree) {
var _props = this.props;
var emptyTreeComponent = _props.emptyTreeComponent;
var emptyTreeComponentProps = _props.emptyTreeComponentProps;
var _props = this.props,
emptyTreeComponent = _props.emptyTreeComponent,
emptyTreeComponentProps = _props.emptyTreeComponentProps;
if (displayTree.length) {
return displayTree;
} else if (emptyTreeComponent) {
var emptyTreeElement = _react2["default"].createElement(emptyTreeComponent, emptyTreeComponentProps);
var emptyTreeElement = _react2.default.createElement(emptyTreeComponent, emptyTreeComponentProps);
return emptyTreeElement;

@@ -430,3 +436,2 @@ } else {

}
/*

@@ -436,6 +441,7 @@ * @function render

*/
}, {
key: "render",
value: function render() {
var _this3 = this;
var _this4 = this;

@@ -448,3 +454,3 @@ var tree = this.props.tree;

}
return _this3.findFiltered(prev, curr, key);
return _this4.findFiltered(prev, curr, key);
}, []) : tree;

@@ -457,3 +463,3 @@

}
return _this3.setDisplayTree(tree, prev, curr, key.toString());
return _this4.setDisplayTree(tree, prev, curr, key.toString());
}, []);

@@ -471,10 +477,10 @@

var bodyContent = this.renderBody(displayTree);
var defaultHeaderContent = this.props.disableDefaultHeaderContent ? null : _react2["default"].createElement(_searchInput2["default"], headerProps);
var headerContent = this.props.headerContent ? _react2["default"].createElement(this.props.headerContent, headerProps) : defaultHeaderContent;
var defaultHeaderContent = this.props.disableDefaultHeaderContent ? null : _react2.default.createElement(_searchInput2.default, headerProps);
var headerContent = this.props.headerContent ? _react2.default.createElement(this.props.headerContent, headerProps) : defaultHeaderContent;
return _react2["default"].createElement(
return _react2.default.createElement(
"div",
{ className: "infinity-menu-container" },
headerContent,
_react2["default"].createElement(
_react2.default.createElement(
"div",

@@ -489,21 +495,22 @@ { className: "infinity-menu-display-tree-container" },

return InfinityMenu;
})(_react2["default"].Component);
}(_react2.default.Component);
exports["default"] = InfinityMenu;
exports.default = InfinityMenu;
InfinityMenu.propTypes = {
tree: _react2["default"].PropTypes.array,
headerContent: _react2["default"].PropTypes.any,
disableDefaultHeaderContent: _react2["default"].PropTypes.bool,
headerProps: _react2["default"].PropTypes.object,
customComponentMappings: _react2["default"].PropTypes.object,
emptyTreeComponent: _react2["default"].PropTypes.any,
emptyTreeComponentProps: _react2["default"].PropTypes.object,
filter: _react2["default"].PropTypes.func,
onNodeMouseClick: _react2["default"].PropTypes.func,
onLeafMouseClick: _react2["default"].PropTypes.func,
onLeafMouseDown: _react2["default"].PropTypes.func,
onLeafMouseUp: _react2["default"].PropTypes.func,
shouldComponentUpdate: _react2["default"].PropTypes.func,
maxLeaves: _react2["default"].PropTypes.number
tree: _react2.default.PropTypes.array,
headerContent: _react2.default.PropTypes.any,
disableDefaultHeaderContent: _react2.default.PropTypes.bool,
headerProps: _react2.default.PropTypes.object,
customComponentMappings: _react2.default.PropTypes.object,
emptyTreeComponent: _react2.default.PropTypes.any,
emptyTreeComponentProps: _react2.default.PropTypes.object,
filter: _react2.default.PropTypes.func,
onNodeMouseClick: _react2.default.PropTypes.func,
onLeafMouseClick: _react2.default.PropTypes.func,
onLeafMouseDown: _react2.default.PropTypes.func,
onLeafMouseUp: _react2.default.PropTypes.func,
shouldComponentUpdate: _react2.default.PropTypes.func,
maxLeaves: _react2.default.PropTypes.number
};

@@ -526,3 +533,2 @@

maxLeaves: Infinity
};
module.exports = exports["default"];
};

@@ -7,17 +7,17 @@ "use strict";

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; }; })();
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; }; }();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _react = require("react");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var SearchInput = (function (_React$Component) {
var SearchInput = function (_React$Component) {
_inherits(SearchInput, _React$Component);

@@ -28,3 +28,3 @@

_get(Object.getPrototypeOf(SearchInput.prototype), "constructor", this).apply(this, arguments);
return _possibleConstructorReturn(this, (SearchInput.__proto__ || Object.getPrototypeOf(SearchInput)).apply(this, arguments));
}

@@ -35,3 +35,3 @@

value: function render() {
return _react2["default"].createElement("input", {
return _react2.default.createElement("input", {
className: "react-infinity-menu-default-search-input",

@@ -43,5 +43,4 @@ onClick: this.props.startSearching, value: this.props.searchInput, onChange: this.props.setSearchInput });

return SearchInput;
})(_react2["default"].Component);
}(_react2.default.Component);
exports["default"] = SearchInput;
module.exports = exports["default"];
exports.default = SearchInput;
{
"name": "react-infinity-menu",
"version": "3.1.0",
"version": "3.2.0",
"description": "An unlimited deep side menu",
"main": "./dist/infinity-menu.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register --recursive",
"test": "./node_modules/.bin/eslint ./src/ ./test/ && mocha --compilers js:babel-core/register --recursive",
"build": "babel src -d dist",

@@ -27,9 +27,13 @@ "watch": "babel src --watch -d dist",

"devDependencies": {
"babel": "^5.8.23",
"babel-core": "^5.8.25",
"babel-loader": "^5.3.2",
"babel": "^6.23.0",
"babel-cli": "^6.23.0",
"babel-core": "^6.23.1",
"babel-loader": "^6.2.10",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"css-loader": "^0.21.0",
"eslint": "^0.23.0",
"eslint-loader": "^0.14.0",
"eslint-plugin-react": "^2.7.1",
"eslint": "^3.15.0",
"eslint-plugin-react": "^6.9.0",
"jsdom": "^6.5.1",

@@ -36,0 +40,0 @@ "mocha": "^2.3.3",

import React from "react";
import SearchInput from "./search-input";
import NestedObjects from "nested-objects";
import _ from 'lodash'
import _get from "lodash/get";

@@ -47,5 +47,5 @@ /*

// get parent node so we can increment it's unique max leaves property
const keyPathArray = keyPath.split('.')
const parentPath = Object.assign([],keyPathArray).splice(0, keyPathArray.length - 2)
const parentNode = _.get(this.props.tree, parentPath)
const keyPathArray = keyPath.split(".");
const parentPath = Object.assign([],keyPathArray).splice(0, keyPathArray.length - 2);
const parentNode = _get(this.props.tree, parentPath);
// set new max leaves - if none exist use component default property

@@ -155,4 +155,4 @@ parentNode.maxLeaves = (!parentNode.maxLeaves) ? this.props.maxLeaves : parentNode.maxLeaves + this.props.maxLeaves;

const currLevel = Math.floor(keyPath.length / 2);
const currCustomComponent = typeof curr.customComponent === 'string' ? this.props.customComponentMappings[curr.customComponent] : curr.customComponent;
const currCustomloadMoreComponent = (this.props.loadMoreComponent) ? this.props.loadMoreComponent : null
const currCustomComponent = typeof curr.customComponent === "string" ? this.props.customComponentMappings[curr.customComponent] : curr.customComponent;
const currCustomloadMoreComponent = (this.props.loadMoreComponent) ? this.props.loadMoreComponent : null;
const isSearching = this.state.search.isSearching && this.state.search.searchInput;

@@ -164,14 +164,19 @@ const shouldDisplay = (isSearching && curr.isSearchDisplay) || !isSearching;

if (!curr.children) {
const keyPathArray = keyPath.split('.')
const parentPath = Object.assign([],keyPathArray).splice(0, keyPathArray.length - 2)
const parentNode = _.get(this.props.tree, parentPath)
const filteredChildren = (_.some(parentNode.children,{isSearchDisplay: true})) ? _.filter(parentNode.children,{isSearchDisplay: true}) : parentNode.children
const keyPathArray = keyPath.split(".");
const parentPath = Object.assign([],keyPathArray).splice(0, keyPathArray.length - 2);
const parentNode = _get(this.props.tree, parentPath);
const filteredChildren = (
parentNode.children.some(child => child.isSearchDisplay === true)
?
parentNode.children.filter(child => child.isSearchDisplay === true)
:
parentNode.children
);
const itemKey = "infinity-menu-leaf-" + curr.id;
const visIds = filteredChildren.map((e) => e.id)
const visIds = filteredChildren.map((e) => e.id);
let relativeIndex = visIds.indexOf(curr.id);
relativeIndex = (relativeIndex === -1) ? Infinity : relativeIndex;
let relativeIndex = visIds.indexOf(curr.id)
relativeIndex = (relativeIndex === -1) ? Infinity : relativeIndex
let parentMaxLeaves = parentNode.maxLeaves || this.props.maxLeaves
let parentMaxLeaves = parentNode.maxLeaves || this.props.maxLeaves;
if (shouldDisplay && parentMaxLeaves > relativeIndex ) {

@@ -181,5 +186,11 @@ if (curr.customComponent) {

key: itemKey,
onMouseDown: (e) => {this.props.onLeafMouseDown ? this.props.onLeafMouseDown(e, curr) : null},
onMouseUp: (e) => {this.props.onLeafMouseUp ? this.props.onLeafMouseUp(e, curr) : null},
onClick: (e) => {this.props.onLeafMouseClick ? this.props.onLeafMouseClick(e, curr) : null},
onMouseDown: (e) => {
this.props.onLeafMouseDown ? this.props.onLeafMouseDown(e, curr) : null;
},
onMouseUp: (e) => {
this.props.onLeafMouseUp ? this.props.onLeafMouseUp(e, curr) : null;
},
onClick: (e) => {
this.props.onLeafMouseClick ? this.props.onLeafMouseClick(e, curr) : null;
},
name: curr.name,

@@ -203,12 +214,13 @@ icon: curr.icon,

}
} else {
}
else {
if (relativeIndex === filteredChildren.length - 1) {
if (currCustomloadMoreComponent) {
const loadMoreProps = {
key: itemKey,
onClick: this.onLoadMoreClick.bind(this, tree, curr, keyPath)
};
prevs.push(React.createElement(currCustomloadMoreComponent, loadMoreProps));
} else {
const loadMoreProps = {
key: itemKey,
onClick: this.onLoadMoreClick.bind(this, tree, curr, keyPath)
};
prevs.push(React.createElement(currCustomloadMoreComponent, loadMoreProps));
}
else {
prevs.push(

@@ -215,0 +227,0 @@ <li key={itemKey}

@@ -17,4 +17,3 @@ import React from "react";

const tree =
[
{
[{
name: "menu1",

@@ -62,4 +61,3 @@ id: 1,

]
}
];
}];
component = <InfinityMenu tree={tree} />;

@@ -73,2 +71,2 @@ });

});
});
});

@@ -58,36 +58,34 @@ import React from "react";

it("should render the custom component when given as a string with mappings", function () {
const tree = [
const tree = [{
name: "menu1",
id: 1,
isOpen: true,
customComponent: "CustomComponent",
children: [
{
name: "menu1",
name: "submenu1",
id: 1,
isOpen: true,
customComponent: 'CustomComponent',
children: [
{
name: "submenu1",
id: 1,
isOpen: true,
children: [
{
name: "item1-1",
id: 1
},
{
name: "item1-2",
id: 2
}
]
name: "item1-1",
id: 1
},
{
name: "item1-2",
id: 2
}
]
}
];
component = <InfinityMenu tree={tree} customComponentMappings={{ 'CustomComponent': CustomComponent }}/>;
dom = TestUtils.renderIntoDocument(component);
should.doesNotThrow(() => {
TestUtils.findRenderedDOMComponentWithClass(
dom,
"test-custom-component"
);
});
]
}];
component = <InfinityMenu tree={tree} customComponentMappings={{ "CustomComponent": CustomComponent }}/>;
dom = TestUtils.renderIntoDocument(component);
should.doesNotThrow(() => {
TestUtils.findRenderedDOMComponentWithClass(
dom,
"test-custom-component"
);
});
});
});

@@ -28,3 +28,3 @@ import React from "react";

"dummy-empty-tree-component"
)
);
});

@@ -55,2 +55,2 @@ });

});
});
});
module.exports = {
entry: {
'example/compiled/index': './example/src/index'
},
entry: { "example/compiled/index": "./example/src/index" },
output: {
path: '.',
filename: '[name].js',
publicPath: '/example/compiled/'
path: ".",
filename: "[name].js",
publicPath: "/example/compiled/"
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?optional=es7.objectRestSpread'},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
query: { presets: [ "es2015" ] }
},
{ test: /\.css$/, loader: "style-loader!css-loader" }

@@ -16,0 +17,0 @@ ]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc