{"_id":"@dankolz/kalpa-tree","_rev":"1-12b9591d13f561a577bb2743b66ffe35","name":"@dankolz/kalpa-tree","dist-tags":{"latest":"3.3.1"},"versions":{"3.3.1":{"name":"@dankolz/kalpa-tree","version":"3.3.1","description":"An efficient hierarchical tree for the dom","main":"index.js","dependencies":{"d3-drag":"^1.0.1","d3-selection":"^1.0.2","d3-transition":"^1.0.3","escape-string-regexp":"^1.0.3","node-sass":"^4.9.0","optional-require":"^1.0.3","scoreboard-colors":"git+ssh://git@github.com/SpiderStrategies/scoreboard-colors.git#v4.2.0"},"devDependencies":{"JSONStream":"^1.0.6","browserify":"^12.0.1","browserify-css":"^0.8.1","double-tap":"^1.0.2","request":"^2.36.0","smokestack":"^3.4.1","tape":"^3.5.0","watchify":"^3.6.1"},"scripts":{"bundle":"browserify -r ./index.js:tree -r http -r JSONStream > example/bundle.js -d","css":"node scripts/css.js","postinstall":"npm run css","start":"node example/server.js","test":"browserify -t browserify-css test/* | double-tap smokestack","watch":"watchify -r ./index.js:tree -r http -r JSONStream -o example/bundle.js -d"},"optionalDependencies":{"scoreboard-colors":"git+ssh://git@github.com/SpiderStrategies/scoreboard-colors.git#v4.2.0"},"repository":{"type":"git","url":"git://github.com/SpiderStrategies/kalpa-tree.git"},"author":{"name":"Nathan Bowser","email":"nathan.bowser@spiderstrategies.com"},"license":"ISC","bugs":{"url":"https://github.com/SpiderStrategies/kalpa-tree/issues"},"homepage":"https://github.com/SpiderStrategies/kalpa-tree","gitHead":"4e71ab597df3fa74d12a34a0a4e4b2e31aa3c48f","_id":"@dankolz/kalpa-tree@3.3.1","_nodeVersion":"10.22.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-VpZLSxF4b4bkk5yX4Ksfp1W1Xm4LUnsvFLLh0ffiiSWzpMzWAVf/s+FsQOYQhZ9pi2X7SJqznCLtIRLhHCnlxw==","shasum":"e2cfdd4f799d06323f99c04f223b9b80bb6eef6d","tarball":"https://registry.npmjs.org/@dankolz/kalpa-tree/-/kalpa-tree-3.3.1.tgz","fileCount":40,"unpackedSize":2360743,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfgeaCRA9TVsSAnZWagAAVOkQAKPw8CIOIXFspB1/m/co\nbtl3hnF1BvVDYmnhzj7IF5YdThPpnbgZFgQD5op68i9luw36dK+30/l2/KVH\n0g/8cDUX9AsyDZRXyrY6T3tDx/vNA0l3koavMHbWjgk34ui8w5DxgVGwn8qH\n/s0DdrhbIJBfgjoBbVaoEc1o5J3L9pztI8kJ7w5QQy4HDJGzqpRMvM7nkO22\nF/quYdAcYkgoTJ0EBevVQJvd1zOAIlu1kA04RZ82jnohJI6NAbcZxEIkcxSz\nYsCQ8vb+djVifsSnadLROupEYFJJxrZUNSWwgnfNe6PxhfvEoFzQm6aDSWMk\nLcktfc+v/AUHllbp3poEw74ZF6l2MU7NV5Nu+AGsgee+RzD7dLCPJT9j/1H/\nktVyqsoD0ErVENhkXpIEGsJWYQpWD8Th/GzEml7gcDxXEAinDBeSBC6EwsWF\n/3MAH8T7VyDBgXfMgZI7H07JDo7vbEyf4ogihDoUu35BEhFeJ8OQxIsxKaTB\nxfHszzeWK8RyAv2+fpms+5bjTlIiZABQvVbHKyZVKUCgrvRhI9Gm3KkbAAHQ\n9uL5/M8GeNMldnUuczlBHcw/53JY8QGS9fJOXF/KvxB1PjMgKluXM7DmfG2v\ndD8EWhekBF/XcxqBvhroNKrTBiLgcty2b0I/STkY+UgicsotaDg8U8Fngvz4\nybIT\r\n=3Mwl\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYLChNdy0upbioPlcI4cb/zRoJM4W95ZgXBxoICGJ85gIgG3fBwhyQY4gHkeTSB+HaRMGPtkSuFo2xCRYHQU2c10w="}]},"_npmUser":{"name":"dankolz","email":"dan@emergentideas.com"},"directories":{},"maintainers":[{"name":"dankolz","email":"dan@emergentideas.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/kalpa-tree_3.3.1_1618872217475_0.4013362442242472"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-19T22:43:37.399Z","3.3.1":"2021-04-19T22:43:37.676Z","modified":"2022-04-05T02:41:57.246Z"},"maintainers":[{"name":"dankolz","email":"dan@emergentideas.com"}],"description":"An efficient hierarchical tree for the dom","homepage":"https://github.com/SpiderStrategies/kalpa-tree","repository":{"type":"git","url":"git://github.com/SpiderStrategies/kalpa-tree.git"},"author":{"name":"Nathan Bowser","email":"nathan.bowser@spiderstrategies.com"},"bugs":{"url":"https://github.com/SpiderStrategies/kalpa-tree/issues"},"license":"ISC","readme":"## kalpa-tree\n\n[![Build Status](https://travis-ci.org/SpiderStrategies/kalpa-tree.svg?branch=master)](https://travis-ci.org/SpiderStrategies/kalpa-tree)\n\nKalpa tree is an implementation of a hierarchical tree. It receives a stream of nodes, each data event on the stream represents a node in the tree.\nThe tree is built using d3, and can handle 50K+ nodes easily. It's optimized for performance so it doesn't overload the browser if there's a lot of data.\n\nView a live example:  http://spiderstrategies.github.io/kalpa-tree/\n\n## Code Example\n\nSee `example/index.html`\n\nTo open the example page locally:\n\n```\n$ npm install\n$ npm start // Builds a test server\n$ npm run watch\n```\nOpen your browser to http://localhost:3000\n\n## API Reference\n\nTo build the tree\n```\nvar tree = new Tree({\n  stream: stream, // Stream of data where each data event represents a node\n})\n```\n\nHandle errors\n```\ntree.on('error', function (e) {\n  // Blue smoke\n})\n```\n\nHandle move events if the user initiated dnd\n```\ntree.on('move', function (node, newParent, previousParent, newIndex, prevIndex) {\n\n})\n```\n\nListen for the start of dnd\n```\ntree.on('dndstart', function (eventData) {\n  // eventData.el -> The DOM node the user is moving\n  // eventData.traveler -> The DOM traveling node created by the tree which can actually be moved\n  // eventData.layout -> Layout data describing the moving node\n  // eventData.data -> Data bound to this tree node\n})\n```\n\nListen for changes when the dnd traveling node moves (basically mouse movements which are swallowed by d3-drag)\n```\ntree.on('dndmove', function (eventData) {\n  // eventData.traveler -> The DOM traveling node created by the tree which can actually be moved\n  // eventData.layout -> Layout data describing the moving node\n  // eventData.data -> Data bound to this tree node\n})\n```\n\nHook for when dnd has finished\n```\ntree.on('dndstop', function (eventData) {\n  // eventData.el -> The DOM node the user is moving\n  // eventData.traveler -> The DOM traveling node created by the tree which can actually be moved\n  // eventData.layout -> Layout data describing the moving node\n  // eventData.data -> Data bound to this tree node\n})\n```\n\nListen to tree `select` events\n```\ntree.on('select', function (node) {\n  // node is the node the user selected\n})\n```\n\nOverridable options:\n\n```\nnew Tree({\n  transientId: -1, // Node's that are `placeholders` are not part of the tree yet.\n  toggleOnSelect: true, // By default each select will toggle the node if needed. This prevents the toggle\n  depth: 20, // indentation depth\n  height: 36, // height of each row (Would need to override with css as well)\n  rootHeight: 36, // root node height can be overridden\n  maxAnimatable: 100, // Disable css animations if a node has children greater than this amount\n  indicator: false, // show indicator light nodes on the right\n  forest: false, // Must be `true` if the tree has multiple root nodes (for example, a list)\n  movable: function (d) { // control if a node can be moved\n    // `d` is the node\n    // `this` is a reference to the tree\n    return true\n  },\n  droppable: function (d, parent) {\n    // `d` is the node being moved\n    // `parent` is its new parent. May be undefined if node is being moved to root in a forest tree\n    // `this` is a reference to the tree\n    return true // By default, any node can be dropped on any other node\n  },\n  label: function (selection) {\n    // This call be used to override how the label is drawn using the default\n    // `contents`\n  },\n  contents: require('./lib/contents'), // Override the default html structure of each node\n  performanceThreshold: 1000, // If the node data count exceeds this threshold, the tree goes into performance mode\n  accessors: { // Used to grab information out of the data object in the stream\n    id: 'id',\n    label: 'label',\n    icon: 'icon',\n    color: 'color'\n  }\n})\n```\n\nGrab a parent node\n```\ntree.parent(node)\n// or\ntree.parent(nodeId)\n```\n\nReturn all children\n```\ntree.children(node)\n// or\ntree.children(nodeId)\n```\n\nReturn a node's next sibling\n```\ntree.nextSibling(node)\n// or\ntree.nextSibling(nodeId)\n```\n\nReturn a node's previous sibling\n```\ntree.previousSibling(node)\n// or\ntree.previousSibling(nodeId)\n```\n\nMove a node\n```\ntree.move(node, to)\n```\n\nCopy a node -- Copies a node to some new parent. `transformer` can be used to transform\neach node that will be copied.\n\nIf to is missing and the tree is a forest, the node will be copied to a new root node of the forest tree.\n```\ntree.copy(node, to, transformer)\n```\n\nSelect a node -- The node is marked selected and shown in the tree\n  opt supports:\n     - silent: Don't fire the select event\n     - toggleOnSelect: Don't toggle the node if it has children, just select it\n     - animate: Disable animations\n     - force: Forces a select. Can be used to bypass the no-op selection if the node is already selected. This forces a redraw.\n```\ntree.select(id, opt)\n\n```\n\nGet -- Returns a node object by id. This searches all the underlying data, not just the visible nodes.\n      if no id is sent, returns the root, essentially the entire tree\n```\ntree.get(id)\n```\n\nSelect a node\n```\ntree.selected()\n```\n\nReturns the currently selected node's dom element\n```\ntree.selectedEl\n```\n\nAdd --  Adds a new node to the tree. Pass in d as the data that represents the node,\n        parent (which can be the parent object or an id), and an optional\n        index. If the index is sent, the node will be inserted at that index within the\n        parent's children.\n```\ntree.add(d, parent, idx)\n```\n\nisEditable -- Determine if the tree is in edit mode\n```\ntree.isEditable()\n```\n\nEditable -- Mark the tree as being in an editable state\n```\ntree.editable()\n```\n\nexpandAll -- Expand all node's in the tree\n```\ntree.expandAll()\n```\n\ncollapseAll -- Collapse all node's in the tree\n```\ntree.collapseAll()\n```\n\nedit -- Makes modifications to tree node(s). Can update a single node, an array of patch\n        changes, or a stream that emits data events with the node and the changes\n```\ntree.edit(obj)\n```\n\nremove -- Cleanup the tree object and remove it from the dom\n```\ntree.remove()\n```\n\nremoveNode -- Removes a node from the tree.\n```\ntree.removeNode(node)\n// or\ntree.removeNode(id)\n```\n\nSearch -- Search the tree node's labels for the `term`\n```\ntree.search(term)\n```\n\nToggle -- Used to toggle the node's children. If they are visible this will hide them, and\n          if they are hidden, this will show them.\n```\ntree.toggle(d, opt)\n```\n\n### Transient nodes --\nTransient nodes have special meaning in the tree. Usually a transient node represents a node that hasn't yet\nbeen persisted to the server.\n\n```\ntree.addTransient(d, parent, idx)\ntree.getTransient()\ntree.editTransient(d)\ntree.saveTransient(id)\ntree.removeTransient()\n```\n\n## Tests\n\nRun the test against phantom\n\n`npm run test`\n\nTo run them in a browser\n\n`npm run test-browser`\n\n## License\n\nISC\n","readmeFilename":"README.md"}