react-infinity-menu
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -7,2 +7,4 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
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; }; })(); | ||
@@ -330,3 +332,3 @@ | ||
/*header component*/ | ||
var headerProps = { | ||
var headerProps = _extends({ | ||
isSearching: this.state.search.isSearching, | ||
@@ -338,3 +340,3 @@ searchInput: this.state.search.searchInput, | ||
onClose: this.props.onClose | ||
}; | ||
}, this.props.headerProps); | ||
var headerContent = this.props.headerContent ? _react2["default"].createElement(this.props.headerContent, headerProps) : null; | ||
@@ -358,2 +360,3 @@ | ||
tree: _react2["default"].PropTypes.array, | ||
headerProps: _react2["default"].PropTypes.object, | ||
onNodeMouseClick: _react2["default"].PropTypes.func, | ||
@@ -368,2 +371,3 @@ onLeafMouseClick: _react2["default"].PropTypes.func, | ||
tree: [], | ||
headerProps: {}, | ||
onNodeMouseClick: function onNodeMouseClick() {}, | ||
@@ -370,0 +374,0 @@ onLeafMouseClick: function onLeafMouseClick() {}, |
{ | ||
"name": "react-infinity-menu", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"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", |
@@ -6,2 +6,3 @@ # react-infinity-menu | ||
* An unlimited deep side menu | ||
* [Live Demo](http://socialtables.github.io/react-infinity-menu/) | ||
@@ -117,4 +118,20 @@ # Demo | ||
``` | ||
#### headerContent(component) subcomponent rendered above the tree | ||
`headerContent` is passed in to `InfinityMenu`. It is rendered above the tree subcomponent. | ||
#### headerProps(object) additional props for headerContent | ||
`headerProps` is an optional prop of InfinityMenu. The props in this object are passed as props to a `headerContent` component. This is useful when extending InfinityMenu. | ||
Passing the following into InfinityMenu as the `headerProps` prop sets the `title` prop on the headerContent component. | ||
``` | ||
{ | ||
title: "my great title" | ||
} | ||
``` | ||
#### customComponent is a React component the user can pass in. | ||
* As the `customComponent` at the node level, you will receive props `key`, `onClick`, `name`, `isOpen` and `isSearching`. | ||
* As the `customComponent` at the node level, you will receive props `key`, `onClick`, `name`, `isOpen`, `data` and `isSearching`. | ||
* As the `customComponent` at the leaf level, you will receive props `key`, `onMouseDown`, `onMouseUp`, `onClick`, `name`, `icon` and `data`. | ||
@@ -121,0 +138,0 @@ |
@@ -269,3 +269,4 @@ import React from "react"; | ||
startSearching: this.startSearching, | ||
onClose: this.props.onClose | ||
onClose: this.props.onClose, | ||
...this.props.headerProps | ||
}; | ||
@@ -285,2 +286,3 @@ const headerContent = this.props.headerContent ? React.createElement(this.props.headerContent, headerProps) : null; | ||
tree: React.PropTypes.array, | ||
headerProps: React.PropTypes.object, | ||
onNodeMouseClick: React.PropTypes.func, | ||
@@ -295,2 +297,3 @@ onLeafMouseClick: React.PropTypes.func, | ||
tree: [], | ||
headerProps: {}, | ||
onNodeMouseClick: ()=>{}, | ||
@@ -297,0 +300,0 @@ onLeafMouseClick: ()=>{}, |
@@ -85,2 +85,21 @@ import React from "react/addons"; | ||
it("should render correctly pass headerProps to the headerContent", function () { | ||
class Doge extends React.Component{ | ||
render() { | ||
return ( | ||
<div>{this.props.breed}</div> | ||
); | ||
} | ||
} | ||
component = <InfinityMenu | ||
headerProps={{breed: "shiba"}} | ||
headerContent={Doge} | ||
/>; | ||
shallowRenderer.render(component); | ||
const result = shallowRenderer.getRenderOutput(); | ||
assert.equal(result.props.children[0].props.breed, "shiba"); | ||
}); | ||
it("should render correctly with folder tree", function () { | ||
@@ -87,0 +106,0 @@ shallowRenderer.render(component); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
355419
918
177