@keenmate/svelte-treeview 1.1.0-beta.1 → 1.1.0-beta.3
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 +13 -2
- package/dist/TreeView.svelte.d.ts +5 -4
- 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) {
|
|
@@ -177,9 +176,11 @@ export function focusFirstNode() {
|
|
|
177
176
|
const rootChildren = helper.getDirectChildren(computedTree, null);
|
|
178
177
|
if (rootChildren.length === 0) {
|
|
179
178
|
focusedNode = null;
|
|
180
|
-
return;
|
|
179
|
+
return null;
|
|
181
180
|
}
|
|
182
181
|
focusedNode = rootChildren[0];
|
|
182
|
+
dispatch('focus', focusedNode);
|
|
183
|
+
return focusedNode;
|
|
183
184
|
}
|
|
184
185
|
function computeTree(helper, selectionProvider, userProvidedTree, filter, props, expandedIds, value) {
|
|
185
186
|
if (!Array.isArray(userProvidedTree) || !Array.isArray(value)) {
|
|
@@ -333,9 +334,19 @@ function onKeyPress(detail) {
|
|
|
333
334
|
onExpand({ node: node, changeTo: setExpansion });
|
|
334
335
|
}
|
|
335
336
|
dispatch('focus', node);
|
|
337
|
+
return;
|
|
336
338
|
}
|
|
337
339
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
338
340
|
onSelectionChanged({ node: targetNode });
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (event.key === 'Escape') {
|
|
344
|
+
focusedNode = null;
|
|
345
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
346
|
+
document.activeElement.blur();
|
|
347
|
+
}
|
|
348
|
+
dispatch('focus-leave');
|
|
349
|
+
return;
|
|
339
350
|
}
|
|
340
351
|
}
|
|
341
352
|
function debugLog(...data) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { SelectionModes as SelectionModes, type Props, type CustomizableClasses, type DragEnterCallback, type ExpandedCallback, type NodeId, type ProvidedTree, type FilterFunction } from './types.js';
|
|
2
|
+
import { SelectionModes as SelectionModes, type Node, type Props, type CustomizableClasses, type DragEnterCallback, type ExpandedCallback, type NodeId, type ProvidedTree, type FilterFunction } from './types.js';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
treeId: string;
|
|
@@ -87,9 +87,10 @@ declare const __propDef: {
|
|
|
87
87
|
setNodeExpansion?: ((nodePath: string, changeTo: boolean) => void) | undefined;
|
|
88
88
|
setExpansions?: ((expansions: NodeId[]) => void) | undefined;
|
|
89
89
|
focusNode?: ((nodePath: string | null) => void) | undefined;
|
|
90
|
-
focusFirstNode?: (() =>
|
|
90
|
+
focusFirstNode?: (() => Node | null) | undefined;
|
|
91
91
|
};
|
|
92
92
|
events: {
|
|
93
|
+
focus: CustomEvent<any>;
|
|
93
94
|
expansion: CustomEvent<any>;
|
|
94
95
|
expanded: CustomEvent<any>;
|
|
95
96
|
closed: CustomEvent<any>;
|
|
@@ -98,7 +99,7 @@ declare const __propDef: {
|
|
|
98
99
|
selected: CustomEvent<any>;
|
|
99
100
|
unselected: CustomEvent<any>;
|
|
100
101
|
moved: CustomEvent<any>;
|
|
101
|
-
focus: CustomEvent<any>;
|
|
102
|
+
'focus-leave': CustomEvent<any>;
|
|
102
103
|
} & {
|
|
103
104
|
[evt: string]: CustomEvent<any>;
|
|
104
105
|
};
|
|
@@ -121,6 +122,6 @@ export default class TreeView extends SvelteComponent<TreeViewProps, TreeViewEve
|
|
|
121
122
|
get setNodeExpansion(): (nodePath: string, changeTo: boolean) => void;
|
|
122
123
|
get setExpansions(): (expansions: NodeId[]) => void;
|
|
123
124
|
get focusNode(): (nodePath: string | null) => void;
|
|
124
|
-
get focusFirstNode(): () =>
|
|
125
|
+
get focusFirstNode(): () => Node | null;
|
|
125
126
|
}
|
|
126
127
|
export {};
|
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
|
+
];
|