@keenmate/svelte-treeview 1.2.12 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,98 +1,98 @@
1
- # Svelte Treeview
2
-
3
- The most elaborate treeview for svelte on earth (or even in our galaxy).
4
-
5
- ## Features
6
-
7
- - load new nodes when expanding
8
- - choose what object properties to use to get necessary information (id, path, ...)
9
- - enable checkboxes on whole tree or just per node
10
- - recursive seletion mode, where leafes can be selected
11
- - build-in support for search
12
- - drag and drop functionality controlable per node
13
- - context menu
14
- - keyboard navigation
15
-
16
- ## Instalation
17
-
18
- install the package `@keenmate/svelte-treeview` using your favourite package manager.
19
-
20
- > [!warning]
21
- > **Font awesome is required for expand/collapse icons.**
22
- > If you wish to not use FA, you need to change all icons in classes properties
23
-
24
- ## Minimal usage
25
-
26
- Tree and treeId are only mandatory attributes.
27
- Tree has to be list of nodes. Only mandatory property of node is nodePath.
28
- You can specify which keys to use for what properties by setting **props**.
29
-
30
- ```svelte
31
- <script lang="ts">
32
- import { TreeView } from '$lib/index.js';
33
-
34
- let tree = [
35
- { nodePath: 'animals', title: 'Animals', hasChildren: true },
36
- //...
37
- { nodePath: 'animals.insects.butterflies', title: 'Butterflies' }
38
- ];
39
- </script>
40
-
41
- <TreeView {tree} treeId="my-tree" let:node>
42
- {node.title}
43
- </TreeView>
44
-
45
- ```
46
-
47
- For more examples see `src/routes/`
48
-
49
- > [!note]
50
- > Both **id** and **path** is required for tree to work.
51
- > By default tree uses nodePath property for both.
52
- > So if you change propery fro path, you need to also change id property.
53
- > You can change both using props attribute.
54
-
55
- ## Properties
56
-
57
- | Name | Type | Default | Description |
58
- | ---------------------- | ------------------------------------------------------------------ | ------- | ----------------------------------------------------------------------------------------------------- |
59
- | treeId | string | | value used to generate ids of nodes |
60
- | tree | array of nodes | | represents tree strucuture |
61
- | value | array of selected nodeIds | [] | |
62
- | verticalLines | bool | false | show vertical guide lines |
63
- | readonly | bool | false | dont allow selection and drag and drop |
64
- | separator | string | "." | |
65
- | recursiveSelection | bool | false | changes behavior of selection, see [Selection](#selection) |
66
- | selectionMode | SelectionModes | none | changes selection mode, see [Selection](#selection) |
67
- | onlyLeafCheckboxes | bool | false | hides non leaf checkboxed, see [Selection](#selection) |
68
- | hideDisabledCheckboxes | bool | false | hides checkboxes instead of disabling, see [Selection](#selection) |
69
- | loadChildrenAsync | ExpandedCallback | null | function that is called when node is expanded, see [Async loading](#async-loading) |
70
- | showContextMenu | bool | false | On right click dispaly context menu defined in `context-menu` slot, see [Context menu](#context-menu) |
71
- | expansionThreshold | number | 0 | Expand all nodes when there is less than number provided |
72
- | customClasses | Partial<CustomizableClasses> | {} | changes classes used on same elements, see [Custom classes](#custom-classes) |
73
- | filter | (node: Node) => boolean or null | null | function that is used for fitlering. It is called on every node |
74
- | dragAndDrop | bool | false | enables drag and drop, see [Drag and drop](#drag-and-drop) |
75
- | dropDisabledCallback | (draggendNode: Node, targetNode: Node) => Promise<boolean> or null | null | function called when draging over new node, see [Drag and drop](#drag-and-drop) |
76
- | useKeyboardNavigation | bool | false | enables keyboard navigation , see [Keyboard navigation](#keyboard-navigation) |
77
- | logger | ((...data: any[]) => void) or null | null | function that acts as logger for tree, mostly used for debugging |
78
-
79
- ## Selection
80
-
81
- ## Async loading
82
-
83
- ## Context menu
84
-
85
- ## Custom classes
86
-
87
- ## Drag and drop
88
- > [!NOTE]
89
- > In memory drag and drop is not yet supported. Tree just dispatches `moved` event with dragged node(`node`), target node (`target`) and insertion type (`insertType`).
90
- > In future, this package will export function, that will allow you to easily compute new tree on frontend.
91
-
92
-
93
- ## Keyboard navigation
94
-
95
- Enable keyboard navigation by setting `useKeyboardNavigation` to true.
96
-
97
- Use arrows to navigata tree. First you need to focus some node,
98
- you can use `focusNode` to do that. Use Enter or Space to select checkbox.
1
+ # Svelte Treeview
2
+
3
+ The most elaborate treeview for svelte on earth (or even in our galaxy).
4
+
5
+ ## Features
6
+
7
+ - load new nodes when expanding
8
+ - choose what object properties to use to get necessary information (id, path, ...)
9
+ - enable checkboxes on whole tree or just per node
10
+ - recursive seletion mode, where leafes can be selected
11
+ - build-in support for search
12
+ - drag and drop functionality controlable per node
13
+ - context menu
14
+ - keyboard navigation
15
+
16
+ ## Instalation
17
+
18
+ install the package `@keenmate/svelte-treeview` using your favourite package manager.
19
+
20
+ > [!warning]
21
+ > **Font awesome is required for expand/collapse icons.**
22
+ > If you wish to not use FA, you need to change all icons in classes properties
23
+
24
+ ## Minimal usage
25
+
26
+ Tree and treeId are only mandatory attributes.
27
+ Tree has to be list of nodes. Only mandatory property of node is nodePath.
28
+ You can specify which keys to use for what properties by setting **props**.
29
+
30
+ ```svelte
31
+ <script lang="ts">
32
+ import { TreeView } from '$lib/index.js';
33
+
34
+ let tree = [
35
+ { nodePath: 'animals', title: 'Animals', hasChildren: true },
36
+ //...
37
+ { nodePath: 'animals.insects.butterflies', title: 'Butterflies' }
38
+ ];
39
+ </script>
40
+
41
+ <TreeView {tree} treeId="my-tree" let:node>
42
+ {node.title}
43
+ </TreeView>
44
+
45
+ ```
46
+
47
+ For more examples see `src/routes/`
48
+
49
+ > [!note]
50
+ > Both **id** and **path** is required for tree to work.
51
+ > By default tree uses nodePath property for both.
52
+ > So if you change propery fro path, you need to also change id property.
53
+ > You can change both using props attribute.
54
+
55
+ ## Properties
56
+
57
+ | Name | Type | Default | Description |
58
+ | ---------------------- | ------------------------------------------------------------------ | ------- | ----------------------------------------------------------------------------------------------------- |
59
+ | treeId | string | | value used to generate ids of nodes |
60
+ | tree | array of nodes | | represents tree strucuture |
61
+ | value | array of selected nodeIds | [] | |
62
+ | verticalLines | bool | false | show vertical guide lines |
63
+ | readonly | bool | false | dont allow selection and drag and drop |
64
+ | separator | string | "." | |
65
+ | recursiveSelection | bool | false | changes behavior of selection, see [Selection](#selection) |
66
+ | selectionMode | SelectionModes | none | changes selection mode, see [Selection](#selection) |
67
+ | onlyLeafCheckboxes | bool | false | hides non leaf checkboxed, see [Selection](#selection) |
68
+ | hideDisabledCheckboxes | bool | false | hides checkboxes instead of disabling, see [Selection](#selection) |
69
+ | loadChildrenAsync | ExpandedCallback | null | function that is called when node is expanded, see [Async loading](#async-loading) |
70
+ | showContextMenu | bool | false | On right click dispaly context menu defined in `context-menu` slot, see [Context menu](#context-menu) |
71
+ | expansionThreshold | number | 0 | Expand all nodes when there is less than number provided |
72
+ | customClasses | Partial<CustomizableClasses> | {} | changes classes used on same elements, see [Custom classes](#custom-classes) |
73
+ | filter | (node: Node) => boolean or null | null | function that is used for fitlering. It is called on every node |
74
+ | dragAndDrop | bool | false | enables drag and drop, see [Drag and drop](#drag-and-drop) |
75
+ | dropDisabledCallback | (draggendNode: Node, targetNode: Node) => Promise<boolean> or null | null | function called when draging over new node, see [Drag and drop](#drag-and-drop) |
76
+ | useKeyboardNavigation | bool | false | enables keyboard navigation , see [Keyboard navigation](#keyboard-navigation) |
77
+ | logger | ((...data: any[]) => void) or null | null | function that acts as logger for tree, mostly used for debugging |
78
+
79
+ ## Selection
80
+
81
+ ## Async loading
82
+
83
+ ## Context menu
84
+
85
+ ## Custom classes
86
+
87
+ ## Drag and drop
88
+ > [!NOTE]
89
+ > In memory drag and drop is not yet supported. Tree just dispatches `moved` event with dragged node(`node`), target node (`target`) and insertion type (`insertType`).
90
+ > In future, this package will export function, that will allow you to easily compute new tree on frontend.
91
+
92
+
93
+ ## Keyboard navigation
94
+
95
+ Enable keyboard navigation by setting `useKeyboardNavigation` to true.
96
+
97
+ Use arrows to navigata tree. First you need to focus some node,
98
+ you can use `focusNode` to do that. Use Enter or Space to select checkbox.
@@ -1,35 +1,18 @@
1
- <script>import { createEventDispatcher } from 'svelte';
2
- import Checkbox from './Checkbox.svelte';
3
- import { SelectionModes, InsertionType } from './types.js';
4
- import { capturedKeys } from './constants.js';
5
- const dispatch = createEventDispatcher();
6
- export let tree;
7
- export let treeId;
8
- export let recursive = false;
9
- export let checkboxes = SelectionModes.none;
10
- export let onlyLeafCheckboxes;
11
- export let hideDisabledCheckboxes;
12
- export let dragAndDrop;
13
- export let verticalLines;
14
- export let readonly;
15
- export let expandTo;
16
- export let classes;
17
- export let helper;
18
- export let childDepth;
19
- export let branchRootNode;
20
- export let draggedNode;
21
- export let highlightedNode;
22
- export let insertionType;
23
- export let focusedNode;
24
- export let allowKeyboardNavigation;
25
- let liElements = {};
1
+ <script lang="ts">import Branch from "./Branch.svelte";
2
+ import Checkbox from "./Checkbox.svelte";
3
+ import { InsertionType, SelectionModes } from "./types.js";
4
+ import { capturedKeys } from "./constants.js";
5
+ let { tree, treeId, recursive = false, checkboxes = SelectionModes.none, onlyLeafCheckboxes, hideDisabledCheckboxes, dragAndDrop, verticalLines, readonly, expandTo, classes, helper, childDepth, branchRootNode, draggedNode, highlightedNode, insertionType, focusedNode, allowKeyboardNavigation, onOpenCtxmenu = undefined, internal_onExpand = undefined, internal_onSelectionChanged = undefined, internal_onHandleDragStart = undefined, internal_onHandleDragDrop = undefined, internal_onHandleDragOver = undefined, internal_onHandleDragEnter = undefined, internal_onHandleDragEnd = undefined, internal_onHandleDragLeave = undefined, internal_onKeypress = undefined, children, nestHighlight } = $props();
6
+ let liElements = $state({});
26
7
  const getNodeId = (node) => `${treeId}-${node.path}`;
27
- $: directChildren = helper.getDirectChildren(tree, branchRootNode?.path ?? null);
28
- $: if (focusedNode && liElements[getNodeId(focusedNode)]) {
29
- liElements[getNodeId(focusedNode)].focus();
30
- }
8
+ let directChildren = $derived(helper.getDirectChildren(tree, branchRootNode?.path ?? null));
9
+ $effect(() => {
10
+ if (focusedNode && liElements[getNodeId(focusedNode)]) {
11
+ liElements[getNodeId(focusedNode)].focus();
12
+ }
13
+ });
31
14
  function setExpansion(node, changeTo) {
32
- dispatch('internal-expand', { node: node, changeTo });
15
+ internal_onExpand?.({ node: node, changeTo });
33
16
  }
34
17
  function isExpanded(node, depth, expandToDepth) {
35
18
  const nodeExpanded = node.expanded;
@@ -41,26 +24,31 @@ function isExpanded(node, depth, expandToDepth) {
41
24
  }
42
25
  //checkboxes
43
26
  function selectionChanged(node) {
44
- dispatch('internal-selectionChanged', { node: node });
27
+ internal_onSelectionChanged?.({ node: node });
45
28
  }
46
29
  // drag and drop
47
30
  function handleDragStart(e, node) {
48
- dispatch('internal-handleDragStart', { node: node, e: e });
31
+ internal_onHandleDragStart?.({ node: node, e: e });
49
32
  }
50
33
  function handleDragDrop(e, node, el) {
51
- dispatch('internal-handleDragDrop', { node: node, event: e, element: el });
34
+ e.stopImmediatePropagation();
35
+ internal_onHandleDragDrop?.({ node: node, event: e, element: el });
52
36
  }
53
37
  function handleDragOver(e, node, el, nest) {
54
- dispatch('internal-handleDragOver', { node: node, event: e, element: el, nest });
38
+ e.stopImmediatePropagation();
39
+ internal_onHandleDragOver?.({ node: node, event: e, element: el, nest });
55
40
  }
56
41
  function handleDragEnter(e, node, el) {
57
- dispatch('internal-handleDragEnter', { node: node, event: e, element: el });
42
+ e.stopImmediatePropagation();
43
+ internal_onHandleDragEnter?.({ node: node, event: e, element: el });
58
44
  }
59
45
  function handleDragEnd(e, node) {
60
- dispatch('internal-handleDragEnd', { node: node, event: e });
46
+ e.stopImmediatePropagation();
47
+ internal_onHandleDragEnd?.({ node: node, event: e });
61
48
  }
62
49
  function handleDragLeave(e, node, el) {
63
- dispatch('internal-handleDragLeave', { node: node, event: e, element: el });
50
+ e.stopImmediatePropagation();
51
+ internal_onHandleDragLeave?.({ node: node, event: e, element: el });
64
52
  }
65
53
  function handleKeyPress(e, node) {
66
54
  if (!capturedKeys.includes(e.key)) {
@@ -68,148 +56,151 @@ function handleKeyPress(e, node) {
68
56
  }
69
57
  e.preventDefault();
70
58
  e.stopPropagation();
71
- dispatch('internal-keypress', { event: e, node });
59
+ internal_onKeypress?.({ event: e, node });
72
60
  }
73
61
  function getHighlighMode(node, highlightedNode, insertionType) {
74
62
  // return InsertionType.insertAbove;
75
- if (highlightedNode?.path !== node.path)
63
+ if (highlightedNode?.path !== node.path) {
76
64
  return InsertionType.none;
65
+ }
77
66
  return insertionType;
78
67
  }
79
- </script>
80
-
81
- <ul
82
- class:show-lines={childDepth === 0 && verticalLines}
83
- class:child-menu={childDepth > 0}
84
- class={childDepth === 0 ? classes.treeClass : ''}
85
- >
86
- <!-- TODO fix accessibility -->
87
- <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
88
- {#each directChildren as node (getNodeId(node))}
89
- {@const expanded = isExpanded(node, childDepth, expandTo)}
90
- {@const draggable = !readonly && dragAndDrop && !node.dragDisabled}
91
- {@const isCurrentlyDragged = draggedNode && node.path.startsWith(draggedNode?.path)}
92
- {@const effectiveHighlight = getHighlighMode(node, highlightedNode, insertionType)}
93
- <!-- svelte-ignore a11y-no-noninteractive-tabindex -->
94
- <li
95
- class:is-child={helper.nodePathIsChild(node.path)}
96
- class:has-children={node.hasChildren}
97
- on:contextmenu|stopPropagation={(e) => {
98
- dispatch('open-ctxmenu', { e, node });
99
- }}
100
- on:drop|stopPropagation={(e) => handleDragDrop(e, node, liElements[getNodeId(node)])}
101
- on:dragover|stopPropagation={(e) =>
102
- handleDragOver(e, node, liElements[getNodeId(node)], false)}
103
- on:dragenter|stopPropagation={(e) => handleDragEnter(e, node, liElements[getNodeId(node)])}
104
- on:dragleave|stopPropagation={(e) => handleDragLeave(e, node, liElements[getNodeId(node)])}
105
- bind:this={liElements[getNodeId(node)]}
106
- on:keydown={(e) => handleKeyPress(e, node)}
107
- tabindex={allowKeyboardNavigation ? 1 : -1}
108
- >
109
- {#if effectiveHighlight == InsertionType.insertAbove}
110
- <div class="insert-line-wrapper">
111
- <div class="insert-line {classes.insertLineClass}" />
112
- </div>
113
- {/if}
114
-
115
- <!-- svelte-ignore a11y-no-static-element-interactions -->
116
- <div
117
- class="tree-item
118
- {effectiveHighlight === InsertionType.nest ? classes.expandClass : ''}
119
- {classes.nodeClass} {isCurrentlyDragged ? classes.currentlyDraggedClass : ''}"
120
- class:div-has-children={node.hasChildren}
121
- class:hover={effectiveHighlight !== InsertionType.none}
122
- {draggable}
123
- on:dragstart={(e) => handleDragStart(e, node)}
124
- on:dragend={(e) => handleDragEnd(e, node)}
125
- >
126
- {#if node.hasChildren}
127
- <button
128
- class="expansion-button arrow"
129
- on:click={() => setExpansion(node, !expanded)}
130
- type="button"
131
- tabindex="-1"
132
- >
133
- <i class="fixed-icon arrow {expanded ? classes.collapseIcon : classes.expandIcon}" />
134
- </button>
135
- {:else}
136
- <span class="fixed-icon" />
137
- {/if}
138
-
139
- <Checkbox
140
- {checkboxes}
141
- {recursive}
142
- {node}
143
- {onlyLeafCheckboxes}
144
- {hideDisabledCheckboxes}
145
- {readonly}
146
- on:select={({ detail: { node } }) => selectionChanged(node)}
147
- />
148
- <span class:pointer-cursor={draggable}>
149
- <slot node={node.originalNode} />
150
- </span>
151
-
152
- {#if dragAndDrop && node.nestAllowed}
153
- <span
154
- on:dragover|stopPropagation={(e) =>
155
- handleDragOver(e, node, liElements[getNodeId(node)], true)}
156
- >
157
- <i class="fixed-icon {classes.nestIcon}" />
158
-
159
- {#if effectiveHighlight === InsertionType.nest}
160
- <slot name="nest-highlight" />
161
- {/if}
162
- </span>
163
- {/if}
164
- </div>
165
- {#if expanded && node.hasChildren}
166
- <svelte:self
167
- branchRootNode={node}
168
- childDepth={childDepth + 1}
169
- {treeId}
170
- {checkboxes}
171
- {tree}
172
- {recursive}
173
- {helper}
174
- {classes}
175
- {readonly}
176
- {onlyLeafCheckboxes}
177
- {hideDisabledCheckboxes}
178
- {expandTo}
179
- {dragAndDrop}
180
- {verticalLines}
181
- {draggedNode}
182
- {highlightedNode}
183
- {insertionType}
184
- {focusedNode}
185
- {allowKeyboardNavigation}
186
- on:open-ctxmenu
187
- on:internal-expand
188
- on:internal-selectionChanged
189
- on:internal-handleDragStart
190
- on:internal-handleDragDrop
191
- on:internal-handleDragOver
192
- on:internal-handleDragEnter
193
- on:internal-handleDragEnd
194
- on:internal-handleDragLeave
195
- on:internal-keypress
196
- let:node={nodeNested}
197
- >
198
- <slot node={nodeNested} />
199
- <svelte:fragment slot="nest-highlight">
200
- <slot name="nest-highlight" />
201
- </svelte:fragment>
202
- </svelte:self>
203
- {/if}
204
- {#if !expanded && node.hasChildren}
205
- <ul class:child-menu={childDepth > 0} />
206
- {/if}
207
- <!-- Show line if insering -->
208
- {#if effectiveHighlight === InsertionType.insertBelow}
209
- <div class="insert-line-wrapper">
210
- <div class="insert-line {classes.insertLineClass}" />
211
- </div>
212
- {/if}
213
- </li>
214
- {/each}
215
- </ul>
68
+ function onContextMenu(ev, node) {
69
+ ev.stopImmediatePropagation();
70
+ onOpenCtxmenu({ ev, node });
71
+ }
72
+ </script>
73
+
74
+ <ul
75
+ class:show-lines={childDepth === 0 && verticalLines}
76
+ class:child-menu={childDepth > 0}
77
+ class={childDepth === 0 ? classes.treeClass : ''}
78
+ >
79
+ <!-- TODO fix accessibility -->
80
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
81
+ {#each directChildren as node (getNodeId(node))}
82
+ {@const expanded = isExpanded(node, childDepth, expandTo)}
83
+ {@const draggable = !readonly && dragAndDrop && !node.dragDisabled}
84
+ {@const isCurrentlyDragged = draggedNode && node.path.startsWith(draggedNode?.path)}
85
+ {@const effectiveHighlight = getHighlighMode(node, highlightedNode, insertionType)}
86
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
87
+ <li
88
+ class:is-child={helper.nodePathIsChild(node.path)}
89
+ class:has-children={node.hasChildren}
90
+ oncontextmenu={e => onContextMenu(e, node)}
91
+ ondrop={e => handleDragDrop(e, node, liElements[getNodeId(node)])}
92
+ ondragover={e => handleDragOver(e, node, liElements[getNodeId(node)], false)}
93
+ ondragenter={e => handleDragEnter(e, node, liElements[getNodeId(node)])}
94
+ ondragleave={e => handleDragLeave(e, node, liElements[getNodeId(node)])}
95
+ bind:this={liElements[getNodeId(node)]}
96
+ onkeydown={(e) => handleKeyPress(e, node)}
97
+ tabindex={allowKeyboardNavigation ? 1 : -1}
98
+ >
99
+ {#if effectiveHighlight == InsertionType.insertAbove}
100
+ <div class="insert-line-wrapper">
101
+ <div class="insert-line {classes.insertLineClass}"></div>
102
+ </div>
103
+ {/if}
104
+
105
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
106
+ <div
107
+ class="tree-item
108
+ {effectiveHighlight === InsertionType.nest ? classes.expandClass : ''}
109
+ {classes.nodeClass} {isCurrentlyDragged ? classes.currentlyDraggedClass : ''}"
110
+ class:div-has-children={node.hasChildren}
111
+ class:hover={effectiveHighlight !== InsertionType.none}
112
+ {draggable}
113
+ ondragstart={(e) => handleDragStart(e, node)}
114
+ ondragend={(e) => handleDragEnd(e, node)}
115
+ >
116
+ {#if node.hasChildren}
117
+ <button
118
+ class="expansion-button arrow"
119
+ onclick={() => setExpansion(node, !expanded)}
120
+ type="button"
121
+ tabindex="-1"
122
+ >
123
+ <i class="fixed-icon arrow {expanded ? classes.collapseIcon : classes.expandIcon}"></i>
124
+ </button>
125
+ {:else}
126
+ <span class="fixed-icon"></span>
127
+ {/if}
128
+
129
+ <Checkbox
130
+ {checkboxes}
131
+ {recursive}
132
+ {node}
133
+ {onlyLeafCheckboxes}
134
+ {hideDisabledCheckboxes}
135
+ {readonly}
136
+ on:select={({ detail: { node } }) => selectionChanged(node)}
137
+ />
138
+ <span class:pointer-cursor={draggable}>
139
+ {@render children?.({node: node.originalNode,})}
140
+ </span>
141
+
142
+ {#if dragAndDrop && node.nestAllowed}
143
+ <span
144
+ ondragover={e => handleDragOver(e, node, liElements[getNodeId(node)], true)}
145
+ >
146
+ <i class="fixed-icon {classes.nestIcon}"></i>
147
+
148
+ {#if effectiveHighlight === InsertionType.nest}
149
+ {@render nestHighlight?.()}
150
+ {/if}
151
+ </span>
152
+ {/if}
153
+ </div>
154
+ {#if expanded && node.hasChildren}
155
+ <Branch
156
+ branchRootNode={node}
157
+ childDepth={childDepth + 1}
158
+ {treeId}
159
+ {checkboxes}
160
+ {tree}
161
+ {recursive}
162
+ {helper}
163
+ {classes}
164
+ {readonly}
165
+ {onlyLeafCheckboxes}
166
+ {hideDisabledCheckboxes}
167
+ {expandTo}
168
+ {dragAndDrop}
169
+ {verticalLines}
170
+ {draggedNode}
171
+ {highlightedNode}
172
+ {insertionType}
173
+ {focusedNode}
174
+ {allowKeyboardNavigation}
175
+ on:open-ctxmenu
176
+ on:internal-expand
177
+ on:internal-selectionChanged
178
+ on:internal-handleDragStart
179
+ on:internal-handleDragDrop
180
+ on:internal-handleDragOver
181
+ on:internal-handleDragEnter
182
+ on:internal-handleDragEnd
183
+ on:internal-handleDragLeave
184
+ on:internal-keypress
185
+
186
+ >
187
+ {#snippet children({ node: nodeNested })}
188
+ {@render children?.({node: nodeNested,})}
189
+ <!--<svelte:fragment slot="nest-highlight">-->
190
+ <!-- <slot name="nest-highlight" />-->
191
+ <!--</svelte:fragment>-->
192
+ {/snippet}
193
+ </Branch>
194
+ {/if}
195
+ {#if !expanded && node.hasChildren}
196
+ <ul class:child-menu={childDepth > 0}></ul>
197
+ {/if}
198
+ <!-- Show line if insering -->
199
+ {#if effectiveHighlight === InsertionType.insertBelow}
200
+ <div class="insert-line-wrapper">
201
+ <div class="insert-line {classes.insertLineClass}"></div>
202
+ </div>
203
+ {/if}
204
+ </li>
205
+ {/each}
206
+ </ul>
@@ -1,52 +1,4 @@
1
- import { SvelteComponent } from "svelte";
2
- import { SelectionModes, InsertionType, type Node, type CustomizableClasses } from './types.js';
3
- import type { TreeHelper } from './helpers/tree-helper.js';
4
- declare const __propDef: {
5
- props: {
6
- tree: Node[];
7
- treeId: string;
8
- recursive?: boolean | undefined;
9
- checkboxes?: SelectionModes | undefined;
10
- onlyLeafCheckboxes: boolean;
11
- hideDisabledCheckboxes: boolean;
12
- dragAndDrop: boolean;
13
- verticalLines: boolean;
14
- readonly: boolean;
15
- expandTo: number;
16
- classes: CustomizableClasses;
17
- helper: TreeHelper;
18
- childDepth: number;
19
- branchRootNode: Node | null;
20
- draggedNode: Node | null;
21
- highlightedNode: Node | null;
22
- insertionType: InsertionType;
23
- focusedNode: Node | null;
24
- allowKeyboardNavigation: boolean;
25
- };
26
- events: {
27
- 'open-ctxmenu': CustomEvent<any>;
28
- 'internal-expand': CustomEvent<any>;
29
- 'internal-selectionChanged': CustomEvent<any>;
30
- 'internal-handleDragStart': CustomEvent<any>;
31
- 'internal-handleDragDrop': CustomEvent<any>;
32
- 'internal-handleDragOver': CustomEvent<any>;
33
- 'internal-handleDragEnter': CustomEvent<any>;
34
- 'internal-handleDragEnd': CustomEvent<any>;
35
- 'internal-handleDragLeave': CustomEvent<any>;
36
- 'internal-keypress': CustomEvent<any>;
37
- } & {
38
- [evt: string]: CustomEvent<any>;
39
- };
40
- slots: {
41
- default: {
42
- node: any;
43
- };
44
- 'nest-highlight': {};
45
- };
46
- };
47
- export type BranchProps = typeof __propDef.props;
48
- export type BranchEvents = typeof __propDef.events;
49
- export type BranchSlots = typeof __propDef.slots;
50
- export default class Branch extends SvelteComponent<BranchProps, BranchEvents, BranchSlots> {
51
- }
52
- export {};
1
+ import Branch from "./Branch.svelte";
2
+ declare const Branch: any;
3
+ type Branch = InstanceType<typeof Branch>;
4
+ export default Branch;