1.0.5 • Published 2 years ago

mindmapr v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Storyboard here

NPM registry NPM license

Install

# Yarn
yarn add mindmapr
# NPM
npm install --save mindmapr

Props

namerequiredtypedefaultDescription
itemsxobjectA nested object that provides id and children keys. idcan be string or number, children are a list of objects, that also provide id and children. Example: {id: 5, optionalParameter: "will be center item", children: [{id: 6, optionalParameter: "will be child of center item", children: []}]}
renderItemxfunctionA function that returns the ReactNode you want to render as the items of the mindmap. You get the item, the nested depth, and the state as arguments. The state currently only includes isSelected, so you can change the appearance of the rendered item, if it got selected through click or keyboard navigation. Also choose a background color to your item to prevent overlap with the lines. Example: const renderItem = (item, depth, {isSelected}) => (<div>{item.optionalParameter}</div>)
sidestringbothCan either be both, left or right. both will make an usual mindmap, where items are placed left and right of the center item. With left and right you can make a tree, that will only expand in the chosen direction.
addChildKeystringTabThe key to press, if you want to create a child item to the currently selected item. Possible key codes are here.
addChildOnParentLevelKeystringEnterThe key to press, if you want to create an item on the same level as the currently selected item.
deleteItemKeystringDeleteThe key to press, if want to delete the currently selected item
setDatafunctionA function to feed back the changes to your state outside the component. If not provided, the mindmap will be read only
createNewItemfunctionA function that creates new items. The items will be inserted at the correct positions according to the key inputs. As a paraemter, the parent item is available. If you choose to return undefined instead of an item, no item will be added.
overwriteLineStylefunctionIf you want to customize the css properties of the connection lines, you can use this function. Example: const overwriteLineStyle = (depth) => ({stroke: "#ddd", strokeWidth: 1})