epiq 0.0.1 → 0.0.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.
Files changed (134) hide show
  1. package/dist/app.js +11 -4
  2. package/dist/board/components/Board.js +4 -12
  3. package/dist/board/components/CommandLine.d.ts +2 -0
  4. package/dist/board/components/CommandLine.js +19 -0
  5. package/dist/{components/Help.d.ts → board/components/ContextBar.d.ts} +1 -1
  6. package/dist/board/components/ContextBar.js +8 -0
  7. package/dist/board/components/Help.js +18 -11
  8. package/dist/board/components/Swimlane.js +6 -3
  9. package/dist/board/components/Swimlanes.js +1 -1
  10. package/dist/board/components/TextInput.d.ts +6 -0
  11. package/dist/board/components/TextInput.js +9 -0
  12. package/dist/board/components/TicketListItem.js +5 -4
  13. package/dist/board/components/TicketUI.js +6 -7
  14. package/dist/board/hints/hints.d.ts +7 -0
  15. package/dist/board/hints/hints.js +29 -0
  16. package/dist/board/mock/board.js +526 -457
  17. package/dist/cli.d.ts +2 -1
  18. package/dist/cli.js +37 -14
  19. package/dist/debug-logger.d.ts +2 -0
  20. package/dist/debug-logger.js +15 -0
  21. package/dist/navigation/actions/add/add-actions.d.ts +2 -0
  22. package/dist/navigation/actions/add/add-actions.js +25 -0
  23. package/dist/navigation/actions/add/add-item-actions.d.ts +2 -0
  24. package/dist/navigation/actions/add/add-item-actions.js +25 -0
  25. package/dist/navigation/actions/add-item/add-item-actions.d.ts +3 -0
  26. package/dist/navigation/actions/add-item/add-item-actions.js +35 -0
  27. package/dist/navigation/actions/board-action-map.d.ts +10 -0
  28. package/dist/navigation/actions/board-action-map.js +12 -0
  29. package/dist/{lib/utils/default-actions.d.ts → navigation/actions/default/default-action-utils.d.ts} +2 -2
  30. package/dist/{lib/utils → navigation/actions/default}/default-action-utils.js +11 -10
  31. package/dist/navigation/actions/default/default-actions.d.ts +2 -0
  32. package/dist/navigation/actions/default/default-actions.js +78 -0
  33. package/dist/navigation/actions/input/command-line-input.d.ts +2 -0
  34. package/dist/navigation/actions/input/command-line-input.js +18 -0
  35. package/dist/navigation/actions/input/input-actions-utils.d.ts +8 -0
  36. package/dist/navigation/actions/input/input-actions-utils.js +47 -0
  37. package/dist/navigation/actions/input/input-actions.d.ts +2 -0
  38. package/dist/navigation/actions/input/input-actions.js +43 -0
  39. package/dist/navigation/actions/move/move-actions-routes.d.ts +4 -0
  40. package/dist/navigation/actions/move/move-actions-routes.js +55 -0
  41. package/dist/{lib/actions → navigation/actions/move}/move-actions-utils.d.ts +1 -1
  42. package/dist/{board/actions/move-actions.js → navigation/actions/move/move-actions-utils.js} +13 -9
  43. package/dist/navigation/actions/move/move-actions.d.ts +4 -0
  44. package/dist/navigation/actions/move/move-actions.js +53 -0
  45. package/dist/{lib/utils/default-action-utils.d.ts → navigation/actions/navigate/navigation-action-utils.d.ts} +1 -1
  46. package/dist/navigation/actions/navigate/navigation-actions.d.ts +2 -0
  47. package/dist/navigation/actions/navigate/navigation-actions.js +78 -0
  48. package/dist/navigation/command-line/command-line-actions.d.ts +2 -0
  49. package/dist/navigation/command-line/command-line-actions.js +32 -0
  50. package/dist/navigation/command-line/command-line-intent.d.ts +7 -0
  51. package/dist/navigation/command-line/command-line-intent.js +29 -0
  52. package/dist/navigation/command-line/command-line-sequence-actions.d.ts +2 -0
  53. package/dist/navigation/command-line/command-line-sequence-actions.js +31 -0
  54. package/dist/navigation/command-line/command-line-sequence-intent.d.ts +7 -0
  55. package/dist/navigation/command-line/command-line-sequence-intent.js +29 -0
  56. package/dist/navigation/model/action-map.model.d.ts +17 -5
  57. package/dist/navigation/model/action-map.model.js +2 -0
  58. package/dist/navigation/model/navigation-ctx.model.d.ts +2 -2
  59. package/dist/navigation/model/navigation-tree.model.d.ts +1 -0
  60. package/dist/navigation/navigation.d.ts +1 -1
  61. package/dist/navigation/navigation.js +48 -34
  62. package/dist/navigation/state/command-line.state.d.ts +13 -0
  63. package/dist/navigation/state/command-line.state.js +43 -0
  64. package/dist/navigation/state/state.d.ts +7 -6
  65. package/dist/navigation/state/state.js +31 -2
  66. package/dist/navigation/utils/get-command-line-intent.d.ts +3 -0
  67. package/dist/navigation/utils/get-command-line-intent.js +17 -0
  68. package/dist/navigation/utils/getKeyIntent.d.ts +5 -0
  69. package/dist/navigation/utils/getKeyIntent.js +71 -0
  70. package/dist/navigation/utils/key-intent.d.ts +19 -10
  71. package/dist/navigation/utils/key-intent.js +103 -43
  72. package/package.json +2 -2
  73. package/dist/board/actions/board-action-map.d.ts +0 -11
  74. package/dist/board/actions/board-action-map.js +0 -11
  75. package/dist/board/actions/move-actions-routes.d.ts +0 -4
  76. package/dist/board/actions/move-actions-routes.js +0 -31
  77. package/dist/board/actions/move-actions.d.ts +0 -5
  78. package/dist/board/board-action-map.d.ts +0 -9
  79. package/dist/board/board-action-map.js +0 -7
  80. package/dist/board/move-actions-routes.d.ts +0 -4
  81. package/dist/board/move-actions-routes.js +0 -31
  82. package/dist/board/move-actions.d.ts +0 -5
  83. package/dist/board/move-actions.js +0 -49
  84. package/dist/components/Board.d.ts +0 -6
  85. package/dist/components/Board.js +0 -15
  86. package/dist/components/Help.js +0 -21
  87. package/dist/components/Swimlane.d.ts +0 -8
  88. package/dist/components/Swimlane.js +0 -10
  89. package/dist/components/TicketListItem.d.ts +0 -6
  90. package/dist/components/TicketListItem.js +0 -12
  91. package/dist/lib/actions/board-action-map.d.ts +0 -9
  92. package/dist/lib/actions/board-action-map.js +0 -7
  93. package/dist/lib/actions/move-actions-utils.js +0 -43
  94. package/dist/lib/actions/move-actions.d.ts +0 -4
  95. package/dist/lib/actions/move-actions.js +0 -31
  96. package/dist/lib/board/board-action-map.d.ts +0 -9
  97. package/dist/lib/board/board-action-map.js +0 -7
  98. package/dist/lib/board/move-actions-routes.d.ts +0 -4
  99. package/dist/lib/board/move-actions-routes.js +0 -31
  100. package/dist/lib/board/move-actions.d.ts +0 -5
  101. package/dist/lib/board/move-actions.js +0 -43
  102. package/dist/lib/board-utils.d.ts +0 -7
  103. package/dist/lib/board-utils.js +0 -33
  104. package/dist/lib/default-actions-routes.d.ts +0 -4
  105. package/dist/lib/default-actions-routes.js +0 -47
  106. package/dist/lib/default-actions.d.ts +0 -4
  107. package/dist/lib/default-actions.js +0 -47
  108. package/dist/lib/navigation-context.d.ts +0 -16
  109. package/dist/lib/navigation.d.ts +0 -10
  110. package/dist/lib/navigation.js +0 -74
  111. package/dist/lib/render-utils.d.ts +0 -10
  112. package/dist/lib/render-utils.js +0 -12
  113. package/dist/lib/state.d.ts +0 -8
  114. package/dist/lib/state.js +0 -8
  115. package/dist/lib/types/action-map.model.d.ts +0 -14
  116. package/dist/lib/types/action-map.model.js +0 -4
  117. package/dist/lib/types/board.model.d.ts +0 -21
  118. package/dist/lib/types/board.model.js +0 -5
  119. package/dist/lib/types/navigation.model.d.ts +0 -9
  120. package/dist/lib/utils/array-utils.d.ts +0 -5
  121. package/dist/lib/utils/array-utils.js +0 -7
  122. package/dist/lib/utils/default-actions.js +0 -50
  123. package/dist/lib/utils/key-intent.d.ts +0 -16
  124. package/dist/lib/utils/key-intent.js +0 -65
  125. package/dist/lib/utils.d.ts +0 -10
  126. package/dist/lib/utils.js +0 -12
  127. package/dist/mock/board.d.ts +0 -2
  128. package/dist/mock/board.js +0 -139
  129. package/dist/navigation/actions/default-actions-routes.d.ts +0 -4
  130. package/dist/navigation/actions/default-actions-routes.js +0 -47
  131. package/dist/navigation/actions/default-actions.d.ts +0 -7
  132. /package/dist/navigation/actions/{default-actions.js → navigate/navigation-action-utils.js} +0 -0
  133. /package/dist/{lib/navigation-context.js → navigation/navigation-ctx.d.ts} +0 -0
  134. /package/dist/{lib/types/navigation.model.js → navigation/navigation-ctx.js} +0 -0
@@ -1,31 +0,0 @@
1
- import { Mode } from '../types/action-map.model.js';
2
- import { KeyIntent } from '../utils/key-intent.js';
3
- import { moveChildNextWithinParent, moveChildPreviousWithinParent, moveChildToNextParent, moveChildToPreviousParent, } from './move-actions-utils.js';
4
- export const moveWithinParent = [
5
- {
6
- mode: Mode.DEFAULT,
7
- description: '[Shift + direction] Move item',
8
- },
9
- {
10
- intent: KeyIntent.MovePreviousItem,
11
- mode: Mode.DEFAULT,
12
- action: moveChildPreviousWithinParent,
13
- },
14
- {
15
- intent: KeyIntent.MoveNextItem,
16
- mode: Mode.DEFAULT,
17
- action: moveChildNextWithinParent,
18
- },
19
- ];
20
- export const moveAcrossParents = [
21
- {
22
- intent: KeyIntent.MoveToNextContainer,
23
- mode: Mode.DEFAULT,
24
- action: moveChildToNextParent,
25
- },
26
- {
27
- intent: KeyIntent.MoveToPreviousContainer,
28
- mode: Mode.DEFAULT,
29
- action: moveChildToPreviousParent,
30
- },
31
- ];
@@ -1,9 +0,0 @@
1
- import { NavigateCtx } from '../navigation-context.js';
2
- import { ActionMap } from '../types/action-map.model.js';
3
- type BoardActionMap = ActionMap<{
4
- BOARD: [NavigateCtx];
5
- SWIMLANE: [NavigateCtx];
6
- TICKET: [NavigateCtx];
7
- }>;
8
- export declare const BoardActions: BoardActionMap;
9
- export {};
@@ -1,7 +0,0 @@
1
- import { BoardItemTypes } from '../types/board.model.js';
2
- import { moveAcrossParents, moveWithinParent } from './move-actions-routes.js';
3
- export const BoardActions = {
4
- [BoardItemTypes.BOARD]: [],
5
- [BoardItemTypes.SWIMLANE]: [...moveWithinParent],
6
- [BoardItemTypes.TICKET]: [...moveWithinParent, ...moveAcrossParents],
7
- };
@@ -1,4 +0,0 @@
1
- import { NavigateCtx } from '../navigation-context.js';
2
- import { ActionEntry } from '../types/action-map.model.js';
3
- export declare const moveWithinParent: ActionEntry<[NavigateCtx]>[];
4
- export declare const moveAcrossParents: ActionEntry<[NavigateCtx]>[];
@@ -1,31 +0,0 @@
1
- import { Mode } from '../types/action-map.model.js';
2
- import { KeyIntent } from '../utils/key-intent.js';
3
- import { moveChildNextWithinParent, moveChildPreviousWithinParent, moveChildToNextParent, moveChildToPreviousParent, } from './move-actions.js';
4
- export const moveWithinParent = [
5
- {
6
- mode: Mode.DEFAULT,
7
- description: '[Shift + direction] Move item',
8
- },
9
- {
10
- intent: KeyIntent.MovePreviousItem,
11
- mode: Mode.DEFAULT,
12
- action: moveChildPreviousWithinParent,
13
- },
14
- {
15
- intent: KeyIntent.MoveNextItem,
16
- mode: Mode.DEFAULT,
17
- action: moveChildNextWithinParent,
18
- },
19
- ];
20
- export const moveAcrossParents = [
21
- {
22
- intent: KeyIntent.MoveToNextContainer,
23
- mode: Mode.DEFAULT,
24
- action: moveChildToNextParent,
25
- },
26
- {
27
- intent: KeyIntent.MoveToPreviousContainer,
28
- mode: Mode.DEFAULT,
29
- action: moveChildToPreviousParent,
30
- },
31
- ];
@@ -1,5 +0,0 @@
1
- import { NavigateCtx } from '../navigation-context.js';
2
- export declare const moveChildToNextParent: (ctx: NavigateCtx) => void;
3
- export declare const moveChildToPreviousParent: (ctx: NavigateCtx) => void;
4
- export declare const moveChildPreviousWithinParent: (ctx: NavigateCtx) => void;
5
- export declare const moveChildNextWithinParent: (ctx: NavigateCtx) => void;
@@ -1,43 +0,0 @@
1
- import { moveItemInArray } from '../utils/array-utils.js';
2
- function moveNodeToSiblingContainer(ctx, direction) {
3
- const ancestors = ctx.breadCrumb;
4
- const parent = ancestors.at(-1);
5
- const grandParent = ancestors.at(-2);
6
- if (!parent || !grandParent)
7
- return;
8
- const parentIndex = grandParent.children.findIndex(x => x.id === parent.id);
9
- const targetIndex = parentIndex + direction;
10
- if (parentIndex < 0 ||
11
- targetIndex < 0 ||
12
- targetIndex >= grandParent.children.length)
13
- return;
14
- const sibling = grandParent.children[targetIndex];
15
- if (!sibling)
16
- return;
17
- if (!sibling?.children?.length && !Array.isArray(sibling.children))
18
- return;
19
- const currentIndex = ctx._selectedIndex;
20
- if (currentIndex < 0 || currentIndex >= parent.children.length)
21
- return;
22
- const [node] = parent.children.splice(currentIndex, 1);
23
- sibling.children.push(node);
24
- const newBreadCrumb = [...ctx.breadCrumb.slice(0, -1), sibling];
25
- const newIndex = sibling.children.length - 1;
26
- ctx.reInvokeNavigate(newIndex, newBreadCrumb);
27
- }
28
- export const moveChildToNextParent = (ctx) => moveNodeToSiblingContainer(ctx, 1);
29
- export const moveChildToPreviousParent = (ctx) => moveNodeToSiblingContainer(ctx, -1);
30
- function moveChildWithinParent(ctx, direction) {
31
- const from = ctx._selectedIndex;
32
- const to = from + direction;
33
- if (to < 0 || to >= ctx.navigationNode.children.length)
34
- return;
35
- moveItemInArray({
36
- array: ctx.navigationNode.children,
37
- from,
38
- to,
39
- });
40
- ctx.select(to);
41
- }
42
- export const moveChildPreviousWithinParent = (ctx) => moveChildWithinParent(ctx, -1);
43
- export const moveChildNextWithinParent = (ctx) => moveChildWithinParent(ctx, 1);
@@ -1,7 +0,0 @@
1
- import { Swimlane, Ticket } from './types/board.model.js';
2
- import { NavigationTree } from './types/navigation.model.js';
3
- /**
4
- * Move a ticket to a new swimlane.
5
- */
6
- export declare function moveTicket(ticket: Ticket, destination: Swimlane): void;
7
- export declare function findNodeById(tree: NavigationTree, id: string): NavigationTree | null;
@@ -1,33 +0,0 @@
1
- import { board } from '../mock/board.js';
2
- /**
3
- * Move a ticket to a new swimlane.
4
- */
5
- export function moveTicket(ticket, destination) {
6
- let realTicket;
7
- // Step 1: Find and remove the real ticket from the current swimlane
8
- for (const swimlane of board.children) {
9
- const index = swimlane.children.findIndex(t => t.id === ticket.id);
10
- if (index !== -1) {
11
- realTicket = swimlane.children[index];
12
- swimlane.children.splice(index, 1);
13
- break;
14
- }
15
- }
16
- // Step 2: Add it to the destination swimlane
17
- if (realTicket && destination.actionContext === 'SWIMLANE') {
18
- destination.children.push(realTicket);
19
- }
20
- else {
21
- console.warn('Ticket not found or destination invalid. No move performed.');
22
- }
23
- }
24
- export function findNodeById(tree, id) {
25
- if (tree.id === id)
26
- return tree;
27
- for (const child of tree.children) {
28
- const found = findNodeById(child, id);
29
- if (found)
30
- return found;
31
- }
32
- return null;
33
- }
@@ -1,4 +0,0 @@
1
- import { NavigateCtx } from './navigation-context.js';
2
- import { ActionEntry } from './types/action-map.model.js';
3
- export type DefaultActionMap = ActionEntry<[NavigateCtx]>[];
4
- export declare const buildDefaultActions: () => DefaultActionMap;
@@ -1,47 +0,0 @@
1
- import { setState } from './state.js';
2
- import { Mode } from './types/action-map.model.js';
3
- import { enterChildNode, exitToParentNode, navigateToNextContainer, navigateToNextItem, navigateToPreviousContainer, navigateToPreviousItem, } from './utils/default-actions.js';
4
- import { KeyIntent } from './utils/key-intent.js';
5
- export const buildDefaultActions = () => [
6
- {
7
- mode: Mode.DEFAULT,
8
- description: '[ARROW KEYS] Navigate',
9
- },
10
- {
11
- intent: KeyIntent.ToggleHelp,
12
- mode: Mode.DEFAULT,
13
- action: () => setState(state => ({ ...state, viewHelp: !state.viewHelp })),
14
- },
15
- {
16
- intent: KeyIntent.Confirm,
17
- mode: Mode.DEFAULT,
18
- description: '[ENTER] Confirm',
19
- action: enterChildNode,
20
- },
21
- {
22
- intent: KeyIntent.Exit,
23
- mode: Mode.DEFAULT,
24
- description: '[E] Exit container',
25
- action: exitToParentNode,
26
- },
27
- {
28
- intent: KeyIntent.NavPreviousItem,
29
- mode: Mode.DEFAULT,
30
- action: navigateToPreviousItem,
31
- },
32
- {
33
- intent: KeyIntent.NavNextItem,
34
- mode: Mode.DEFAULT,
35
- action: navigateToNextItem,
36
- },
37
- {
38
- intent: KeyIntent.NavToPreviousContainer,
39
- mode: Mode.DEFAULT,
40
- action: navigateToPreviousContainer,
41
- },
42
- {
43
- intent: KeyIntent.NavToNextContainer,
44
- mode: Mode.DEFAULT,
45
- action: navigateToNextContainer,
46
- },
47
- ];
@@ -1,4 +0,0 @@
1
- import { NavigateCtx } from './navigation-context.js';
2
- import { ActionEntry } from './types/action-map.model.js';
3
- export type DefaultActionMap = ActionEntry<[NavigateCtx]>[];
4
- export declare const buildDefaultActions: () => DefaultActionMap;
@@ -1,47 +0,0 @@
1
- import { setState } from './state.js';
2
- import { Mode } from './types/action-map.model.js';
3
- import { enterChildNode, exitToParentNode, navigateToNextContainer, navigateToNextItem, navigateToPreviousContainer, navigateToPreviousItem, } from './utils/default-action-utils.js';
4
- import { KeyIntent } from './utils/key-intent.js';
5
- export const buildDefaultActions = () => [
6
- {
7
- mode: Mode.DEFAULT,
8
- description: '[ARROW KEYS] Navigate',
9
- },
10
- {
11
- intent: KeyIntent.ToggleHelp,
12
- mode: Mode.DEFAULT,
13
- action: () => setState(state => ({ ...state, viewHelp: !state.viewHelp })),
14
- },
15
- {
16
- intent: KeyIntent.Confirm,
17
- mode: Mode.DEFAULT,
18
- description: '[ENTER] Confirm',
19
- action: enterChildNode,
20
- },
21
- {
22
- intent: KeyIntent.Exit,
23
- mode: Mode.DEFAULT,
24
- description: '[E] Exit container',
25
- action: exitToParentNode,
26
- },
27
- {
28
- intent: KeyIntent.NavPreviousItem,
29
- mode: Mode.DEFAULT,
30
- action: navigateToPreviousItem,
31
- },
32
- {
33
- intent: KeyIntent.NavNextItem,
34
- mode: Mode.DEFAULT,
35
- action: navigateToNextItem,
36
- },
37
- {
38
- intent: KeyIntent.NavToPreviousContainer,
39
- mode: Mode.DEFAULT,
40
- action: navigateToPreviousContainer,
41
- },
42
- {
43
- intent: KeyIntent.NavToNextContainer,
44
- mode: Mode.DEFAULT,
45
- action: navigateToNextContainer,
46
- },
47
- ];
@@ -1,16 +0,0 @@
1
- import { NavigationTree } from './types/navigation.model.js';
2
- export interface NavigateCtx {
3
- _selectedIndex: number;
4
- breadCrumb: Array<NavigationTree<NavigationTree>>;
5
- navigationNode: NavigationTree<NavigationTree>;
6
- children: NavigationTree[];
7
- getSelectedIndex(): number;
8
- select(index: number): void;
9
- selectNone(): void;
10
- reInvokeNavigate(index: number, breadCrumb: NavigationTree<NavigationTree>[]): void;
11
- render(): void;
12
- confirm(selected: NavigationTree<NavigationTree>): void;
13
- exit(): void;
14
- enterChildNode(node: NavigationTree<NavigationTree>): void;
15
- enterParentNode(): void;
16
- }
@@ -1,10 +0,0 @@
1
- import { NavigationTree } from './types/navigation.model.js';
2
- export declare function navigate<T extends NavigationTree>({ index, breadCrumb, callbacks, }: {
3
- index: number;
4
- breadCrumb: Array<NavigationTree<NavigationTree>>;
5
- callbacks: Partial<{
6
- render: () => void;
7
- onSelectChange: (s: T['children'][number]) => void;
8
- onConfirm: (s: T['children'][number]) => void;
9
- }>;
10
- }): void;
@@ -1,74 +0,0 @@
1
- import readline from 'readline';
2
- import { navigationState } from './state.js';
3
- import { getKeyIntent } from './utils/key-intent.js';
4
- export function navigate({ index = 0, breadCrumb, callbacks, }) {
5
- const { render = () => { }, onSelectChange = () => { }, onConfirm = () => { }, } = callbacks;
6
- const ctx = {
7
- breadCrumb,
8
- get navigationNode() {
9
- return this.breadCrumb.at(-1);
10
- },
11
- get children() {
12
- return this.navigationNode.children ?? [];
13
- },
14
- selectNone: () => {
15
- ctx.select(-1);
16
- },
17
- _selectedIndex: 0,
18
- getSelectedIndex() {
19
- return this._selectedIndex;
20
- },
21
- select(i) {
22
- this._selectedIndex = i;
23
- updateSelection(ctx.navigationNode, i, onSelectChange);
24
- },
25
- render,
26
- reInvokeNavigate(index, breadCrumb) {
27
- return reInvokeNavigate(index, breadCrumb);
28
- },
29
- confirm: sel => onConfirm(sel),
30
- exit: () => {
31
- cleanup();
32
- process.exit(0);
33
- },
34
- enterChildNode: node => reInvokeNavigate(0, [...breadCrumb, node]),
35
- enterParentNode: () => {
36
- ctx.select(-1); // Clear all on this level
37
- if (breadCrumb.length < 2)
38
- return; // Need at least grandparent + parent
39
- const ancestors = breadCrumb;
40
- const parent = ancestors[ancestors.length - 1];
41
- const grandParent = ancestors[ancestors.length - 2];
42
- if (!parent || !grandParent)
43
- return;
44
- const parentIndex = grandParent?.children.findIndex(x => parent.id === x.id);
45
- reInvokeNavigate(parentIndex, breadCrumb.slice(0, -1)); // Go to parent level
46
- },
47
- };
48
- ctx.select(index);
49
- function onKeyPress(_, key) {
50
- if (key.ctrl && key.name === 'c')
51
- return ctx.exit();
52
- const filteredActions = navigationState.availableActions.filter(x => x.mode === navigationState.mode);
53
- const action = filteredActions?.find(actionMeta => {
54
- const intent = getKeyIntent(key, ctx);
55
- return intent === actionMeta.intent;
56
- });
57
- action?.action?.(ctx);
58
- ctx.render();
59
- }
60
- const cleanup = () => process.stdin.removeListener('keypress', onKeyPress);
61
- const reInvokeNavigate = (idx, crumb) => {
62
- cleanup();
63
- navigate({ index: idx, breadCrumb: [...crumb], callbacks });
64
- };
65
- render();
66
- readline.emitKeypressEvents(process.stdin);
67
- if (process.stdin.isTTY)
68
- process.stdin.setRawMode(true);
69
- process.stdin.on('keypress', onKeyPress);
70
- }
71
- function updateSelection({ children }, idx, onSelectChange) {
72
- children.forEach((c, i) => (c.isSelected = i === idx));
73
- onSelectChange(children[idx]);
74
- }
@@ -1,10 +0,0 @@
1
- declare const COLORS: {
2
- readonly green: "\u001B[32m";
3
- readonly gray: "\u001B[90m";
4
- readonly yellow: "\u001B[33m";
5
- readonly red: "\u001B[31m";
6
- readonly default: null;
7
- };
8
- export type HighlightColor = keyof typeof COLORS;
9
- export declare const highlight: (str: string, color?: HighlightColor) => string;
10
- export {};
@@ -1,12 +0,0 @@
1
- const COLORS = {
2
- green: "\x1b[32m",
3
- gray: "\x1b[90m",
4
- yellow: "\x1b[33m",
5
- red: "\x1b[31m",
6
- default: null, // no color
7
- };
8
- const RESET = "\x1b[0m";
9
- export const highlight = (str, color = "default") => {
10
- const prefix = COLORS[color];
11
- return prefix ? `${prefix}${str}${RESET}` : str;
12
- };
@@ -1,8 +0,0 @@
1
- import { NavigateCtx } from './navigation-context.js';
2
- import { ActionEntry, ModeOptions } from './types/action-map.model.js';
3
- export declare let navigationState: {
4
- mode: ModeOptions;
5
- availableActions: ActionEntry<[NavigateCtx]>[];
6
- viewHelp: boolean;
7
- };
8
- export declare const setState: (cb: (oldState: typeof navigationState) => typeof navigationState) => void;
package/dist/lib/state.js DELETED
@@ -1,8 +0,0 @@
1
- export let navigationState = {
2
- mode: 'default',
3
- availableActions: [],
4
- viewHelp: false,
5
- };
6
- export const setState = (cb) => {
7
- navigationState = cb(navigationState);
8
- };
@@ -1,14 +0,0 @@
1
- export declare const Mode: {
2
- readonly DEFAULT: "default";
3
- readonly MOVE: "move";
4
- };
5
- export type ModeOptions = (typeof Mode)[keyof typeof Mode];
6
- export type ActionEntry<TArgs extends any[] = []> = {
7
- intent?: string;
8
- mode: string;
9
- description?: `[${string}] ${string}`;
10
- action?: (...args: TArgs) => void;
11
- };
12
- export type ActionMap<T extends Record<string, any[]>> = {
13
- [K in keyof T]: ActionEntry<T[K]>[];
14
- };
@@ -1,4 +0,0 @@
1
- export const Mode = {
2
- DEFAULT: 'default',
3
- MOVE: 'move',
4
- };
@@ -1,21 +0,0 @@
1
- import type { NavigationTree } from './navigation.model.js';
2
- export declare const BoardItemTypes: {
3
- readonly TICKET: "TICKET";
4
- readonly SWIMLANE: "SWIMLANE";
5
- readonly BOARD: "BOARD";
6
- };
7
- export type Ticket = NavigationTree<{
8
- actionContext: (typeof BoardItemTypes)['TICKET'];
9
- description?: string;
10
- }>;
11
- export type Swimlane = NavigationTree<{
12
- actionContext: (typeof BoardItemTypes)['SWIMLANE'];
13
- enableChildNavigationAcrossContainers: true;
14
- }> & {
15
- children: Ticket[];
16
- };
17
- export type Board = NavigationTree<{
18
- actionContext: (typeof BoardItemTypes)['BOARD'];
19
- }> & {
20
- children: Swimlane[];
21
- };
@@ -1,5 +0,0 @@
1
- export const BoardItemTypes = {
2
- TICKET: 'TICKET',
3
- SWIMLANE: 'SWIMLANE',
4
- BOARD: 'BOARD',
5
- };
@@ -1,9 +0,0 @@
1
- export type NavigationTree<TMeta = Record<string, unknown>> = {
2
- id: string;
3
- isSelected: boolean;
4
- childrenRenderAxis: 'vertical' | 'horizontal';
5
- name: string;
6
- children: NavigationTree<unknown>[];
7
- actionContext: string;
8
- enableChildNavigationAcrossContainers?: boolean;
9
- } & TMeta;
@@ -1,5 +0,0 @@
1
- export declare function moveItemInArray<T>({ array, from, to, }: {
2
- array: T[];
3
- from: number;
4
- to: number;
5
- }): void;
@@ -1,7 +0,0 @@
1
- export function moveItemInArray({ array, from, to, }) {
2
- if (from < 0 || from >= array.length || to < 0 || to >= array.length)
3
- return;
4
- const [item] = array.splice(from, 1);
5
- if (item)
6
- array.splice(to, 0, item);
7
- }
@@ -1,50 +0,0 @@
1
- // -- Basic item navigation --
2
- const navigateByOffset = (ctx, offset) => {
3
- const len = ctx.children.length;
4
- const newIndex = (ctx.getSelectedIndex() + offset + len) % len;
5
- ctx.select(newIndex);
6
- };
7
- export const navigateToNextItem = (ctx) => navigateByOffset(ctx, 1);
8
- export const navigateToPreviousItem = (ctx) => navigateByOffset(ctx, -1);
9
- // -- Cross-container navigation --
10
- const navigateToSiblingContainer = (ctx, direction) => {
11
- if (!ctx.navigationNode.enableChildNavigationAcrossContainers)
12
- return;
13
- const parent = ctx.breadCrumb.at(-1);
14
- const grandParent = ctx.breadCrumb.at(-2);
15
- if (!parent || !grandParent)
16
- return;
17
- const parentIndex = grandParent.children.findIndex(x => x.id === parent.id);
18
- const sliced = direction === -1
19
- ? grandParent.children.toSpliced(parentIndex).toReversed()
20
- : grandParent.children.slice(parentIndex + 1);
21
- const nextSibling = sliced.find(x => x.children.length);
22
- if (!nextSibling?.children?.length)
23
- return;
24
- const prevIndex = ctx.getSelectedIndex();
25
- const boundedIndex = Math.min(prevIndex, nextSibling.children.length - 1);
26
- ctx.selectNone();
27
- ctx.reInvokeNavigate(boundedIndex, [
28
- ...ctx.breadCrumb.slice(0, -1),
29
- nextSibling,
30
- ]);
31
- };
32
- export const navigateToNextContainer = (ctx) => navigateToSiblingContainer(ctx, 1);
33
- export const navigateToPreviousContainer = (ctx) => navigateToSiblingContainer(ctx, -1);
34
- export const enterChildNode = (ctx) => {
35
- const current = ctx.navigationNode.children[ctx._selectedIndex];
36
- if (!current)
37
- return;
38
- if (!current.children?.length) {
39
- ctx.confirm(current);
40
- }
41
- else {
42
- ctx.select(-1);
43
- ctx.enterChildNode(current);
44
- }
45
- };
46
- export const exitToParentNode = (ctx) => {
47
- if (ctx.breadCrumb.length >= 2) {
48
- ctx.enterParentNode();
49
- }
50
- };
@@ -1,16 +0,0 @@
1
- import readline from 'readline';
2
- import { NavigateCtx } from '../navigation-context.js';
3
- export declare enum KeyIntent {
4
- NavPreviousItem = "nav-previous-item",
5
- NavNextItem = "nav-next-item",
6
- NavToPreviousContainer = "nav-to-previous-container",
7
- NavToNextContainer = "nav-to-next-container",
8
- MovePreviousItem = "move-previous-item",
9
- MoveNextItem = "move-next-item",
10
- MoveToPreviousContainer = "move-to-previous-container",
11
- MoveToNextContainer = "move-to-next-container",
12
- Confirm = "confirm",
13
- Exit = "exit",
14
- ToggleHelp = "toggle-help"
15
- }
16
- export declare function getKeyIntent(key: readline.Key, ctx: NavigateCtx): KeyIntent | null;
@@ -1,65 +0,0 @@
1
- export var KeyIntent;
2
- (function (KeyIntent) {
3
- KeyIntent["NavPreviousItem"] = "nav-previous-item";
4
- KeyIntent["NavNextItem"] = "nav-next-item";
5
- KeyIntent["NavToPreviousContainer"] = "nav-to-previous-container";
6
- KeyIntent["NavToNextContainer"] = "nav-to-next-container";
7
- KeyIntent["MovePreviousItem"] = "move-previous-item";
8
- KeyIntent["MoveNextItem"] = "move-next-item";
9
- KeyIntent["MoveToPreviousContainer"] = "move-to-previous-container";
10
- KeyIntent["MoveToNextContainer"] = "move-to-next-container";
11
- KeyIntent["Confirm"] = "confirm";
12
- KeyIntent["Exit"] = "exit";
13
- KeyIntent["ToggleHelp"] = "toggle-help";
14
- })(KeyIntent || (KeyIntent = {}));
15
- export function getKeyIntent(key, ctx) {
16
- const axis = ctx.navigationNode.childrenRenderAxis;
17
- if (key.shift) {
18
- switch (key.name) {
19
- case 'up':
20
- return axis === 'vertical' ? KeyIntent.MovePreviousItem : null;
21
- case 'down':
22
- return axis === 'vertical' ? KeyIntent.MoveNextItem : null;
23
- case 'left':
24
- return axis === 'horizontal'
25
- ? KeyIntent.MovePreviousItem
26
- : ctx.navigationNode.enableChildNavigationAcrossContainers
27
- ? KeyIntent.MoveToPreviousContainer
28
- : null;
29
- case 'right':
30
- return axis === 'horizontal'
31
- ? KeyIntent.MoveNextItem
32
- : ctx.navigationNode.enableChildNavigationAcrossContainers
33
- ? KeyIntent.MoveToNextContainer
34
- : null;
35
- default:
36
- return null;
37
- }
38
- }
39
- switch (key.name) {
40
- case 'h':
41
- return KeyIntent.ToggleHelp;
42
- case 'up':
43
- return axis === 'vertical' ? KeyIntent.NavPreviousItem : null;
44
- case 'down':
45
- return axis === 'vertical' ? KeyIntent.NavNextItem : null;
46
- case 'left':
47
- return axis === 'horizontal'
48
- ? KeyIntent.NavPreviousItem
49
- : ctx.navigationNode.enableChildNavigationAcrossContainers
50
- ? KeyIntent.NavToPreviousContainer
51
- : null;
52
- case 'right':
53
- return axis === 'horizontal'
54
- ? KeyIntent.NavNextItem
55
- : ctx.navigationNode.enableChildNavigationAcrossContainers
56
- ? KeyIntent.NavToNextContainer
57
- : null;
58
- case 'return':
59
- return KeyIntent.Confirm;
60
- case 'e':
61
- return KeyIntent.Exit;
62
- default:
63
- return null;
64
- }
65
- }
@@ -1,10 +0,0 @@
1
- export declare const clearScreen: () => void;
2
- export declare const keys: {
3
- readonly CTRL_C: "\u0003";
4
- readonly ENTER: "\r";
5
- readonly ARROW_UP: "\u001B[A";
6
- readonly ARROW_DOWN: "\u001B[B";
7
- readonly ARROW_LEFT: "\u001B[D";
8
- readonly ARROW_RIGHT: "\u001B[C";
9
- readonly ESCAPE: "\u001B";
10
- };