@keenmate/svelte-treeview 4.2.0 → 4.2.1
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 +22 -0
- package/dist/components/Tree.svelte +13 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -512,6 +512,7 @@ Without both requirements, no search indexing will occur.
|
|
|
512
512
|
| `indexerBatchSize` | `number \| null` | `25` | Number of nodes to process per batch during search indexing |
|
|
513
513
|
| `indexerTimeout` | `number \| null` | `50` | Maximum time (ms) to wait for idle callback before forcing indexing |
|
|
514
514
|
| `shouldDisplayDebugInformation` | `boolean` | `false` | Show debug information panel with tree statistics and enable console debug logging for tree operations and async search indexing |
|
|
515
|
+
| `shouldDisplayContextMenuInDebugMode` | `boolean` | `false` | Display persistent context menu at fixed position for styling development |
|
|
515
516
|
|
|
516
517
|
#### Event Handler Properties
|
|
517
518
|
| Prop | Type | Default | Description |
|
|
@@ -732,6 +733,27 @@ Horizontal offset from cursor position (default: 8px).
|
|
|
732
733
|
#### contextMenuYOffset
|
|
733
734
|
Vertical offset from cursor position (default: 0px).
|
|
734
735
|
|
|
736
|
+
#### shouldDisplayContextMenuInDebugMode
|
|
737
|
+
When enabled, displays a persistent context menu at a fixed position for styling development (default: false).
|
|
738
|
+
|
|
739
|
+
```svelte
|
|
740
|
+
<Tree
|
|
741
|
+
{data}
|
|
742
|
+
contextMenuCallback={createContextMenu}
|
|
743
|
+
shouldDisplayContextMenuInDebugMode={true}
|
|
744
|
+
shouldDisplayDebugInformation={true}
|
|
745
|
+
contextMenuXOffset={10}
|
|
746
|
+
contextMenuYOffset={5}
|
|
747
|
+
/>
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
**Debug Mode Features:**
|
|
751
|
+
- Shows context menu for the second node (or first if only one exists)
|
|
752
|
+
- Positions menu 200px right and 100px down from tree's top-left corner
|
|
753
|
+
- Persistent display - no need to right-click repeatedly
|
|
754
|
+
- Perfect for CSS styling and position testing
|
|
755
|
+
- Works with both callback-based and snippet-based context menus
|
|
756
|
+
|
|
735
757
|
## 🏗️ Data Structure
|
|
736
758
|
|
|
737
759
|
The component expects hierarchical data with path-based organization:
|
|
@@ -410,7 +410,7 @@
|
|
|
410
410
|
|
|
411
411
|
const handleGlobalScroll = (event?: Event) => {
|
|
412
412
|
if (shouldDisplayDebugInformation) {
|
|
413
|
-
console.log(
|
|
413
|
+
console.log(`[Tree ${treeId}] Scroll/wheel event detected, closing context menu`, event?.type);
|
|
414
414
|
}
|
|
415
415
|
closeContextMenu();
|
|
416
416
|
};
|
|
@@ -436,21 +436,23 @@
|
|
|
436
436
|
|
|
437
437
|
// Debug context menu - show context menu on second node for styling development
|
|
438
438
|
let isDebugMenuActive = $state(false);
|
|
439
|
+
let treeContainerRef: HTMLDivElement;
|
|
439
440
|
|
|
440
441
|
$effect(() => {
|
|
441
|
-
if (shouldDisplayContextMenuInDebugMode && (contextMenu || contextMenuCallback) && tree?.tree && tree.tree.length >
|
|
442
|
-
//
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
445
|
-
// Position the context menu
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
442
|
+
if (shouldDisplayContextMenuInDebugMode && (contextMenu || contextMenuCallback) && tree?.tree && tree.tree.length > 0) {
|
|
443
|
+
// Use the first available node for the context menu data
|
|
444
|
+
const targetNode = tree.tree.length > 1 ? tree.tree[1] : tree.tree[0];
|
|
445
|
+
if (targetNode && treeContainerRef) {
|
|
446
|
+
// Position the context menu relative to the tree container
|
|
447
|
+
const treeRect = treeContainerRef.getBoundingClientRect();
|
|
448
|
+
contextMenuNode = targetNode;
|
|
449
|
+
contextMenuX = treeRect.left + 200; // 200px from tree's left edge
|
|
450
|
+
contextMenuY = treeRect.top + 100; // 100px from tree's top edge
|
|
449
451
|
contextMenuVisible = true;
|
|
450
452
|
isDebugMenuActive = true;
|
|
451
453
|
|
|
452
454
|
if (shouldDisplayDebugInformation) {
|
|
453
|
-
console.log(
|
|
455
|
+
console.log(`[Tree ${treeId}] Debug context menu displayed for node:`, targetNode.data, `at position (${contextMenuX}, ${contextMenuY})`);
|
|
454
456
|
}
|
|
455
457
|
}
|
|
456
458
|
} else if (!shouldDisplayContextMenuInDebugMode && isDebugMenuActive) {
|
|
@@ -462,7 +464,7 @@
|
|
|
462
464
|
});
|
|
463
465
|
</script>
|
|
464
466
|
|
|
465
|
-
<div>
|
|
467
|
+
<div bind:this={treeContainerRef}>
|
|
466
468
|
{#if shouldDisplayDebugInformation}
|
|
467
469
|
<div class="ltree-debug-info">
|
|
468
470
|
<details>
|