{"id":20461067,"url":"https://github.com/ericgj/accordion-tree","last_synced_at":"2025-04-13T06:16:13.094Z","repository":{"id":138269712,"uuid":"9869626","full_name":"ericgj/accordion-tree","owner":"ericgj","description":"No-frills \"Tree View\" component","archived":false,"fork":false,"pushed_at":"2013-05-06T21:34:39.000Z","size":139,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T06:15:57.190Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericgj.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-05T14:32:41.000Z","updated_at":"2023-08-27T04:04:43.000Z","dependencies_parsed_at":"2023-03-11T07:25:43.330Z","dependency_job_id":null,"html_url":"https://github.com/ericgj/accordion-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Faccordion-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Faccordion-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Faccordion-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Faccordion-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericgj","download_url":"https://codeload.github.com/ericgj/accordion-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670438,"owners_count":21142905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T12:23:03.123Z","updated_at":"2025-04-13T06:16:13.062Z","avatar_url":"https://github.com/ericgj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Accordion Tree\n\n  A no-frills \"Tree View\" component.\n\n  Love it or hate it, it's here to stay... \n  \n  \u003cimg alt=\"Example\" src=\"http://i.imgur.com/dJ1mcOT.png\" /\u003e\n\n  See `test/index.html` for example usage.\n  \n  Please note that this component does not currently implement \n  re-ordering of tree structure, etc.\n\n## Installation\n\n    $ component install ericgj/accordion-tree\n\n## Events\n\n  - `selectLeaf(node)`      when a leaf node is selected\n  - `selectBranch(node)`    when a branch node is selected \n  - `select(node, type)`    when any node is selected (type is 'leaf' or 'branch')\n\n## API\n  \n### AccordionTree(el, options)\n\n  Creates a new `AccordionTree` under the given DOM element or selector.\n  See info on the generated structure below.\n\n  The following options are available:\n\n  - `collapse {Boolean}`        allows collapse of selected node (default true)\n  - `multiexpand {Boolean}`     allows expansion of more than one panel per tree \n                                  level (default false)\n  - `branchexpand {Boolean}`    clicking on branch label expands/collapses node, \n                                  in addition to selecting (default true). When \n                                  false, only clicking the caret/icon expands/\n                                  collapses node.\n\n### AccordionTree#addBranch(content,slug)\n\n  Add a branch node with the given content, and (optional) identifying slug.\n  Returns the new node.\n\n### AccordionTree#addLeaf(content,slug)\n\n  Add a leaf node with the given content, and (optional) identifying slug.\n  Returns the new node.\n\n### AccordionTree#build(object,[node])\n\n  Build a tree from the given (json) object, under the given node or the tree root\n  node by default. Easy tree construction for simple cases.\n\n### AccordionTree#clear\n\n  Remove the contents of the entire tree.\n\n### AccordionTree#removeNode(node)\n\n  Remove the subtree under and including the specified node.\n\n\n### Node#addBranch(content,slug)\n\n  Add a branch node with this node as the root.\n\n### Node#addLeaf(content,slug)\n\n  Add a leaf node with this node as the root.\n\n### Node#remove\n\n  Remove the subtree under and including this node.\n  \n### Node#expand\n\n  Programmatically expand this node (following collapse/multiexpand behavior).\n\n### Node#collapse\n\n  Programmatically collapse this node.\n\n### Node#collapseAll\n\n  Programmatically collapse this node and all its siblings.\n\n\n\n## DOM structure\n\n  In the DOM, the generated tree looks like this:\n\n  ```html\n  \u003cdiv class=\"accordion-tree\"\u003e\n    \u003cul class=\"children\"\u003e\n      \u003cli class=\"branch\" data-path=\"/a-branch\"\u003e\n        \u003ch3\u003e\n          \u003cspan class=\"caret\"\u003e\u003c/span\u003e\n          \u003cspan class=\"icon\"\u003e\u003c/span\u003e\n          A branch\n        \u003c/h3\u003e\n        \u003cul class=\"children\"\u003e\n          \u003cli class=\"leaf\" data-path=\"/a-branch/a-leaf\"\u003e\n            A leaf\n          \u003c/li\u003e\n          \u003cli class=\"leaf\" data-path=\"/a-branch/another-leaf\"\u003e\n            Another leaf\n          \u003c/li\u003e\n        \u003c/ul\u003e\n      \u003c/li\u003e\n      \u003cli class=\"branch\" data-path=\"/another-branch\"\u003e\n        \u003ch3\u003e\n          \u003cspan class=\"caret\"\u003e\u003c/span\u003e\n          \u003cspan class=\"icon\"\u003e\u003c/span\u003e\n          Another branch\n        \u003c/h3\u003e\n        \u003cul class=\"children\"\u003e\n        \u003c/ul\u003e\n      \u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/div\u003e\n  ```\n\n  Note that the top-level DOM element will have the \"accordion-tree\" class\n  added on initialization.\n\n  Note that the `\u003cspan class=\"icon\"\u003e` you can use to style your own expand/\n  collapse arrows, instead of the default in `\u003cspan class=\"caret\"\u003e`. You\n  should have something like this:\n\n  ```css\n  .accordion-tree .caret { \n    display: none; \n  }\n\n  .accordion-tree .icon {\n    display: inline-block;\n    /* background image or content for right-arrow */\n  }\n\n  .accordion-tree .expanded \u003e * \u003e .icon {\n    /* background image or content for down-arrow */\n  }\n  ```\n\n## Help\n\nQuestions, suggestions, pull requests, etc. please contact me.\n\n## License\n\n  MIT\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Faccordion-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericgj%2Faccordion-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Faccordion-tree/lists"}