A Vue3 Block Organization Tree View Component Library

Block tree is a simple organizational hierarchical horizontal or vertical tree view based on Vue3.x. It supports events, slots, horizontal visibility, and node processing.

Thanks to hukaibaihu and his vue 2 sources are taken as a basis.

Bootstrap 5 To Create Vertical And Nested Collapsible Tree Menu Plugin
Hierarchical Tree With Radio Buttons Using Vanilla JS and Bootstrap | ninotree

How to make use of it:

Install and download:

# Yarn
$ yarn add vue3-blocks-tree

# NPM
$ npm i vue3-blocks-tree

1. Import the block tree.

import {createApp} from 'vue';
import VueBlocksTree from 'vue3-blocks-tree';
import 'vue3-blocks-tree/dist/vue3-blocks-tree.css';
let defaultoptions = {
    // OPTIONS HERE
}
createApp(App).use(VueBlocksTree, defaultoptions)

2. Create a basic organization tree.

<blocks-tree :data="treeData"></blocks-tree>
import { defineComponent,ref,reactive } from 'vue';
export default defineComponent({
  setup() {
    let selected = ref([]);
    let treeOrientation = ref("0");
    let treeData = reactive({
        label: 'root',
        expand: true,
        some_id: 1,
        children: [
          { label: 'child 1', some_id: 2, },
          { label: 'child 2', some_id: 3, },
          { 
            label: 'subparent 1', 
            some_id: 4, 
            expand: false, 
            children: [
              { label: 'subchild 1', some_id: 5 },
              {  
                label: 'subchild 2', 
                some_id: 6, 
                expand: false, 
                children: [
                  { label: 'subchild 11', some_id: 7 },
                  { label: 'subchild 22', some_id: 8 },
                ]
              },
            ]
          },
        ]
    });
    return {
      treeData,
    }
  }
})

3. Component props available.

data: {
  type: Object,
  required: true
},
props: {
  type: Object,
  default: () => (<PropsType>{
    label: 'label',
    expand: 'expand',
    children: 'children'
  })
},
horizontal: Boolean,
collapsable: Boolean,
renderContent: Function,
labelWidth: [String, Number],
labelClassName: [Function, String],

API

Must Read: An Editable SVG-based Diagram Component For Vue

apidescriptiontype
node contextContext to node manipulation in the slot or in event callbackinterface NodeContext { isExpanded():boolean; toggleExpand():void; }

props

Must Read: A JavaScript Library To Create Flow Charts Interactively | diagramflowjs

propdescriptiontypedefault
dataObject
propsconfigure propsObject{label: 'label', children: 'children', expand: 'expand',key: 'id'}
labelWidthnode label widthString | Numberauto
collapsablechildren node is collapsableBooleantrue
renderContenthow to render node labelFunction
labelClassNamenode label classFunction | String

events

Must Read: Create Data Flows with Drag And Drop Flowchart Builder | Drawflow

event namedescriptiontype
node-clickClick eventFunction
node-mouseoveronMouseOver eventFunction
node-mouseoutonMouseOut eventFunction
node-expandclick expand button eventFunction

Slots

Must Read: jQuery Plugin for Convert PPTX to HTML5 | PPTXjs

slot namedescriptionparams
nodecurrent node scoped slotdata – node data, context – node context

node-expand

well be called when the collapse-btn clicked

  • params e Event
  • params data Current node data
  • params context Node context

node-click

well be called when the node-label clicked

  • params e Event
  • params data Current node data
  • params context Node context

node-mouseover

It is called when the mouse hovers over the label.

  • params e Event
  • params data Current node data
  • params context Node context

node-mouseout

It is called when the mouse leaves the label.

  • params e Event
  • params data Current node data
  • params context Node context

See Demo And Download

vue3-blocks-tree

Official Website(megafetis): Click Here

This superior jQuery/javascript plugin is developed by megafetis. For extra advanced usage, please go to the official website.

Related Posts

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Bootstrap-4-Sidebar-Menu-Responsive-Template

Bootstrap 4 Sidebar Menu Responsive Template | MDB

Bootstrap Side Navbar – Responsive sidebar template based on the Bootstrap 4 framework. An easy-to-use, totally responsive, Google Material Design impressed aspect navigation for modern web app…

Bootstrap-4-Toast-Notification-Plugin

Lightweight Bootstrap 4 Toast Notification Plugin | BS4 Advanced Toast

A lightweight Bootstrap 4 Toast Notification plugin integrated with JS/jQuery. bs4-toast.js is a JavaScript library that enhances the native Bootstrap toast component with icons, buttons, callbacks, and…

Leave a Reply

Your email address will not be published. Required fields are marked *