| 1 | <script context="module"> |
| 2 | const _expansionState = { |
| 3 | /* treeNodeId: expanded <boolean> */ |
| 4 | }; |
| 5 | </script> |
| 6 | |
| 7 | <script lang="ts"> |
| 8 | import { createEventDispatcher, onMount } from "svelte"; |
| 9 | import FileTreeList from "./FileTreeList.svelte"; |
| 10 | |
| 11 | export let tree; |
| 12 | export let contextMenuEnabled = false; |
| 13 | export let isExpanded = false; |
| 14 | export let iconsEnabled = true; |
| 15 | export let canDrag = false; |
| 16 | |
| 17 | let ref; |
| 18 | let dispatch = createEventDispatcher(); |
| 19 | |
| 20 | let contextmenu = false; |
| 21 | function handleMouseUp(e) { |
| 22 | let x = null; |
| 23 | if (e.button === 2 && contextMenuEnabled) { |
| 24 | if (e.target === ref) { |
| 25 | x = ref; |
| 26 | contextmenu = true; |
| 27 | } |
| 28 | else { |
| 29 | x = null; |
| 30 | contextmenu = false; |
| 31 | } |
| 32 | dispatch("rightclick", {target: x, contextmenu: contextmenu}); |
| 33 | } |
| 34 | } |
| 35 | </script> |
| 36 | |
| 37 | <ul bind:this={ref} class="tree" role="tree" on:mouseup={handleMouseUp}> |
| 38 | <FileTreeList {canDrag} {isExpanded} on:nodeselect on:dblnodeselect children={tree} root {contextMenuEnabled} {iconsEnabled} /> |
| 39 | </ul> |
| 40 | |
| 41 | <style> |
| 42 | ul { |
| 43 | margin: 0; |
| 44 | list-style: none; |
| 45 | user-select: none; |
| 46 | } |
| 47 | .tree { |
| 48 | width: 100%; |
| 49 | padding: 10px 0; |
| 50 | height: -webkit-fill-available; |
| 51 | } |
| 52 | </style> |