Skip to content

Commit b1592c6

Browse files
authored
Add collapsible property (#42)
1 parent 228dbe2 commit b1592c6

File tree

7 files changed

+22
-5
lines changed

7 files changed

+22
-5
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Node.js
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: '14'
23+
node-version: '16'
2424

2525
- name: Install dependencies
2626
run: npm install

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface TreeViewItem {
9191
selected?: boolean;
9292
expanded?: boolean;
9393
disableDragAndDrop?: boolean; // Disable drag and drop for a specific node.
94+
collapsible?: boolean; // When set to false, item can not be collapsed (children always visible)
9495
disabled?: boolean;// When disabled, an item can neither be selected nor checked
9596
styles?: string[]; // Add the .css styles for a given item
9697
meta?: any;// provides meta-data of any type per node.

dev/tree.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
"type": ".playlist"
3535
},
3636
{
37-
"name": "Decoding hieroglyphs",
37+
"name": "Decoding hieroglyphs (Not collapsible)",
3838
"id": 8,
3939
"type": ".playlist",
40+
"collapsible": false,
41+
"expanded": true,
4042
"children": [
4143
{
4244
"name": "List of Rejection Emails",

src/style.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,16 @@
147147
align-items: center;
148148
}
149149

150-
.vue3-tree-vue .nested {
150+
/**
151+
* children of checkable tree items need 47px left margin.
152+
* Otherwise, only 27px left margin is needed.
153+
*/
154+
155+
.vue3-tree-vue .nested{
156+
margin-left: 27px !important;
157+
}
158+
159+
.tree-item-node-checkable > .nested {
151160
margin-left: 47px !important;
152161
}
153162

src/tree-component.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
<li v-for="treeViewItem in internalItems"
1212
:key="treeViewItem.id"
1313
:id="treeViewItem.id"
14-
class="tree-item-node">
14+
class="tree-item-node"
15+
:class="{
16+
'tree-item-node-checkable': isCheckable,
17+
}"
18+
>
1519
<treeview-item class="pointer tree-view-item"
1620
:item="treeViewItem"
1721
:parent="parent"

src/tree-item.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="d-flex align-items-center" @contextmenu.prevent="$emit('onContextMenu', { item, event: $event })">
33
<div class="guide-line" v-if="parent != null && !hideGuideLines"></div>
44

5-
<div @click="toggleExpand()" v-if="lazyLoad || (item.children && item.children.length > 0)">
5+
<div @click="toggleExpand()" v-if="(lazyLoad || (item.children && item.children.length > 0)) && (item.collapsible == undefined || item.collapsible == true)">
66
<slot name="expander" v-bind="item">
77
<span class="chevron-right" :class="{'rotate-90' : item.expanded }"></span>
88
</slot>

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface TreeViewItem {
77
expanded?: boolean;
88
disabled?: boolean;
99
disableDragAndDrop?: boolean;
10+
collapsible?: boolean;
1011
styles?: string[];
1112
meta?: any;
1213
}

0 commit comments

Comments
 (0)