@keenmate/svelte-treeview 1.1.0-beta.1 → 1.1.0-beta.2
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/dist/Branch.svelte +3 -3
- package/dist/Branch.svelte.d.ts +1 -1
- package/dist/TreeView.svelte +10 -1
- package/dist/TreeView.svelte.d.ts +1 -0
- package/dist/constants.js +9 -1
- package/package.json +1 -1
package/dist/Branch.svelte
CHANGED
|
@@ -21,7 +21,7 @@ export let draggedNode;
|
|
|
21
21
|
export let highlightedNode;
|
|
22
22
|
export let insertionType;
|
|
23
23
|
export let focusedNode;
|
|
24
|
-
export let
|
|
24
|
+
export let allowKeyboardNavigation;
|
|
25
25
|
let liElements = {};
|
|
26
26
|
const getNodeId = (node) => `${treeId}-${node.path}`;
|
|
27
27
|
$: directChildren = helper.getDirectChildren(tree, branchRootNode?.path ?? null);
|
|
@@ -101,7 +101,7 @@ function getHighlighMode(node, highlightedNode, insertionType) {
|
|
|
101
101
|
on:dragleave|stopPropagation={(e) => handleDragLeave(e, node, liElements[getNodeId(node)])}
|
|
102
102
|
bind:this={liElements[getNodeId(node)]}
|
|
103
103
|
on:keydown={(e) => handleKeyPress(e, node)}
|
|
104
|
-
tabindex={
|
|
104
|
+
tabindex={allowKeyboardNavigation ? 1 : -1}
|
|
105
105
|
>
|
|
106
106
|
{#if effectiveHighlight == InsertionType.insertAbove}
|
|
107
107
|
<div class="insert-line-wrapper">
|
|
@@ -179,7 +179,7 @@ function getHighlighMode(node, highlightedNode, insertionType) {
|
|
|
179
179
|
{highlightedNode}
|
|
180
180
|
{insertionType}
|
|
181
181
|
{focusedNode}
|
|
182
|
-
{
|
|
182
|
+
{allowKeyboardNavigation}
|
|
183
183
|
on:open-ctxmenu
|
|
184
184
|
on:internal-expand
|
|
185
185
|
on:internal-selectionChanged
|
package/dist/Branch.svelte.d.ts
CHANGED
package/dist/TreeView.svelte
CHANGED
|
@@ -147,7 +147,6 @@ export function expandToNode(nodePath) {
|
|
|
147
147
|
}
|
|
148
148
|
const parents = helper.getParents(computedTree, targetNode);
|
|
149
149
|
debugLog("expanding to node '" + nodePath + "'" + ' parents', parents);
|
|
150
|
-
console.log('parents', parents);
|
|
151
150
|
expandedIds = uniq([...expandedIds, ...parents.map((node) => node.id)]);
|
|
152
151
|
}
|
|
153
152
|
export function setNodeExpansion(nodePath, changeTo) {
|
|
@@ -333,9 +332,19 @@ function onKeyPress(detail) {
|
|
|
333
332
|
onExpand({ node: node, changeTo: setExpansion });
|
|
334
333
|
}
|
|
335
334
|
dispatch('focus', node);
|
|
335
|
+
return;
|
|
336
336
|
}
|
|
337
337
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
338
338
|
onSelectionChanged({ node: targetNode });
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (event.key === 'Escape') {
|
|
342
|
+
focusedNode = null;
|
|
343
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
344
|
+
document.activeElement.blur();
|
|
345
|
+
}
|
|
346
|
+
dispatch('focus-leave');
|
|
347
|
+
return;
|
|
339
348
|
}
|
|
340
349
|
}
|
|
341
350
|
function debugLog(...data) {
|
package/dist/constants.js
CHANGED
|
@@ -22,4 +22,12 @@ export const defaultClasses = {
|
|
|
22
22
|
export const defaultConfig = {
|
|
23
23
|
separator: '.'
|
|
24
24
|
};
|
|
25
|
-
export const capturedKeys = [
|
|
25
|
+
export const capturedKeys = [
|
|
26
|
+
'ArrowUp',
|
|
27
|
+
'ArrowDown',
|
|
28
|
+
'ArrowLeft',
|
|
29
|
+
'ArrowRight',
|
|
30
|
+
'Enter',
|
|
31
|
+
' ',
|
|
32
|
+
'Escape'
|
|
33
|
+
];
|