Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import 'vue3-tree-vue/dist/style.css'; // remember to add this in your component
const onItemChecked = (checkedItems: TreeViewItem[]) => console.log(checkedItems);
const onItemSelected = (item: TreeViewItem) => console.log(item);


// How to handle drag and drop logic
const onBeforeItemDropped = (droppedItem: TreeViewItem, destinationNode: TreeViewItem | undefined) => {
// destinationNode == undefined means dropping at the root of the tree.
Expand Down Expand Up @@ -91,6 +90,7 @@ export interface TreeViewItem {
checked?: boolean;
selected?: boolean;
expanded?: boolean;
disableDragAndDrop?: boolean; // Disable drag and drop for a specific node.
disabled?: boolean;// When disabled, an item can neither be selected nor checked
meta?: any;// provides meta-data of any type per node.
}
Expand Down
7 changes: 6 additions & 1 deletion dev/serve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default defineComponent({
</div>
</template>

<style scoped>
<style>
* {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 14px;
Expand All @@ -114,4 +114,9 @@ button {
color: blue;
cursor: pointer;
}

.selected-tree-item {
background: blue !important;
}

</style>
3 changes: 2 additions & 1 deletion dev/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
]
},
{
"name": "System Design Playlist",
"name": "System Design Playlist (Not Draggable)",
"id": 993029302938,
"disableDragAndDrop": true,
"type": ".playlist",
"children": [
{
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue3-tree-vue",
"version": "2.0.11",
"version": "2.0.12",
"description": "",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -71,8 +71,5 @@
},
"engines": {
"node": ">=12"
},
"dependencies": {
"user": "^0.0.0"
}
}
3 changes: 2 additions & 1 deletion src/composables/use-tree-mouse-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function useTreeViewItemMouseActions() {
}

const onDragNode = (item: TreeViewItem, event: DragEvent): void => {
if (item.disableDragAndDrop) return;
if (event.dataTransfer) {
event.dataTransfer.setData('text/plain', JSON.stringify(item));
}
Expand All @@ -46,7 +47,7 @@ export function useTreeViewItemMouseActions() {

if (!isDropValid) return;

if (dropHost && droppedNode.id === dropHost.id) {
if (dropHost && droppedNode.id === dropHost.id || droppedNode.disableDragAndDrop) {
return
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface TreeViewItem {
selected?: boolean;
expanded?: boolean;
disabled?: boolean;
disableDragAndDrop?: boolean;
meta?: any;
}

Expand Down