{"id":22355414,"url":"https://github.com/geekhybrid/tree-vue","last_synced_at":"2025-07-30T10:31:39.378Z","repository":{"id":49895726,"uuid":"371089116","full_name":"geekhybrid/tree-vue","owner":"geekhybrid","description":"A lightweight library for handling hierarchical content. With full customizations of items rendering.","archived":false,"fork":false,"pushed_at":"2021-12-04T17:19:14.000Z","size":321,"stargazers_count":31,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-03T05:24:06.777Z","etag":null,"topics":["hierarchical-data","tree","tree-view","vue"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geekhybrid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-26T15:48:03.000Z","updated_at":"2024-11-02T13:27:22.000Z","dependencies_parsed_at":"2022-09-15T03:10:55.385Z","dependency_job_id":null,"html_url":"https://github.com/geekhybrid/tree-vue","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekhybrid%2Ftree-vue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekhybrid%2Ftree-vue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekhybrid%2Ftree-vue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekhybrid%2Ftree-vue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geekhybrid","download_url":"https://codeload.github.com/geekhybrid/tree-vue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227877775,"owners_count":17833559,"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":["hierarchical-data","tree","tree-view","vue"],"created_at":"2024-12-04T14:06:24.341Z","updated_at":"2024-12-04T14:06:25.084Z","avatar_url":"https://github.com/geekhybrid.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tree-Vue\n\nA light-weight library for management of hierachical content. Most solutions I found did not offer the depth of flexibility I needed with the tree. I decided to solve my problem and also give back to the Vue community. Feel free to log issues, I will jump on them at the slightest opportunity. 😊\n\n### How to install.\nnpm: `npm i v-tree-vue`\n\nVue 3 Project: https://github.com/geekhybrid/vue3-tree-vue\n\nVue 3 npm package: `npm i vue3-tree-vue`\n\n\n## Features\n\n1. :heavy_check_mark: Hierachical rendering of content.\n2. ✔️ Subscribing to items checked event (based on type)\n3. :heavy_check_mark: Moving Items between folders (drag-and-drop)\n4. :heavy_check_mark: Customising Item Rendering based on item type\n5. ✔️ Rendering selectable items like checkboxes or plain content\n6. ✔️ Double clicking to rename item\n\n## Features in Development\n1. Programmatically toggle item visibility based on the `type` property.\n2. Sorting items alphametically or grouping based on types\n3. Disabling and Enabling Item(s)\n4. Programmatically determining what item can be dragged into another item.\n5. -Custom Context Menu depending on item type.\n\n\n![image](https://user-images.githubusercontent.com/39003759/125176959-e320f580-e1cf-11eb-886f-7a9c8808c178.png)\n\n### Basic Component Rendering\n``` html\n\u003ctemplate\u003e\n    \u003ctree-view :treeViewItems=\"treeViewNodes\" /\u003e\n\u003c/template\u003e\n```\n\n```ts\n\u003cscript lang='ts'\u003e\nimport { Vue, Component} from 'vue-property-decorator';\n\nimport { TreeViewItem, ItemTypes } from '@/businessLogic/contracts/types';\n\n@Component\nexport default class App extends Vue {\n  treeViewNodes: TreeViewItem[] = []\n}\n```\n\n## Item Schema\n\n```ts\nexport interface TreeViewItem {\n    children?: TreeViewItem[]\n    type: string\n    checkedStatus?: CheckedState,\n    name: string,\n    id: string,\n    parentId?: string\n}\n```\n\n## How to use Advance\n\n### Custom Icon Based on Item Type.\nYou can customise item based on their `type` property.\n\n```html\n\u003ctemplate\u003e\n  \u003ctree-view :treeViewItems=\"treeViewNodes\"\u003e\n      \u003ctemplate v-slot:icon=\"treeViewItem\"\u003e\n          \u003cimg src=\"@/assets/folder.svg\" alt=\"folder\" v-if=\"treeViewItem.type === 'folder'\" \u003e\n          \u003cimg src=\"@/assets/word.png\" alt=\"vue-logo\" v-else-if=\"treeViewItem.type === '.doc'\" height=\"22\" width=\"22\"\u003e\n          \u003cimg src=\"@/assets/excel.png\" alt=\"vue-logo\" v-else-if=\"treeViewItem.type === '.excel'\" height=\"22\" width=\"22\"\u003e\n      \u003c/template\u003e\n  \u003c/tree-view\u003e\n\u003c/template\u003e\n\n```\n\n## Advanced Customisation\n\nThe library provides a way to further customise the tree view by listening to the `v-on:created` event from the tree-view component. The payload surplied provides robust set of options for configuring the tree.\n\n#### Schema of CreatedEvent Payload\n\n```ts\n    export interface TreeViewCreatedEventPayload {\n        itemCustomisations: ItemTypeCustomisations;\n        eventManager: EventManager\n        ...\n    }\n```\n\nSchema for `ItemTypeCustomisations`\n\n```ts\nexport interface ItemTypeCustomisations {\n    isDropValid(droppedNode: TreeViewItem, dropHost: TreeViewItem): boolean;\n    makeItemsCheckable(types: string[]): void;\n    registerItemRenamedHandler(type: string, callback: (renamedItem: TreeViewItem) =\u003e Promise\u003cTreeViewItem\u003e): void;\n    registerDragAndDropValidator(canItemMoveCallBack: (movingItem: TreeViewItem, destinationItem: TreeViewItem) =\u003e boolean): void;\n    disableDragAndDrop(): void;\n    \n    getCustomisation(type: string): Customisations;\n    getRenameHandler(type: string): (item: TreeViewItem) =\u003e Promise\u003cTreeViewItem\u003e;\n\n    registerItemDeletedHandler(type: string, callback: (item: TreeViewItem) =\u003e Promise\u003cboolean\u003e): void;\n    registerItemMovedHandler(callBack: (movedItem: TreeViewItem) =\u003e Promise\u003cTreeViewItem\u003e): void;\n    \n    registerAnyItemDeleted(callback: (item: TreeViewItem) =\u003e Promise\u003cboolean\u003e): void;\n    registerAnyItemRenamed(callback: (item: TreeViewItem) =\u003e Promise\u003cTreeViewItem\u003e): void;\n    registerAnyItemDragAndDrop(): void;\n}\n```\n\n## Example\n\n```html\n\u003ctemplate\u003e\n  \u003ctree-view :treeViewItems=\"treeViewNodes\" @created=\"customiseTreeView\" /\u003e\n\u003c/template\u003e\n```\n```ts\n\u003cscript lang='ts'\u003e\nimport { Vue, Component} from 'vue-property-decorator';\n\nimport { TreeViewCreatedEventPayload, TreeViewItem } from '@/businessLogic/contracts/types';\n\n@Component\nexport default class App extends Vue {\n  \n  // This method is called when the tree view is created (on Created hook). And allows you to customise the tree-view items using the payload passed into the function.\n\n  customiseTreeView(treeCreatedEvent: TreeViewCreatedEventPayload) {\n    const customisations = treeCreatedEvent.itemCustomisations;\n    \n    // `Tree-vue` supports 2-major types of tree items. Checkable items or plain items.\n    customisations.makeItemsCheckable([\".doc\", \".excel\", \"media\" ]);\n  }\n\n  treeViewNodes: TreeViewItem[] = [] // Populate tree items here.\n  ];\n}\n\u003c/script\u003e\n```\n\n#### Output\n\n![image](https://user-images.githubusercontent.com/39003759/121091770-7090b480-c7e2-11eb-9ee5-e79351bd8ed8.png)\n\n### Listening to Items Checked\n\nTo carter for advanced cases where `children` of the hierachical tree may be of different types. And you want to perform some further actions whenever something happens to them. You can subscribe for checked events of item types you may be interested in. And perform further actions.\n\n### Use case\nE.g A school has departments, and you want to check some departments and delete them.\n\n### Solution\nYou can attach callbacks that notify you when departments have been checked on the tree.\n\n### How to Use\n\n```html\n\u003ctemplate\u003e    \n    \u003c!-- Examples of how to subscribe for events --\u003e\n    \u003ctree-view :treeViewItems=\"schools\" @created=\"customiseSchools\" /\u003e\n\u003c/template\u003e\n```\n```ts\n\u003cscript lang='ts'\u003e\nimport { Vue, Component} from 'vue-property-decorator';\n\nimport { TreeViewCreatedEventPayload } from '@/businessLogic/contracts/types';\n\n@Component\nexport default class App extends Vue {\n  customiseSchools(treeCreatedEvent: TreeViewCreatedEventPayload) {\n    const customisations = treeCreatedEvent.itemCustomisations;\n    const eventManager = treeCreatedEvent.eventManager;\n\n    eventManager.subscribeToItemChecked(\"department\", (items) =\u003e console.log(items));\n    customisations.makeItemsCheckable([\"department\"]);\n  }\n  schools: TreeViewItem[] = [\n    {\n      id: '1',\n      type: 'school',\n      name: 'Vue School',\n      children: [\n        {\n          id: '2',\n          type: 'department',\n          name: 'Typescript Department',\n          parentId: '1'\n        },\n        {\n          id: '3',\n          type: 'department',\n          name: 'Open Source Department',\n          parentId: '1'\n        }\n      ]\n    }\n  ]\n}\n```\n## Properties\n\n| Property      | Default | Description |\n| ----------- | ----------- |-------------\n| treeViewItems | Empty array      | An array of `TreeViewItem`.       |\n| hideGuideLines | `false` | Determines the visibility of the guidelines\n| selectionMode | `Multiple`   | `Single` or `Multiple`. This determines how many items can be simultaneously selected/checked in the tree.         |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekhybrid%2Ftree-vue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeekhybrid%2Ftree-vue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekhybrid%2Ftree-vue/lists"}