Socket
Socket
Sign inDemoInstall

react-infinity-menu

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-infinity-menu - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

74

dist/infinity-menu.js

@@ -168,5 +168,15 @@ "use strict";

}
/*
* @function setDisplayTree
* @description recursive go through the tree and set the render tree
*
* @param {array} tree - whole tree
* @param {array} prevs - the whole rendering array
* @param {object} curr - current node/leaf
* @param {string} keyPath - the path to current node/leaf, e.g. "0.children.1"
*/
}, {
key: "setDisplayFolders",
value: function setDisplayFolders(tree, prevs, curr, keyPath) {
key: "setDisplayTree",
value: function setDisplayTree(tree, prevs, curr, keyPath) {
var _this2 = this;

@@ -224,2 +234,3 @@

isSearching: false,
data: curr,
key: key

@@ -247,28 +258,25 @@ };

/*unname folder is not showing as parent*/
var isDefault = curr.name === "";
if (!isDefault) {
if (curr.customComponent) {
var nodeProps = {
if (curr.customComponent) {
var nodeProps = {
onClick: this.onNodeClick.bind(this, tree, curr, keyPath),
name: nodeName,
isOpen: curr.isOpen,
data: curr,
key: key,
isSearching: isSearching
};
openedNode.push(_react2["default"].createElement(curr.customComponent, nodeProps));
} else {
openedNode.push(_react2["default"].createElement(
"div",
{ key: key,
onClick: this.onNodeClick.bind(this, tree, curr, keyPath),
name: nodeName,
isOpen: curr.isOpen,
key: key,
isSearching: isSearching
};
openedNode.push(_react2["default"].createElement(curr.customComponent, nodeProps));
} else {
openedNode.push(_react2["default"].createElement(
"div",
{ key: key,
onClick: this.onNodeClick.bind(this, tree, curr, keyPath),
className: "infinity-menu-node-container"
},
_react2["default"].createElement(
"label",
null,
nodeName
)
));
}
className: "infinity-menu-node-container"
},
_react2["default"].createElement(
"label",
null,
nodeName
)
));
}

@@ -280,3 +288,3 @@

}
return _this2.setDisplayFolders(tree, p, c, keyPath + ".children." + k);
return _this2.setDisplayTree(tree, p, c, keyPath + ".children." + k);
}, []) : [];

@@ -309,3 +317,3 @@

/*find filtered folders base on search, if there no search, return all*/
var filteredFolders = this.state.search.isSearching && this.state.search.searchInput.length ? tree.reduce(function (prev, curr, key) {
var filteredTree = this.state.search.isSearching && this.state.search.searchInput.length ? tree.reduce(function (prev, curr, key) {
if (key === undefined) {

@@ -317,9 +325,11 @@ return prev;

var displayFolders = filteredFolders.reduce(function (prev, curr, key) {
/*recursive go through the tree*/
var displayTree = filteredTree.reduce(function (prev, curr, key) {
if (key === undefined) {
return prev;
}
return _this3.setDisplayFolders(tree, prev, curr, key.toString());
return _this3.setDisplayTree(tree, prev, curr, key.toString());
}, []);
/*header component*/
var headerProps = {

@@ -339,3 +349,3 @@ isSearching: this.state.search.isSearching,

headerContent,
displayFolders
displayTree
);

@@ -342,0 +352,0 @@ }

{
"name": "react-infinity-menu",
"version": "1.0.4",
"version": "1.0.5",
"description": "[![Circle CI](https://circleci.com/gh/socialtables/react-infinity-menu.svg?style=svg&circle-token=230aaa396d006f1dc8d875b340834234c4937bbc)](https://circleci.com/gh/socialtables/react-infinity-menu)",

@@ -5,0 +5,0 @@ "main": "./dist/infinity-menu.js",

@@ -67,5 +67,5 @@ # react-infinity-menu

{
name: "menu1",
id: 1,
isOpen: true,
name: "menu1", /*require*/
id: 1, /*require*/
isOpen: true, /*require*/
customComponent: YOUR_OWN_COMPONENT_FOR_MENU,

@@ -104,6 +104,6 @@ children: [

{
name: "menu2",
id: 2,
name: "menu2", /*require*/
id: 2, /*require*/
isOpen: true, /*require*/
customComponent: YOUR_OWN_COMPONENT_FOR_MENU,
isOpen: true,
children: [

@@ -110,0 +110,0 @@ {

@@ -124,3 +124,12 @@ import React from "react";

setDisplayFolders(tree, prevs, curr, keyPath) {
/*
* @function setDisplayTree
* @description recursive go through the tree and set the render tree
*
* @param {array} tree - whole tree
* @param {array} prevs - the whole rendering array
* @param {object} curr - current node/leaf
* @param {string} keyPath - the path to current node/leaf, e.g. "0.children.1"
*/
setDisplayTree(tree, prevs, curr, keyPath) {
const currLevel = Math.floor(keyPath.length / 2);

@@ -167,2 +176,3 @@ /*the leaves*/

isSearching: false,
data: curr,
key

@@ -188,26 +198,23 @@ };

/*unname folder is not showing as parent*/
const isDefault = curr.name === "";
if (!isDefault) {
if (curr.customComponent) {
const nodeProps = {
onClick: this.onNodeClick.bind(this, tree, curr, keyPath),
name: nodeName,
isOpen: curr.isOpen,
key,
isSearching
};
openedNode.push(React.createElement(curr.customComponent, nodeProps));
}
else {
openedNode.push(
<div key={key}
onClick={this.onNodeClick.bind(this, tree, curr, keyPath)}
className="infinity-menu-node-container"
>
<label>{nodeName}</label>
</div>
);
}
if (curr.customComponent) {
const nodeProps = {
onClick: this.onNodeClick.bind(this, tree, curr, keyPath),
name: nodeName,
isOpen: curr.isOpen,
data: curr,
key,
isSearching
};
openedNode.push(React.createElement(curr.customComponent, nodeProps));
}
else {
openedNode.push(
<div key={key}
onClick={this.onNodeClick.bind(this, tree, curr, keyPath)}
className="infinity-menu-node-container"
>
<label>{nodeName}</label>
</div>
);
}

@@ -218,3 +225,3 @@ const childrenList = curr.children.length ? curr.children.reduce((p, c, k) => {

}
return this.setDisplayFolders(tree, p, c, keyPath + ".children." + k);
return this.setDisplayTree(tree, p, c, keyPath + ".children." + k);
}, []) : [];

@@ -243,3 +250,3 @@

/*find filtered folders base on search, if there no search, return all*/
const filteredFolders = this.state.search.isSearching && this.state.search.searchInput.length ? tree.reduce((prev, curr, key) => {
const filteredTree = this.state.search.isSearching && this.state.search.searchInput.length ? tree.reduce((prev, curr, key) => {
if (key === undefined) {

@@ -252,9 +259,11 @@ return prev;

const displayFolders = filteredFolders.reduce((prev, curr, key) => {
/*recursive go through the tree*/
const displayTree = filteredTree.reduce((prev, curr, key) => {
if (key === undefined) {
return prev;
}
return this.setDisplayFolders(tree, prev, curr, key.toString());
return this.setDisplayTree(tree, prev, curr, key.toString());
}, []);
/*header component*/
const headerProps = {

@@ -273,3 +282,3 @@ isSearching: this.state.search.isSearching,

{headerContent}
{displayFolders}
{displayTree}
</div>

@@ -276,0 +285,0 @@ );

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc