@keenmate/svelte-treeview 3.1.2 → 4.0.0-rc05

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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +485 -98
  3. package/dist/components/Node.svelte +161 -0
  4. package/dist/components/Node.svelte.d.ts +41 -0
  5. package/dist/components/Tree.svelte +404 -0
  6. package/dist/components/Tree.svelte.d.ts +77 -0
  7. package/dist/helpers/ltree-helpers.d.ts +4 -0
  8. package/dist/helpers/ltree-helpers.js +25 -0
  9. package/dist/helpers/string-helpers.d.ts +2 -0
  10. package/dist/helpers/string-helpers.js +2 -0
  11. package/dist/index.d.ts +3 -6
  12. package/dist/index.js +2 -6
  13. package/dist/ltree/flex.d.ts +2 -0
  14. package/dist/ltree/flex.js +8 -0
  15. package/dist/ltree/ltree-demo.d.ts +2 -0
  16. package/dist/ltree/ltree-demo.js +90 -0
  17. package/dist/ltree/ltree-node.svelte.d.ts +29 -0
  18. package/dist/ltree/ltree-node.svelte.js +31 -0
  19. package/dist/ltree/ltree.svelte.d.ts +4 -0
  20. package/dist/ltree/ltree.svelte.js +479 -0
  21. package/dist/ltree/types.d.ts +47 -0
  22. package/dist/ltree/types.js +1 -0
  23. package/dist/styles/main.scss +338 -0
  24. package/dist/styles.css +264 -0
  25. package/dist/styles.css.map +1 -0
  26. package/dist/styles.scss +2 -0
  27. package/package.json +89 -86
  28. package/dist/Branch.svelte +0 -200
  29. package/dist/Branch.svelte.d.ts +0 -70
  30. package/dist/Checkbox.svelte +0 -50
  31. package/dist/Checkbox.svelte.d.ts +0 -29
  32. package/dist/TreeView.svelte +0 -456
  33. package/dist/TreeView.svelte.d.ts +0 -126
  34. package/dist/constants.d.ts +0 -5
  35. package/dist/constants.js +0 -33
  36. package/dist/helpers/tree-helper.d.ts +0 -32
  37. package/dist/helpers/tree-helper.js +0 -163
  38. package/dist/menu/ContextMenu.svelte +0 -28
  39. package/dist/menu/ContextMenu.svelte.d.ts +0 -9
  40. package/dist/menu/Menu.svelte +0 -50
  41. package/dist/menu/Menu.svelte.d.ts +0 -25
  42. package/dist/menu/MenuDivider.svelte +0 -10
  43. package/dist/menu/MenuDivider.svelte.d.ts +0 -26
  44. package/dist/menu/MenuOption.svelte +0 -45
  45. package/dist/menu/MenuOption.svelte.d.ts +0 -25
  46. package/dist/menu/menu.d.ts +0 -1
  47. package/dist/menu/menu.js +0 -3
  48. package/dist/providers/drag-drop-provider.d.ts +0 -9
  49. package/dist/providers/drag-drop-provider.js +0 -33
  50. package/dist/providers/movement-provider.d.ts +0 -7
  51. package/dist/providers/movement-provider.js +0 -102
  52. package/dist/providers/selection-provider.d.ts +0 -25
  53. package/dist/providers/selection-provider.js +0 -155
  54. package/dist/tree-styles.scss +0 -147
  55. package/dist/types.d.ts +0 -85
  56. package/dist/types.js +0 -26
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 KeenMate
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,98 +1,485 @@
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
+ # @keenmate/svelte-treeview
2
+
3
+ A high-performance, feature-rich hierarchical tree view component for Svelte 5 with drag & drop support, search functionality, and flexible data structures using LTree.
4
+
5
+ ## 🚀 Features
6
+
7
+ - **Svelte 5 Native**: Built specifically for Svelte 5 with full support for runes and modern Svelte patterns
8
+ - **High Performance**: Uses LTree data structure for efficient hierarchical data management
9
+ - **Drag & Drop**: Built-in drag and drop support with validation and visual feedback
10
+ - **Search & Filter**: Integrated FlexSearch for fast, full-text search capabilities
11
+ - **Flexible Data Sources**: Works with any hierarchical data structure
12
+ - **Context Menus**: Right-click context menus with customizable actions
13
+ - **Visual Customization**: Extensive styling options and icon customization
14
+ - **TypeScript Support**: Full TypeScript support with comprehensive type definitions
15
+ - **Accessibility**: Built with accessibility in mind
16
+
17
+ ## 📦 Installation
18
+
19
+ ```bash
20
+ npm install @keenmate/svelte-treeview
21
+ ```
22
+
23
+ ## 🔨 Development Setup
24
+
25
+ For developers working on the project, you can use either standard npm commands or the provided Makefile (which provides a unified interface for all contributors):
26
+
27
+ ```bash
28
+ # Using Makefile (recommended for consistency)
29
+ make setup # or make install
30
+ make dev
31
+
32
+ # Or using standard npm commands
33
+ npm install
34
+ npm run dev
35
+ ```
36
+
37
+ ## 🎨 Importing Styles
38
+
39
+ The component requires CSS to display correctly. Import the styles in your app:
40
+
41
+ ### Option 1: Import SCSS in your main app file
42
+ ```javascript
43
+ // In your main.js or main.ts
44
+ import '@keenmate/svelte-treeview/styles.scss';
45
+ ```
46
+
47
+ ### Option 2: Import in your Svelte component
48
+ ```svelte
49
+ <style>
50
+ @import '@keenmate/svelte-treeview/styles.scss';
51
+ </style>
52
+ ```
53
+
54
+ ### Option 3: Use with your build system
55
+ If using Vite, Webpack, or similar, you can import the SCSS:
56
+ ```javascript
57
+ import '@keenmate/svelte-treeview/styles.scss';
58
+ ```
59
+
60
+ ## 🎯 Quick Start
61
+
62
+ ```svelte
63
+ <script lang="ts">
64
+ import { Tree } from '@keenmate/svelte-treeview';
65
+
66
+ const data = [
67
+ { path: '1', name: 'Documents', type: 'folder' },
68
+ { path: '1.1', name: 'Projects', type: 'folder' },
69
+ { path: '1.1.1', name: 'Project A', type: 'folder' },
70
+ { path: '1.1.2', name: 'Project B', type: 'folder' },
71
+ { path: '2', name: 'Pictures', type: 'folder' },
72
+ { path: '2.1', name: 'Vacation', type: 'folder' }
73
+ ];
74
+ </script>
75
+
76
+ <Tree
77
+ {data}
78
+ idMember="path"
79
+ pathMember="path"
80
+ displayValueMember="name"
81
+ />
82
+ ```
83
+
84
+ ## 🔧 Advanced Usage
85
+
86
+ ### With Custom Node Templates
87
+
88
+ ```svelte
89
+ <script lang="ts">
90
+ import { Tree } from '@keenmate/svelte-treeview';
91
+
92
+ const fileData = [
93
+ { path: '1', name: 'Documents', type: 'folder', icon: '📁' },
94
+ { path: '1.1', name: 'report.pdf', type: 'file', icon: '📄', size: '2.3 MB' },
95
+ { path: '2', name: 'Images', type: 'folder', icon: '🖼️' },
96
+ { path: '2.1', name: 'photo.jpg', type: 'file', icon: '🖼️', size: '1.8 MB' }
97
+ ];
98
+ </script>
99
+
100
+ <Tree
101
+ data={fileData}
102
+ idMember="path"
103
+ pathMember="path"
104
+ selectedNodeClass="ltree-selected-bold"
105
+ onNodeClicked={(node) => console.log('Clicked:', node.data.name)}
106
+ >
107
+ {#snippet nodeTemplate(node)}
108
+ <div class="d-flex align-items-center">
109
+ <span class="me-2">{node.data.icon}</span>
110
+ <strong>{node.data.name}</strong>
111
+ {#if node.data.size}
112
+ <small class="text-muted ms-2">({node.data.size})</small>
113
+ {/if}
114
+ </div>
115
+ {/snippet}
116
+ </Tree>
117
+ ```
118
+
119
+ ### With Search and Filtering
120
+
121
+ ```svelte
122
+ <script lang="ts">
123
+ import { Tree } from '@keenmate/svelte-treeview';
124
+
125
+ let searchText = $state('');
126
+ const data = [/* your data */];
127
+ </script>
128
+
129
+ <input
130
+ type="text"
131
+ placeholder="Search..."
132
+ bind:value={searchText}
133
+ />
134
+
135
+ <Tree
136
+ {data}
137
+ idMember="path"
138
+ pathMember="path"
139
+ shouldUseInternalSearchIndex={true}
140
+ searchValueMember="name"
141
+ bind:searchText
142
+ />
143
+ ```
144
+
145
+ ### With Drag & Drop
146
+
147
+ ```svelte
148
+ <script lang="ts">
149
+ import { Tree } from '@keenmate/svelte-treeview';
150
+
151
+ const sourceData = [
152
+ { path: '1', name: 'Item 1', isDraggable: true },
153
+ { path: '2', name: 'Item 2', isDraggable: true }
154
+ ];
155
+
156
+ const targetData = [
157
+ { path: 'zone1', name: 'Drop Zone 1' },
158
+ { path: 'zone2', name: 'Drop Zone 2' }
159
+ ];
160
+
161
+ function onDragStart(node, event) {
162
+ console.log('Dragging:', node.data.name);
163
+ }
164
+
165
+ function onDrop(dropNode, draggedNode, event) {
166
+ console.log(`Dropped ${draggedNode.data.name} onto ${dropNode.data.name}`);
167
+ // Handle the drop logic here
168
+ }
169
+ </script>
170
+
171
+ <div class="row">
172
+ <div class="col-6">
173
+ <Tree
174
+ data={sourceData}
175
+ idMember="path"
176
+ pathMember="path"
177
+ onNodeDragStart={onDragStart}
178
+ />
179
+ </div>
180
+
181
+ <div class="col-6">
182
+ <Tree
183
+ data={targetData}
184
+ idMember="path"
185
+ pathMember="path"
186
+ onNodeDrop={onDrop}
187
+ />
188
+ </div>
189
+ </div>
190
+ ```
191
+
192
+ ## 🎨 Styling and Customization
193
+
194
+ The component comes with default styles that provide a clean, modern look. You can customize it extensively:
195
+
196
+ ### CSS Variables
197
+
198
+ The component uses CSS custom properties for easy theming:
199
+
200
+ ```css
201
+ :root {
202
+ --tree-node-indent-per-level: 0.5rem;
203
+ --ltree-primary: #0d6efd;
204
+ --ltree-primary-rgb: 13, 110, 253;
205
+ --ltree-success: #198754;
206
+ --ltree-success-rgb: 25, 135, 84;
207
+ --ltree-danger: #dc3545;
208
+ --ltree-danger-rgb: 220, 53, 69;
209
+ --ltree-light: #f8f9fa;
210
+ --ltree-border: #dee2e6;
211
+ --ltree-body-color: #212529;
212
+ }
213
+ ```
214
+
215
+ ### SCSS Variables (if using SCSS)
216
+
217
+ If you're building the styles from SCSS source, you can override these variables:
218
+
219
+ ```scss
220
+ // Import your overrides before the library styles
221
+ $tree-node-indent-per-level: 1rem;
222
+ $tree-node-font-family: 'Custom Font', sans-serif;
223
+ $primary-color: #custom-color;
224
+
225
+ @import '@keenmate/svelte-treeview/styles.scss';
226
+ ```
227
+
228
+ ### CSS Classes
229
+
230
+ - `.ltree-tree` - Main tree container
231
+ - `.ltree-node` - Individual node container
232
+ - `.ltree-node-content` - Node content area
233
+ - `.ltree-toggle-icon` - Expand/collapse icons
234
+ - `.ltree-selected-*` - Selected node styles
235
+ - `.ltree-draggable` - Draggable nodes
236
+ - `.ltree-context-menu` - Context menu styling
237
+ - `.ltree-drag-over` - Applied during drag operations
238
+ - `.ltree-drop-valid` / `.ltree-drop-invalid` - Drop target validation
239
+
240
+ ### Pre-built Selected Node Styles
241
+
242
+ The component includes several pre-built classes for styling selected nodes:
243
+
244
+ ```svelte
245
+ <Tree
246
+ {data}
247
+ idMember="path"
248
+ pathMember="path"
249
+ selectedNodeClass="ltree-selected-bold"
250
+ />
251
+ ```
252
+
253
+ **Available Selected Node Classes:**
254
+
255
+ | Class | Description | Visual Effect |
256
+ |-------|-------------|---------------|
257
+ | `ltree-selected-bold` | Bold text with primary color | **Bold text** in theme primary color |
258
+ | `ltree-selected-border` | Border and background highlight | Solid border with light background |
259
+ | `ltree-selected-brackets` | Decorative brackets around text | ❯ **Node Text** ❮ |
260
+
261
+ ### Custom Icon Classes
262
+
263
+ ```svelte
264
+ <Tree
265
+ {data}
266
+ idMember="path"
267
+ pathMember="path"
268
+ expandIconClass="custom-expand-icon"
269
+ collapseIconClass="custom-collapse-icon"
270
+ leafIconClass="custom-leaf-icon"
271
+ />
272
+ ```
273
+
274
+ ## 📚 API Reference
275
+
276
+ ### Tree Component Props
277
+
278
+ #### Core Required Properties
279
+ | Prop | Type | Required | Description |
280
+ |------|------|----------|-------------|
281
+ | `data` | `T[]` | ✅ | Array of data objects |
282
+ | `idMember` | `string` | ✅ | Property name for unique identifiers |
283
+ | `pathMember` | `string` | ✅ | Property name for hierarchical paths |
284
+ | `sortCallback` | `(items: T[]) => T[]` | ✅ | Function to sort items |
285
+
286
+ #### Data Mapping Properties
287
+ | Prop | Type | Default | Description |
288
+ |------|------|---------|-------------|
289
+ | `treeId` | `string \| null` | `null` | Unique identifier for the tree |
290
+ | `parentPathMember` | `string \| null` | `null` | Property name for parent path references |
291
+ | `levelMember` | `string \| null` | `null` | Property name for node level |
292
+ | `isExpandedMember` | `string \| null` | `null` | Property name for expanded state |
293
+ | `isSelectedMember` | `string \| null` | `null` | Property name for selected state |
294
+ | `isDraggableMember` | `string \| null` | `null` | Property name for draggable state |
295
+ | `isDropAllowedMember` | `string \| null` | `null` | Property name for drop allowed state |
296
+ | `hasChildrenMember` | `string \| null` | `null` | Property name for children existence |
297
+ | `isSorted` | `boolean \| null` | `null` | Whether items should be sorted |
298
+
299
+ #### Display & Search Properties
300
+ | Prop | Type | Default | Description |
301
+ |------|------|---------|-------------|
302
+ | `displayValueMember` | `string \| null` | `null` | Property name for display text |
303
+ | `getDisplayValueCallback` | `(node) => string` | `undefined` | Function to get display value |
304
+ | `searchValueMember` | `string \| null` | `null` | Property name for search indexing |
305
+ | `getSearchValueCallback` | `(node) => string` | `undefined` | Function to get search value |
306
+ | `shouldUseInternalSearchIndex` | `boolean` | `false` | Enable built-in search functionality |
307
+ | `initializeIndexCallback` | `() => Index` | `undefined` | Function to initialize search index |
308
+ | `searchText` | `string` (bindable) | `undefined` | Current search text |
309
+
310
+ **Note**: When `shouldUseInternalSearchIndex` is enabled, node indexing is performed asynchronously using `requestIdleCallback` (with fallback to `setTimeout`). This ensures the tree renders immediately while search indexing happens during browser idle time, providing better performance for large datasets.
311
+
312
+ **⚠️ Important**: For internal search indexing to work, you must:
313
+ 1. Set `shouldUseInternalSearchIndex={true}`
314
+ 2. Provide either `searchValueMember` (property name) or `getSearchValueCallback` (function)
315
+
316
+ Without both requirements, no search indexing will occur.
317
+
318
+ #### Tree Configuration
319
+ | Prop | Type | Default | Description |
320
+ |------|------|---------|-------------|
321
+ | `treeId` | `string \| null` | auto-generated | Unique identifier for the tree |
322
+ | `selectedNode` | `LTreeNode<T>` (bindable) | `undefined` | Currently selected node |
323
+
324
+ #### Behavior Properties
325
+ | Prop | Type | Default | Description |
326
+ |------|------|---------|-------------|
327
+ | `expandLevel` | `number \| null` | `2` | Automatically expand nodes up to this level |
328
+ | `shouldToggleOnNodeClick` | `boolean` | `true` | Toggle expansion on node click |
329
+ | `shouldDisplayDebugInformation` | `boolean` | `false` | Show debug information panel with tree statistics |
330
+
331
+ #### Event Handler Properties
332
+ | Prop | Type | Default | Description |
333
+ |------|------|---------|-------------|
334
+ | `onNodeClicked` | `(node) => void` | `undefined` | Node click event handler |
335
+ | `onNodeDragStart` | `(node, event) => void` | `undefined` | Drag start event handler |
336
+ | `onNodeDragOver` | `(node, event) => void` | `undefined` | Drag over event handler |
337
+ | `onNodeDrop` | `(dropNode, draggedNode, event) => void` | `undefined` | Drop event handler |
338
+
339
+ #### Visual Styling Properties
340
+ | Prop | Type | Default | Description |
341
+ |------|------|---------|-------------|
342
+ | `bodyClass` | `string \| null` | `undefined` | CSS class for tree body |
343
+ | `selectedNodeClass` | `string \| null` | `undefined` | CSS class for selected nodes |
344
+ | `expandIconClass` | `string \| null` | `"ltree-icon-expand"` | CSS class for expand icons |
345
+ | `collapseIconClass` | `string \| null` | `"ltree-icon-collapse"` | CSS class for collapse icons |
346
+ | `leafIconClass` | `string \| null` | `"ltree-icon-leaf"` | CSS class for leaf node icons |
347
+
348
+ #### Available Slots
349
+ | Slot | Description |
350
+ |------|-------------|
351
+ | `nodeTemplate` | Custom node template |
352
+ | `treeHeader` | Tree header content |
353
+ | `treeBody` | Tree body content |
354
+ | `treeFooter` | Tree footer content |
355
+ | `noDataFound` | No data template |
356
+ | `contextMenu` | Context menu template |
357
+
358
+ #### Public Methods
359
+ | Method | Parameters | Description |
360
+ |--------|------------|-------------|
361
+ | `expandNodes` | `nodePath: string` | Expand nodes at specified path |
362
+ | `collapseNodes` | `nodePath: string` | Collapse nodes at specified path |
363
+ | `expandAll` | `nodePath?: string` | Expand all nodes or nodes under path |
364
+ | `collapseAll` | `nodePath?: string` | Collapse all nodes or nodes under path |
365
+
366
+ #### Statistics
367
+ The tree provides real-time statistics about the loaded data:
368
+
369
+ | Property | Type | Description |
370
+ |----------|------|-------------|
371
+ | `statistics` | `{ nodeCount: number; maxLevel: number; filteredNodeCount: number; isIndexing: boolean; pendingIndexCount: number }` | Returns current node count, maximum depth level, filtered nodes count, indexing status, and pending index count |
372
+
373
+ ```typescript
374
+ const { nodeCount, maxLevel, filteredNodeCount, isIndexing, pendingIndexCount } = tree.statistics;
375
+ console.log(`Tree has ${nodeCount} nodes with maximum depth of ${maxLevel} levels`);
376
+ if (filteredNodeCount > 0) {
377
+ console.log(`Currently showing ${filteredNodeCount} filtered nodes`);
378
+ }
379
+ if (isIndexing) {
380
+ console.log(`Search indexing in progress: ${pendingIndexCount} nodes pending`);
381
+ }
382
+ ```
383
+
384
+ ### Debug Information
385
+
386
+ Enable debug information to see real-time tree statistics:
387
+
388
+ ```svelte
389
+ <Tree
390
+ {data}
391
+ idMember="path"
392
+ pathMember="path"
393
+ shouldDisplayDebugInformation={true}
394
+ />
395
+ ```
396
+
397
+ The debug panel shows:
398
+ - Tree ID
399
+ - Data array length
400
+ - Expand level setting
401
+ - Node count
402
+ - Maximum depth levels
403
+ - Filtered node count (when filtering is active)
404
+ - Search indexing progress (when indexing is active)
405
+ - Currently dragged node
406
+
407
+ ### Events
408
+
409
+ #### onNodeClicked(node)
410
+ Triggered when a node is clicked.
411
+
412
+ #### onNodeDragStart(node, event)
413
+ Triggered when drag operation starts.
414
+
415
+ #### onNodeDragOver(node, event)
416
+ Triggered when dragging over a potential drop target.
417
+
418
+ #### onNodeDrop(dropNode, draggedNode, event)
419
+ Triggered when a node is dropped onto another node.
420
+
421
+ ### Slots
422
+
423
+ #### nodeTemplate
424
+ Custom template for rendering node content.
425
+
426
+ ```svelte
427
+ {#snippet nodeTemplate(node)}
428
+ <!-- Your custom node content -->
429
+ {/snippet}
430
+ ```
431
+
432
+ #### contextMenu
433
+ Custom context menu template.
434
+
435
+ ```svelte
436
+ {#snippet contextMenu(node, closeMenu)}
437
+ <button onclick={() => { /* action */ closeMenu(); }}>
438
+ Action
439
+ </button>
440
+ {/snippet}
441
+ ```
442
+
443
+ ## 🏗️ Data Structure
444
+
445
+ The component expects hierarchical data with path-based organization:
446
+
447
+ ```typescript
448
+ interface NodeData {
449
+ path: string; // e.g., "1.2.3" for hierarchical positioning
450
+ // ... your custom properties
451
+ }
452
+ ```
453
+
454
+ ### Path Examples
455
+
456
+ - Root level: `"1"`, `"2"`, `"3"`
457
+ - Second level: `"1.1"`, `"1.2"`, `"2.1"`
458
+ - Third level: `"1.1.1"`, `"1.2.1"`, `"2.1.1"`
459
+
460
+ ## 🚀 Performance
461
+
462
+ The component is optimized for large datasets:
463
+
464
+ - **LTree**: Efficient hierarchical data structure
465
+ - **Async Search Indexing**: Uses `requestIdleCallback` for non-blocking search index building
466
+ - **Virtual Scrolling**: (Coming soon)
467
+ - **Lazy Loading**: (Coming soon)
468
+ - **Search Indexing**: Uses FlexSearch for fast search operations
469
+
470
+ ## 🤝 Contributing
471
+
472
+ We welcome contributions! Please see our contributing guidelines for details.
473
+
474
+ ## 📄 License
475
+
476
+ MIT License - see LICENSE file for details.
477
+
478
+ ## 🆘 Support
479
+
480
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/keenmate/svelte-treeview/issues)
481
+ - **Documentation**: [Full documentation](https://github.com/keenmate/svelte-treeview#readme)
482
+
483
+ ---
484
+
485
+ Built with ❤️ by [KeenMate](https://github.com/keenmate)