epiq 0.0.4 → 0.1.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/dist/cli.js +398 -33
- package/package.json +26 -11
- package/readme.md +54 -17
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -18
- package/dist/board/components/Board.d.ts +0 -6
- package/dist/board/components/Board.js +0 -11
- package/dist/board/components/CommandLine.d.ts +0 -2
- package/dist/board/components/CommandLine.js +0 -26
- package/dist/board/components/ContextBar.d.ts +0 -4
- package/dist/board/components/ContextBar.js +0 -17
- package/dist/board/components/Help.d.ts +0 -4
- package/dist/board/components/Help.js +0 -28
- package/dist/board/components/Logo.d.ts +0 -2
- package/dist/board/components/Logo.js +0 -21
- package/dist/board/components/ScrollBox.d.ts +0 -9
- package/dist/board/components/ScrollBox.js +0 -22
- package/dist/board/components/Swimlane.d.ts +0 -9
- package/dist/board/components/Swimlane.js +0 -12
- package/dist/board/components/Swimlanes.d.ts +0 -8
- package/dist/board/components/Swimlanes.js +0 -17
- package/dist/board/components/TextInput.d.ts +0 -6
- package/dist/board/components/TextInput.js +0 -9
- package/dist/board/components/TicketListItem.d.ts +0 -6
- package/dist/board/components/TicketListItem.js +0 -13
- package/dist/board/components/TicketUI.d.ts +0 -8
- package/dist/board/components/TicketUI.js +0 -8
- package/dist/board/hints/hints.d.ts +0 -7
- package/dist/board/hints/hints.js +0 -21
- package/dist/board/mock/board.d.ts +0 -2
- package/dist/board/mock/board.js +0 -520
- package/dist/board/model/board.model.d.ts +0 -26
- package/dist/board/model/board.model.js +0 -6
- package/dist/board/render/color.d.ts +0 -7
- package/dist/board/render/color.js +0 -21
- package/dist/cli.d.ts +0 -3
- package/dist/debug-logger.d.ts +0 -2
- package/dist/debug-logger.js +0 -16
- package/dist/init-project.d.ts +0 -1
- package/dist/init-project.js +0 -1
- package/dist/navigation/actions/add/add-actions.d.ts +0 -2
- package/dist/navigation/actions/add/add-actions.js +0 -25
- package/dist/navigation/actions/add/add-item-actions.d.ts +0 -2
- package/dist/navigation/actions/add/add-item-actions.js +0 -25
- package/dist/navigation/actions/add-item/add-item-actions.d.ts +0 -3
- package/dist/navigation/actions/add-item/add-item-actions.js +0 -45
- package/dist/navigation/actions/board-action-map.d.ts +0 -10
- package/dist/navigation/actions/board-action-map.js +0 -12
- package/dist/navigation/actions/default/default-action-utils.d.ts +0 -8
- package/dist/navigation/actions/default/default-action-utils.js +0 -101
- package/dist/navigation/actions/default/default-actions.d.ts +0 -2
- package/dist/navigation/actions/default/default-actions.js +0 -64
- package/dist/navigation/actions/default/navigation-action-utils.d.ts +0 -16
- package/dist/navigation/actions/default/navigation-action-utils.js +0 -109
- package/dist/navigation/actions/input/command-line-input.d.ts +0 -2
- package/dist/navigation/actions/input/command-line-input.js +0 -18
- package/dist/navigation/actions/input/input-actions-utils.d.ts +0 -8
- package/dist/navigation/actions/input/input-actions-utils.js +0 -47
- package/dist/navigation/actions/input/input-actions.d.ts +0 -2
- package/dist/navigation/actions/input/input-actions.js +0 -44
- package/dist/navigation/actions/move/move-actions-routes.d.ts +0 -4
- package/dist/navigation/actions/move/move-actions-routes.js +0 -55
- package/dist/navigation/actions/move/move-actions-utils.d.ts +0 -4
- package/dist/navigation/actions/move/move-actions-utils.js +0 -66
- package/dist/navigation/actions/move/move-actions.d.ts +0 -4
- package/dist/navigation/actions/move/move-actions.js +0 -59
- package/dist/navigation/actions/navigate/navigation-action-utils.d.ts +0 -7
- package/dist/navigation/actions/navigate/navigation-action-utils.js +0 -48
- package/dist/navigation/actions/navigate/navigation-actions.d.ts +0 -2
- package/dist/navigation/actions/navigate/navigation-actions.js +0 -78
- package/dist/navigation/command-line/command-line-actions.d.ts +0 -2
- package/dist/navigation/command-line/command-line-actions.js +0 -32
- package/dist/navigation/command-line/command-line-intent.d.ts +0 -7
- package/dist/navigation/command-line/command-line-intent.js +0 -29
- package/dist/navigation/command-line/command-line-sequence-actions.d.ts +0 -2
- package/dist/navigation/command-line/command-line-sequence-actions.js +0 -44
- package/dist/navigation/command-line/command-line-sequence-intent.d.ts +0 -8
- package/dist/navigation/command-line/command-line-sequence-intent.js +0 -32
- package/dist/navigation/command-line/commands.d.ts +0 -2
- package/dist/navigation/command-line/commands.js +0 -58
- package/dist/navigation/keypress-listener.d.ts +0 -1
- package/dist/navigation/keypress-listener.js +0 -33
- package/dist/navigation/model/action-map.model.d.ts +0 -26
- package/dist/navigation/model/action-map.model.js +0 -6
- package/dist/navigation/model/navigation-ctx.model.d.ts +0 -1
- package/dist/navigation/model/navigation-ctx.model.js +0 -1
- package/dist/navigation/model/navigation-tree.model.d.ts +0 -11
- package/dist/navigation/model/navigation-tree.model.js +0 -1
- package/dist/navigation/navigation-ctx.d.ts +0 -1
- package/dist/navigation/navigation-ctx.js +0 -1
- package/dist/navigation/navigation.d.ts +0 -3
- package/dist/navigation/navigation.js +0 -82
- package/dist/navigation/state/command-line.state.d.ts +0 -18
- package/dist/navigation/state/command-line.state.js +0 -60
- package/dist/navigation/state/state.d.ts +0 -20
- package/dist/navigation/state/state.js +0 -38
- package/dist/navigation/utils/get-command-line-intent.d.ts +0 -3
- package/dist/navigation/utils/get-command-line-intent.js +0 -17
- package/dist/navigation/utils/getKeyIntent.d.ts +0 -5
- package/dist/navigation/utils/getKeyIntent.js +0 -71
- package/dist/navigation/utils/key-intent.d.ts +0 -25
- package/dist/navigation/utils/key-intent.js +0 -119
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { BoardItemTypes, } from '../../../board/model/board.model.js';
|
|
2
|
-
import { appState } from '../../state/state.js';
|
|
3
|
-
import { navigator } from '../default/navigation-action-utils.js';
|
|
4
|
-
export const addSwimlaneAction = async (_ctx, _cmd, { value }) => {
|
|
5
|
-
const newItem = {
|
|
6
|
-
id: `${Date.now()}`,
|
|
7
|
-
name: value || 'New lane',
|
|
8
|
-
description: '...',
|
|
9
|
-
actionContext: BoardItemTypes.SWIMLANE,
|
|
10
|
-
isSelected: false,
|
|
11
|
-
childrenRenderAxis: 'vertical',
|
|
12
|
-
enableChildNavigationAcrossContainers: true,
|
|
13
|
-
children: [],
|
|
14
|
-
};
|
|
15
|
-
const parent = appState.currentNode;
|
|
16
|
-
parent.children ?? (parent.children = []);
|
|
17
|
-
const newItemIndex = parent.children.length;
|
|
18
|
-
parent.children.push(newItem);
|
|
19
|
-
navigator.navigate({ selectedIndex: newItemIndex });
|
|
20
|
-
};
|
|
21
|
-
export const addTicketAction = async (_ctx, _cmd, { value }) => {
|
|
22
|
-
const newItem = {
|
|
23
|
-
id: `${Date.now()}`,
|
|
24
|
-
name: value || 'New issue',
|
|
25
|
-
actionContext: BoardItemTypes.TICKET_LIST_ITEM,
|
|
26
|
-
isSelected: false,
|
|
27
|
-
childrenRenderAxis: 'vertical',
|
|
28
|
-
children: [
|
|
29
|
-
{
|
|
30
|
-
isSelected: false,
|
|
31
|
-
id: `${Date.now()}`,
|
|
32
|
-
name: 'Description',
|
|
33
|
-
description: '...add description',
|
|
34
|
-
actionContext: BoardItemTypes.TICKET,
|
|
35
|
-
childrenRenderAxis: 'vertical',
|
|
36
|
-
children: [],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
const parent = appState.currentNode;
|
|
41
|
-
parent.children ?? (parent.children = []);
|
|
42
|
-
const newItemIndex = parent.children.length;
|
|
43
|
-
parent.children.push(newItem);
|
|
44
|
-
navigator.navigate({ selectedIndex: newItemIndex });
|
|
45
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BoardItemTypes } from '../../board/model/board.model.js';
|
|
2
|
-
import { ActionEntry, ActionMap } from '../model/action-map.model.js';
|
|
3
|
-
type BoardActionMap = ActionMap<{
|
|
4
|
-
[BoardItemTypes.BOARD]: ActionEntry[];
|
|
5
|
-
[BoardItemTypes.SWIMLANE]: ActionEntry[];
|
|
6
|
-
[BoardItemTypes.TICKET_LIST_ITEM]: ActionEntry[];
|
|
7
|
-
[BoardItemTypes.TICKET]: ActionEntry[];
|
|
8
|
-
}>;
|
|
9
|
-
export declare const ContextualActionMap: BoardActionMap;
|
|
10
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BoardItemTypes } from '../../board/model/board.model.js';
|
|
2
|
-
import { moveAcrossParents, moveWithinParent, toggleMoveMode, } from './move/move-actions.js';
|
|
3
|
-
export const ContextualActionMap = {
|
|
4
|
-
[BoardItemTypes.BOARD]: [...toggleMoveMode, ...moveWithinParent],
|
|
5
|
-
[BoardItemTypes.SWIMLANE]: [
|
|
6
|
-
...toggleMoveMode,
|
|
7
|
-
...moveWithinParent,
|
|
8
|
-
...moveAcrossParents,
|
|
9
|
-
],
|
|
10
|
-
[BoardItemTypes.TICKET_LIST_ITEM]: [],
|
|
11
|
-
[BoardItemTypes.TICKET]: [],
|
|
12
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { NavigateUtils } from '../../model/navigation-ctx.model.js';
|
|
2
|
-
export declare const navigationUtils: NavigateUtils;
|
|
3
|
-
export declare const navigateToNextItem: () => void;
|
|
4
|
-
export declare const navigateToPreviousItem: () => void;
|
|
5
|
-
export declare const navigateToNextContainer: (ctx: NavigateUtils) => void;
|
|
6
|
-
export declare const navigateToPreviousContainer: (ctx: NavigateUtils) => void;
|
|
7
|
-
export declare const enterChildNode: (ctx: NavigateUtils) => Promise<void>;
|
|
8
|
-
export declare const exitToParentNode: (ctx: NavigateUtils) => void;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { appState, patchState, updateState } from '../../state/state.js';
|
|
2
|
-
export const navigationUtils = {
|
|
3
|
-
updateSelection: (idx) => {
|
|
4
|
-
updateState(oldState => {
|
|
5
|
-
const currentNode = oldState.breadCrumb.at(-1) ?? oldState.breadCrumb[0];
|
|
6
|
-
if (!currentNode)
|
|
7
|
-
return oldState;
|
|
8
|
-
currentNode.children?.forEach((child, i) => (child.isSelected = i === idx));
|
|
9
|
-
return {
|
|
10
|
-
...oldState,
|
|
11
|
-
selectedIndex: idx,
|
|
12
|
-
currentNode: currentNode, // keep currentNode in sync
|
|
13
|
-
breadCrumb: [...oldState.breadCrumb], // keep reference fresh if you rely on it
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
},
|
|
17
|
-
selectNone() {
|
|
18
|
-
this.updateSelection(-1);
|
|
19
|
-
},
|
|
20
|
-
confirm(sel) {
|
|
21
|
-
console.log(sel);
|
|
22
|
-
},
|
|
23
|
-
exit() {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
},
|
|
26
|
-
enterChildNode(childNode) {
|
|
27
|
-
patchState({
|
|
28
|
-
breadCrumb: [...appState.breadCrumb, childNode],
|
|
29
|
-
currentNode: childNode,
|
|
30
|
-
selectedIndex: 0,
|
|
31
|
-
});
|
|
32
|
-
this.updateSelection(0);
|
|
33
|
-
},
|
|
34
|
-
enterParentNode() {
|
|
35
|
-
const crumb = appState.breadCrumb;
|
|
36
|
-
if (crumb.length < 2)
|
|
37
|
-
return;
|
|
38
|
-
const newCrumb = crumb.slice(0, -1);
|
|
39
|
-
const parentLevelNode = newCrumb.at(-1);
|
|
40
|
-
// find old parent index inside grandparent
|
|
41
|
-
const grandParent = newCrumb.at(-2);
|
|
42
|
-
const parentIndex = grandParent?.children?.findIndex(x => x.id === parentLevelNode.id) ?? 0;
|
|
43
|
-
patchState({
|
|
44
|
-
breadCrumb: newCrumb,
|
|
45
|
-
currentNode: parentLevelNode,
|
|
46
|
-
selectedIndex: parentIndex,
|
|
47
|
-
});
|
|
48
|
-
this.updateSelection(parentIndex);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
const navigateByOffset = (offset) => {
|
|
52
|
-
const len = appState.currentNode.children.length;
|
|
53
|
-
if (len === 0)
|
|
54
|
-
return;
|
|
55
|
-
const newIndex = (appState.selectedIndex + offset + len) % len;
|
|
56
|
-
navigationUtils.updateSelection(newIndex);
|
|
57
|
-
};
|
|
58
|
-
export const navigateToNextItem = () => navigateByOffset(1);
|
|
59
|
-
export const navigateToPreviousItem = () => navigateByOffset(-1);
|
|
60
|
-
const navigateToSiblingContainer = (ctx, direction) => {
|
|
61
|
-
if (!appState.currentNode.enableChildNavigationAcrossContainers)
|
|
62
|
-
return;
|
|
63
|
-
const parent = appState.breadCrumb.at(-1);
|
|
64
|
-
const grandParent = appState.breadCrumb.at(-2);
|
|
65
|
-
if (!parent || !grandParent)
|
|
66
|
-
return;
|
|
67
|
-
const parentIndex = grandParent.children.findIndex(x => x.id === parent.id);
|
|
68
|
-
const sliced = direction === -1
|
|
69
|
-
? grandParent.children.toSpliced(parentIndex).toReversed()
|
|
70
|
-
: grandParent.children.slice(parentIndex + 1);
|
|
71
|
-
const nextSibling = sliced.find(x => x.children.length);
|
|
72
|
-
if (!nextSibling?.children?.length)
|
|
73
|
-
return;
|
|
74
|
-
const prevIndex = appState.selectedIndex;
|
|
75
|
-
const boundedIndex = Math.min(prevIndex, nextSibling.children.length - 1);
|
|
76
|
-
ctx.selectNone();
|
|
77
|
-
patchState({
|
|
78
|
-
selectedIndex: boundedIndex,
|
|
79
|
-
breadCrumb: [...appState.breadCrumb.slice(0, -1), nextSibling],
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
export const navigateToNextContainer = (ctx) => navigateToSiblingContainer(ctx, 1);
|
|
83
|
-
export const navigateToPreviousContainer = (ctx) => navigateToSiblingContainer(ctx, -1);
|
|
84
|
-
export const enterChildNode = async (ctx) => {
|
|
85
|
-
const currentNode = appState.breadCrumb.at(-1);
|
|
86
|
-
const focusNode = currentNode?.children[appState.selectedIndex];
|
|
87
|
-
if (!currentNode || !focusNode)
|
|
88
|
-
return;
|
|
89
|
-
if (!focusNode?.children?.length) {
|
|
90
|
-
await ctx.enterChildNode(focusNode);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
ctx.enterChildNode(focusNode);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
export const exitToParentNode = (ctx) => {
|
|
98
|
-
if (appState.breadCrumb.length >= 2) {
|
|
99
|
-
ctx.enterParentNode();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { CmdIntent } from '../../command-line/command-line-sequence-intent.js';
|
|
2
|
-
import { Mode } from '../../model/action-map.model.js';
|
|
3
|
-
import { updateCommandLineInput } from '../../state/command-line.state.js';
|
|
4
|
-
import { appState, patchState } from '../../state/state.js';
|
|
5
|
-
import { Intent } from '../../utils/key-intent.js';
|
|
6
|
-
import { navigator } from './navigation-action-utils.js';
|
|
7
|
-
export const DefaultActions = [
|
|
8
|
-
{
|
|
9
|
-
intent: Intent.ToggleCommandLine,
|
|
10
|
-
mode: Mode.DEFAULT,
|
|
11
|
-
description: '[:] Toggle command line',
|
|
12
|
-
action: () => patchState({ mode: Mode.COMMAND_LINE }),
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
intent: Intent.ToggleCommandLine,
|
|
16
|
-
mode: Mode.COMMAND_LINE,
|
|
17
|
-
description: '[ESC] Toggle command line',
|
|
18
|
-
action: () => patchState({ mode: Mode.DEFAULT }),
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
intent: Intent.Confirm,
|
|
22
|
-
mode: Mode.DEFAULT,
|
|
23
|
-
description: '[ENTER] Confirm/Enter context',
|
|
24
|
-
action: navigator.enterChildNode,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
intent: Intent.Exit,
|
|
28
|
-
mode: Mode.DEFAULT,
|
|
29
|
-
description: '[ESC/Q] Exit application',
|
|
30
|
-
action: navigator.enterParentNode,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
mode: Mode.DEFAULT,
|
|
34
|
-
description: '[ARROWS/HJKL] Navigate',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
intent: Intent.NavPreviousItem,
|
|
38
|
-
mode: Mode.DEFAULT,
|
|
39
|
-
action: navigator.navigateToPreviousItem,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
intent: Intent.NavNextItem,
|
|
43
|
-
mode: Mode.DEFAULT,
|
|
44
|
-
action: navigator.navigateToNextItem,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
intent: Intent.NavToPreviousContainer,
|
|
48
|
-
mode: Mode.DEFAULT,
|
|
49
|
-
action: navigator.navigateToPreviousContainer,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
intent: Intent.NavToNextContainer,
|
|
53
|
-
mode: Mode.DEFAULT,
|
|
54
|
-
action: navigator.navigateToNextContainer,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
intent: Intent.Edit,
|
|
58
|
-
mode: Mode.DEFAULT,
|
|
59
|
-
action: () => {
|
|
60
|
-
patchState({ mode: Mode.COMMAND_LINE });
|
|
61
|
-
updateCommandLineInput(() => `${CmdIntent.Rename} ${appState.currentNode?.name}`);
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NavigationTree } from '../../model/navigation-tree.model.js';
|
|
2
|
-
export interface Navigator {
|
|
3
|
-
navigate({ currentNode, selectedIndex, }: {
|
|
4
|
-
currentNode?: NavigationTree<NavigationTree>;
|
|
5
|
-
selectedIndex: number;
|
|
6
|
-
}): void;
|
|
7
|
-
confirm(selected: NavigationTree<NavigationTree>): void;
|
|
8
|
-
exit(): void;
|
|
9
|
-
enterChildNode(): void;
|
|
10
|
-
enterParentNode(): void;
|
|
11
|
-
navigateToNextItem: () => void;
|
|
12
|
-
navigateToPreviousItem: () => void;
|
|
13
|
-
navigateToNextContainer: () => void;
|
|
14
|
-
navigateToPreviousContainer: () => void;
|
|
15
|
-
}
|
|
16
|
-
export declare const navigator: Navigator;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { appState, patchState } from '../../state/state.js';
|
|
2
|
-
export const navigator = {
|
|
3
|
-
confirm(sel) {
|
|
4
|
-
console.log(sel);
|
|
5
|
-
},
|
|
6
|
-
exit() {
|
|
7
|
-
process.exit(0);
|
|
8
|
-
},
|
|
9
|
-
enterChildNode() {
|
|
10
|
-
const currentNode = appState.currentNode;
|
|
11
|
-
const focusNode = currentNode?.children[appState.selectedIndex];
|
|
12
|
-
if (!currentNode || !focusNode)
|
|
13
|
-
return;
|
|
14
|
-
navigator.navigate({
|
|
15
|
-
currentNode: focusNode,
|
|
16
|
-
selectedIndex: 0,
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
enterParentNode() {
|
|
20
|
-
const breadCrumb = appState.breadCrumb;
|
|
21
|
-
if (breadCrumb.length < 2)
|
|
22
|
-
return;
|
|
23
|
-
const prevNode = breadCrumb.at(-1);
|
|
24
|
-
if (!prevNode)
|
|
25
|
-
return;
|
|
26
|
-
const newCurrentNode = breadCrumb.at(-2);
|
|
27
|
-
const newIndex = newCurrentNode?.children?.findIndex(x => x.id === prevNode.id) ?? 0;
|
|
28
|
-
navigator.navigate({
|
|
29
|
-
currentNode: newCurrentNode,
|
|
30
|
-
selectedIndex: newIndex,
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
navigateToNextItem: () => navigateByOffset(1),
|
|
34
|
-
navigateToPreviousItem: () => navigateByOffset(-1),
|
|
35
|
-
navigateToNextContainer: () => navigateToSiblingContainer(1),
|
|
36
|
-
navigateToPreviousContainer: () => navigateToSiblingContainer(-1),
|
|
37
|
-
navigate: ({ currentNode, selectedIndex }) => {
|
|
38
|
-
if (!currentNode) {
|
|
39
|
-
currentNode = appState.currentNode;
|
|
40
|
-
}
|
|
41
|
-
const findBreadCrumb = (node, targetId, path = []) => {
|
|
42
|
-
const nextPath = [...path, node];
|
|
43
|
-
if (node.id === targetId)
|
|
44
|
-
return nextPath;
|
|
45
|
-
for (const child of node.children ?? []) {
|
|
46
|
-
const found = findBreadCrumb(child, targetId, nextPath);
|
|
47
|
-
if (found.length)
|
|
48
|
-
return found;
|
|
49
|
-
}
|
|
50
|
-
return [];
|
|
51
|
-
};
|
|
52
|
-
const setIsSelected = (node, targetId, selectedIndex) => {
|
|
53
|
-
// Clear selection for all children at this node
|
|
54
|
-
for (const child of node.children ?? []) {
|
|
55
|
-
child.isSelected = false;
|
|
56
|
-
setIsSelected(child, targetId, selectedIndex);
|
|
57
|
-
}
|
|
58
|
-
// If this is the target container, select its child at selectedIndex
|
|
59
|
-
if (node.id === targetId) {
|
|
60
|
-
const children = node.children;
|
|
61
|
-
const idx = Math.max(0, Math.min(selectedIndex, children.length - 1));
|
|
62
|
-
if (children[idx]) {
|
|
63
|
-
children[idx].isSelected = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const root = appState.rootNode;
|
|
68
|
-
const breadCrumb = findBreadCrumb(root, currentNode.id);
|
|
69
|
-
setIsSelected(root, currentNode.id, selectedIndex);
|
|
70
|
-
patchState({
|
|
71
|
-
breadCrumb,
|
|
72
|
-
currentNode,
|
|
73
|
-
selectedIndex,
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const navigateByOffset = (offset) => {
|
|
78
|
-
const len = appState.currentNode.children.length;
|
|
79
|
-
if (len === 0)
|
|
80
|
-
return;
|
|
81
|
-
const newIndex = (appState.selectedIndex + offset + len) % len;
|
|
82
|
-
navigator.navigate({ selectedIndex: newIndex });
|
|
83
|
-
};
|
|
84
|
-
const navigateToSiblingContainer = (direction) => {
|
|
85
|
-
if (!appState.currentNode.enableChildNavigationAcrossContainers)
|
|
86
|
-
return;
|
|
87
|
-
const currentNode = appState.breadCrumb.at(-1);
|
|
88
|
-
const parentNode = appState.breadCrumb.at(-2);
|
|
89
|
-
if (!currentNode || !parentNode)
|
|
90
|
-
return;
|
|
91
|
-
const siblings = parentNode.children ?? [];
|
|
92
|
-
const currentNodeIndex = siblings.findIndex(x => x.id === currentNode.id);
|
|
93
|
-
if (currentNodeIndex < 0)
|
|
94
|
-
return;
|
|
95
|
-
// Look for the next sibling "container" that actually has children
|
|
96
|
-
const candidates = direction === -1
|
|
97
|
-
? siblings.slice(0, currentNodeIndex).toReversed()
|
|
98
|
-
: siblings.slice(currentNodeIndex + 1);
|
|
99
|
-
const nextSibling = candidates.find(x => (x.children?.length ?? 0) > 0);
|
|
100
|
-
if (!nextSibling?.children?.length)
|
|
101
|
-
return;
|
|
102
|
-
// Keep the same child index if possible, otherwise clamp to last child
|
|
103
|
-
const prevIndex = appState.selectedIndex;
|
|
104
|
-
const boundedIndex = Math.min(prevIndex, nextSibling.children.length - 1);
|
|
105
|
-
navigator.navigate({
|
|
106
|
-
currentNode: nextSibling,
|
|
107
|
-
selectedIndex: boundedIndex,
|
|
108
|
-
});
|
|
109
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getCommandIntent } from '../../command-line/command-line-sequence-intent.js';
|
|
2
|
-
import { commands } from '../../command-line/commands.js';
|
|
3
|
-
import { clearCommandLine, getCommandLineInput, updateCommandHistory, } from '../../state/command-line.state.js';
|
|
4
|
-
export const onConfirmCommandLineSequenceInput = (...args) => {
|
|
5
|
-
const commandSequence = getCommandLineInput();
|
|
6
|
-
const [ctx] = [...args];
|
|
7
|
-
const [firstItem, ...rest] = commandSequence.split(' ');
|
|
8
|
-
const command = (firstItem || '').trim();
|
|
9
|
-
const value = rest.join(' ').trim();
|
|
10
|
-
if (!command)
|
|
11
|
-
return;
|
|
12
|
-
const intent = getCommandIntent(command);
|
|
13
|
-
const actionMeta = commands.find(x => x.intent === intent);
|
|
14
|
-
actionMeta?.action?.(ctx, actionMeta, { command, value });
|
|
15
|
-
updateCommandHistory();
|
|
16
|
-
clearCommandLine();
|
|
17
|
-
return;
|
|
18
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionEntry } from '../../model/action-map.model.js';
|
|
2
|
-
export declare const CommandLineIntent: {
|
|
3
|
-
readonly AddItem: "add-item";
|
|
4
|
-
readonly ViewHelp: "view-help";
|
|
5
|
-
};
|
|
6
|
-
export declare const getCommandLineIntent: (input: string) => "add-item" | "view-help" | undefined;
|
|
7
|
-
export declare const inputActions: ActionEntry[];
|
|
8
|
-
export declare const onConfirmCommandLineInput: (input: string) => void;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Mode } from '../../model/action-map.model.js';
|
|
2
|
-
import { patchState } from '../../state/state.js';
|
|
3
|
-
export const CommandLineIntent = {
|
|
4
|
-
AddItem: 'add-item',
|
|
5
|
-
ViewHelp: 'view-help',
|
|
6
|
-
};
|
|
7
|
-
export const getCommandLineIntent = (input) => {
|
|
8
|
-
switch (input) {
|
|
9
|
-
case 'help':
|
|
10
|
-
case 'h':
|
|
11
|
-
return CommandLineIntent.ViewHelp;
|
|
12
|
-
case 'add':
|
|
13
|
-
case 'a':
|
|
14
|
-
return CommandLineIntent.AddItem;
|
|
15
|
-
default:
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
export const inputActions = [
|
|
20
|
-
{
|
|
21
|
-
intent: CommandLineIntent.ViewHelp,
|
|
22
|
-
mode: Mode.DEFAULT, // Make accept array
|
|
23
|
-
action: () => {
|
|
24
|
-
patchState({
|
|
25
|
-
mode: Mode.HELP,
|
|
26
|
-
commandLineInput: '',
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
export const onConfirmCommandLineInput = (input) => {
|
|
32
|
-
switch (input.trim()) {
|
|
33
|
-
case 'help':
|
|
34
|
-
case 'h':
|
|
35
|
-
patchState({
|
|
36
|
-
mode: Mode.HELP,
|
|
37
|
-
commandLineInput: '',
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
default:
|
|
41
|
-
patchState({
|
|
42
|
-
mode: Mode.DEFAULT,
|
|
43
|
-
commandLineInput: '',
|
|
44
|
-
});
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Mode } from '../../model/action-map.model.js';
|
|
2
|
-
import { getNextCommand, getPrevCommand, updateCommandLineInput, } from '../../state/command-line.state.js';
|
|
3
|
-
import { patchState } from '../../state/state.js';
|
|
4
|
-
import { Intent } from '../../utils/key-intent.js';
|
|
5
|
-
import { onConfirmCommandLineSequenceInput } from './command-line-input.js';
|
|
6
|
-
export const inputActions = [
|
|
7
|
-
{
|
|
8
|
-
intent: Intent.ViewHelp,
|
|
9
|
-
mode: Mode.DEFAULT,
|
|
10
|
-
action: () => patchState({ mode: Mode.HELP }),
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
intent: Intent.Exit,
|
|
14
|
-
mode: Mode.HELP,
|
|
15
|
-
action: () => patchState({ mode: Mode.DEFAULT }),
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
intent: Intent.Confirm,
|
|
19
|
-
mode: Mode.COMMAND_LINE,
|
|
20
|
-
action: (...args) => {
|
|
21
|
-
onConfirmCommandLineSequenceInput(...args);
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
intent: Intent.CaptureInput,
|
|
26
|
-
mode: Mode.COMMAND_LINE,
|
|
27
|
-
action: (_1, _2, { sequence }) => updateCommandLineInput(s => s + sequence),
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
intent: Intent.EraseInput,
|
|
31
|
-
mode: Mode.COMMAND_LINE,
|
|
32
|
-
action: () => updateCommandLineInput(s => s.slice(0, -1)),
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
intent: Intent.GetLastCommandFromHistory,
|
|
36
|
-
mode: Mode.COMMAND_LINE,
|
|
37
|
-
action: () => getPrevCommand(),
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
intent: Intent.GetNextCommandFromHistory,
|
|
41
|
-
mode: Mode.COMMAND_LINE,
|
|
42
|
-
action: () => getNextCommand(),
|
|
43
|
-
},
|
|
44
|
-
];
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Mode } from '../../model/action-map.model.js';
|
|
2
|
-
import { setState } from '../../state/state.js';
|
|
3
|
-
import { KeyIntent } from '../../utils/key-intent.js';
|
|
4
|
-
import { moveChildNextWithinParent, moveChildPreviousWithinParent, moveChildToNextParent, moveChildToPreviousParent, } from './move-actions-utils.js';
|
|
5
|
-
export const toggleMoveMode = [
|
|
6
|
-
{
|
|
7
|
-
intent: KeyIntent.ToggleMove,
|
|
8
|
-
mode: Mode.DEFAULT,
|
|
9
|
-
description: '[Y] Toggle move/yank mode',
|
|
10
|
-
action: () => {
|
|
11
|
-
setState(state => ({
|
|
12
|
-
...state,
|
|
13
|
-
mode: Mode.MOVE,
|
|
14
|
-
}));
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
intent: KeyIntent.ToggleMove,
|
|
19
|
-
mode: Mode.MOVE,
|
|
20
|
-
action: () => {
|
|
21
|
-
setState(state => ({
|
|
22
|
-
...state,
|
|
23
|
-
mode: Mode.DEFAULT,
|
|
24
|
-
}));
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
export const moveWithinParent = [
|
|
29
|
-
{
|
|
30
|
-
mode: Mode.MOVE,
|
|
31
|
-
description: '[Y, ARROW KEYS] Move item',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
intent: KeyIntent.MovePreviousItem,
|
|
35
|
-
mode: Mode.MOVE,
|
|
36
|
-
action: moveChildPreviousWithinParent,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
intent: KeyIntent.MoveNextItem,
|
|
40
|
-
mode: Mode.MOVE,
|
|
41
|
-
action: moveChildNextWithinParent,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
export const moveAcrossParents = [
|
|
45
|
-
{
|
|
46
|
-
intent: KeyIntent.MoveToNextContainer,
|
|
47
|
-
mode: Mode.MOVE,
|
|
48
|
-
action: moveChildToNextParent,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
intent: KeyIntent.MoveToPreviousContainer,
|
|
52
|
-
mode: Mode.MOVE,
|
|
53
|
-
action: moveChildToPreviousParent,
|
|
54
|
-
},
|
|
55
|
-
];
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { appState } from '../../state/state.js';
|
|
2
|
-
import { navigator } from '../default/navigation-action-utils.js';
|
|
3
|
-
function moveItemInArray({ array, from, to, }) {
|
|
4
|
-
if (from < 0 || from >= array.length || to < 0 || to >= array.length)
|
|
5
|
-
return;
|
|
6
|
-
const [item] = array.splice(from, 1);
|
|
7
|
-
if (item)
|
|
8
|
-
array.splice(to, 0, item);
|
|
9
|
-
}
|
|
10
|
-
function moveNodeToSiblingContainer(direction) {
|
|
11
|
-
const currentNode = appState.breadCrumb.at(-1);
|
|
12
|
-
const parentNode = appState.breadCrumb.at(-2);
|
|
13
|
-
if (!currentNode || !parentNode)
|
|
14
|
-
return;
|
|
15
|
-
if (!Array.isArray(parentNode.children))
|
|
16
|
-
return;
|
|
17
|
-
const currentNodeIndex = parentNode.children.findIndex(x => x.id === currentNode.id);
|
|
18
|
-
const targetNodeIndex = currentNodeIndex + direction;
|
|
19
|
-
if (currentNodeIndex < 0 ||
|
|
20
|
-
targetNodeIndex < 0 ||
|
|
21
|
-
targetNodeIndex >= parentNode.children.length)
|
|
22
|
-
return;
|
|
23
|
-
const siblingNode = parentNode.children[targetNodeIndex];
|
|
24
|
-
if (!siblingNode)
|
|
25
|
-
return;
|
|
26
|
-
if (!Array.isArray(currentNode.children))
|
|
27
|
-
return;
|
|
28
|
-
if (!Array.isArray(siblingNode.children))
|
|
29
|
-
siblingNode.children = []; // normalize empty container
|
|
30
|
-
const currentSelectionIndex = appState.selectedIndex;
|
|
31
|
-
if (currentSelectionIndex < 0 ||
|
|
32
|
-
currentSelectionIndex >= currentNode.children.length)
|
|
33
|
-
return;
|
|
34
|
-
const [moveNode] = currentNode.children.splice(currentSelectionIndex, 1);
|
|
35
|
-
if (!moveNode)
|
|
36
|
-
return;
|
|
37
|
-
siblingNode.children.push(moveNode);
|
|
38
|
-
navigator.navigate({
|
|
39
|
-
selectedIndex: siblingNode.children.length - 1,
|
|
40
|
-
currentNode: siblingNode,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
export const moveChildToNextParent = () => {
|
|
44
|
-
moveNodeToSiblingContainer(1);
|
|
45
|
-
};
|
|
46
|
-
export const moveChildToPreviousParent = () => {
|
|
47
|
-
moveNodeToSiblingContainer(-1);
|
|
48
|
-
};
|
|
49
|
-
function moveChildWithinParent(direction) {
|
|
50
|
-
const from = appState.selectedIndex;
|
|
51
|
-
const to = from + direction;
|
|
52
|
-
if (to < 0 || to >= appState.currentNode.children.length)
|
|
53
|
-
return;
|
|
54
|
-
moveItemInArray({
|
|
55
|
-
array: appState.currentNode.children,
|
|
56
|
-
from,
|
|
57
|
-
to,
|
|
58
|
-
});
|
|
59
|
-
navigator.navigate({ selectedIndex: to });
|
|
60
|
-
}
|
|
61
|
-
export const moveChildPreviousWithinParent = () => {
|
|
62
|
-
moveChildWithinParent(-1);
|
|
63
|
-
};
|
|
64
|
-
export const moveChildNextWithinParent = () => {
|
|
65
|
-
moveChildWithinParent(1);
|
|
66
|
-
};
|