epiq 0.0.2 → 0.0.4

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 (148) hide show
  1. package/dist/app.js +10 -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 +26 -0
  5. package/dist/{components/Help.d.ts → board/components/ContextBar.d.ts} +1 -1
  6. package/dist/board/components/ContextBar.js +17 -0
  7. package/dist/board/components/Help.js +19 -12
  8. package/dist/board/components/Swimlane.d.ts +1 -0
  9. package/dist/board/components/Swimlane.js +6 -4
  10. package/dist/board/components/Swimlanes.js +8 -11
  11. package/dist/board/components/TextInput.d.ts +6 -0
  12. package/dist/board/components/TextInput.js +9 -0
  13. package/dist/board/components/TicketListItem.js +6 -5
  14. package/dist/board/components/TicketUI.js +6 -7
  15. package/dist/board/hints/hints.d.ts +7 -0
  16. package/dist/board/hints/hints.js +21 -0
  17. package/dist/board/mock/board.js +73 -27
  18. package/dist/cli.d.ts +2 -1
  19. package/dist/cli.js +21 -39
  20. package/dist/debug-logger.d.ts +2 -0
  21. package/dist/debug-logger.js +16 -0
  22. package/dist/init-project.d.ts +1 -0
  23. package/dist/init-project.js +1 -0
  24. package/dist/navigation/actions/add/add-actions.d.ts +2 -0
  25. package/dist/navigation/actions/add/add-actions.js +25 -0
  26. package/dist/navigation/actions/add/add-item-actions.d.ts +2 -0
  27. package/dist/navigation/actions/add/add-item-actions.js +25 -0
  28. package/dist/navigation/actions/add-item/add-item-actions.d.ts +3 -0
  29. package/dist/navigation/actions/add-item/add-item-actions.js +45 -0
  30. package/dist/navigation/actions/board-action-map.d.ts +10 -0
  31. package/dist/navigation/actions/board-action-map.js +12 -0
  32. package/dist/navigation/actions/default/default-action-utils.d.ts +8 -0
  33. package/dist/navigation/actions/default/default-action-utils.js +101 -0
  34. package/dist/navigation/actions/default/default-actions.d.ts +2 -0
  35. package/dist/navigation/actions/default/default-actions.js +64 -0
  36. package/dist/navigation/actions/default/navigation-action-utils.d.ts +16 -0
  37. package/dist/navigation/actions/default/navigation-action-utils.js +109 -0
  38. package/dist/navigation/actions/input/command-line-input.d.ts +2 -0
  39. package/dist/navigation/actions/input/command-line-input.js +18 -0
  40. package/dist/navigation/actions/input/input-actions-utils.d.ts +8 -0
  41. package/dist/navigation/actions/input/input-actions-utils.js +47 -0
  42. package/dist/navigation/actions/input/input-actions.d.ts +2 -0
  43. package/dist/navigation/actions/input/input-actions.js +44 -0
  44. package/dist/navigation/actions/move/move-actions-routes.d.ts +4 -0
  45. package/dist/navigation/actions/move/move-actions-routes.js +55 -0
  46. package/dist/navigation/actions/move/move-actions-utils.d.ts +4 -0
  47. package/dist/navigation/actions/move/move-actions-utils.js +66 -0
  48. package/dist/navigation/actions/move/move-actions.d.ts +4 -0
  49. package/dist/navigation/actions/move/move-actions.js +59 -0
  50. package/dist/{lib/utils/default-action-utils.d.ts → navigation/actions/navigate/navigation-action-utils.d.ts} +1 -1
  51. package/dist/navigation/actions/navigate/navigation-actions.d.ts +2 -0
  52. package/dist/navigation/actions/navigate/navigation-actions.js +78 -0
  53. package/dist/navigation/command-line/command-line-actions.d.ts +2 -0
  54. package/dist/navigation/command-line/command-line-actions.js +32 -0
  55. package/dist/navigation/command-line/command-line-intent.d.ts +7 -0
  56. package/dist/navigation/command-line/command-line-intent.js +29 -0
  57. package/dist/navigation/command-line/command-line-sequence-actions.d.ts +2 -0
  58. package/dist/navigation/command-line/command-line-sequence-actions.js +44 -0
  59. package/dist/navigation/command-line/command-line-sequence-intent.d.ts +8 -0
  60. package/dist/navigation/command-line/command-line-sequence-intent.js +32 -0
  61. package/dist/navigation/command-line/commands.d.ts +2 -0
  62. package/dist/navigation/command-line/commands.js +58 -0
  63. package/dist/navigation/keypress-listener.d.ts +1 -0
  64. package/dist/navigation/keypress-listener.js +33 -0
  65. package/dist/navigation/model/action-map.model.d.ts +17 -5
  66. package/dist/navigation/model/action-map.model.js +2 -0
  67. package/dist/navigation/model/navigation-ctx.model.d.ts +1 -16
  68. package/dist/navigation/model/navigation-ctx.model.js +0 -1
  69. package/dist/navigation/model/navigation-tree.model.d.ts +3 -1
  70. package/dist/navigation/navigation.d.ts +3 -10
  71. package/dist/navigation/navigation.js +74 -66
  72. package/dist/navigation/state/command-line.state.d.ts +18 -0
  73. package/dist/navigation/state/command-line.state.js +60 -0
  74. package/dist/navigation/state/state.d.ts +18 -9
  75. package/dist/navigation/state/state.js +36 -8
  76. package/dist/navigation/utils/get-command-line-intent.d.ts +3 -0
  77. package/dist/navigation/utils/get-command-line-intent.js +17 -0
  78. package/dist/navigation/utils/getKeyIntent.d.ts +5 -0
  79. package/dist/navigation/utils/getKeyIntent.js +71 -0
  80. package/dist/navigation/utils/key-intent.d.ts +21 -12
  81. package/dist/navigation/utils/key-intent.js +104 -50
  82. package/package.json +3 -3
  83. package/dist/board/actions/board-action-map.d.ts +0 -11
  84. package/dist/board/actions/board-action-map.js +0 -11
  85. package/dist/board/actions/move-actions-routes.d.ts +0 -4
  86. package/dist/board/actions/move-actions-routes.js +0 -31
  87. package/dist/board/actions/move-actions.d.ts +0 -5
  88. package/dist/board/actions/move-actions.js +0 -49
  89. package/dist/board/board-action-map.d.ts +0 -9
  90. package/dist/board/board-action-map.js +0 -7
  91. package/dist/board/move-actions-routes.d.ts +0 -4
  92. package/dist/board/move-actions-routes.js +0 -31
  93. package/dist/board/move-actions.d.ts +0 -5
  94. package/dist/board/move-actions.js +0 -49
  95. package/dist/components/Board.d.ts +0 -6
  96. package/dist/components/Board.js +0 -15
  97. package/dist/components/Help.js +0 -21
  98. package/dist/components/Swimlane.d.ts +0 -8
  99. package/dist/components/Swimlane.js +0 -10
  100. package/dist/components/TicketListItem.d.ts +0 -6
  101. package/dist/components/TicketListItem.js +0 -12
  102. package/dist/lib/actions/board-action-map.d.ts +0 -9
  103. package/dist/lib/actions/board-action-map.js +0 -7
  104. package/dist/lib/actions/move-actions-utils.d.ts +0 -5
  105. package/dist/lib/actions/move-actions-utils.js +0 -43
  106. package/dist/lib/actions/move-actions.d.ts +0 -4
  107. package/dist/lib/actions/move-actions.js +0 -31
  108. package/dist/lib/board/board-action-map.d.ts +0 -9
  109. package/dist/lib/board/board-action-map.js +0 -7
  110. package/dist/lib/board/move-actions-routes.d.ts +0 -4
  111. package/dist/lib/board/move-actions-routes.js +0 -31
  112. package/dist/lib/board/move-actions.d.ts +0 -5
  113. package/dist/lib/board/move-actions.js +0 -43
  114. package/dist/lib/board-utils.d.ts +0 -7
  115. package/dist/lib/board-utils.js +0 -33
  116. package/dist/lib/default-actions-routes.d.ts +0 -4
  117. package/dist/lib/default-actions-routes.js +0 -47
  118. package/dist/lib/default-actions.d.ts +0 -4
  119. package/dist/lib/default-actions.js +0 -47
  120. package/dist/lib/navigation-context.d.ts +0 -16
  121. package/dist/lib/navigation.d.ts +0 -10
  122. package/dist/lib/navigation.js +0 -74
  123. package/dist/lib/render-utils.d.ts +0 -10
  124. package/dist/lib/render-utils.js +0 -12
  125. package/dist/lib/state.d.ts +0 -8
  126. package/dist/lib/state.js +0 -8
  127. package/dist/lib/types/action-map.model.d.ts +0 -14
  128. package/dist/lib/types/action-map.model.js +0 -4
  129. package/dist/lib/types/board.model.d.ts +0 -21
  130. package/dist/lib/types/board.model.js +0 -5
  131. package/dist/lib/types/navigation.model.d.ts +0 -9
  132. package/dist/lib/utils/array-utils.d.ts +0 -5
  133. package/dist/lib/utils/array-utils.js +0 -7
  134. package/dist/lib/utils/default-action-utils.js +0 -50
  135. package/dist/lib/utils/default-actions.d.ts +0 -7
  136. package/dist/lib/utils/default-actions.js +0 -50
  137. package/dist/lib/utils/key-intent.d.ts +0 -16
  138. package/dist/lib/utils/key-intent.js +0 -65
  139. package/dist/lib/utils.d.ts +0 -10
  140. package/dist/lib/utils.js +0 -12
  141. package/dist/mock/board.d.ts +0 -2
  142. package/dist/mock/board.js +0 -139
  143. package/dist/navigation/actions/default-actions-routes.d.ts +0 -4
  144. package/dist/navigation/actions/default-actions-routes.js +0 -47
  145. package/dist/navigation/actions/default-actions.d.ts +0 -7
  146. /package/dist/navigation/actions/{default-actions.js → navigate/navigation-action-utils.js} +0 -0
  147. /package/dist/{lib/navigation-context.js → navigation/navigation-ctx.d.ts} +0 -0
  148. /package/dist/{lib/types/navigation.model.js → navigation/navigation-ctx.js} +0 -0
@@ -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,7 +0,0 @@
1
- import { NavigateCtx } from '../navigation-context.js';
2
- export declare const navigateToNextItem: (ctx: NavigateCtx) => void;
3
- export declare const navigateToPreviousItem: (ctx: NavigateCtx) => void;
4
- export declare const navigateToNextContainer: (ctx: NavigateCtx) => void;
5
- export declare const navigateToPreviousContainer: (ctx: NavigateCtx) => void;
6
- export declare const enterChildNode: (ctx: NavigateCtx) => void;
7
- export declare const exitToParentNode: (ctx: NavigateCtx) => void;
@@ -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
- };
package/dist/lib/utils.js DELETED
@@ -1,12 +0,0 @@
1
- export const clearScreen = () => {
2
- process.stdout.write('\x1B[2J\x1B[0f');
3
- };
4
- export const keys = {
5
- CTRL_C: '\u0003',
6
- ENTER: '\r',
7
- ARROW_UP: '\u001b[A',
8
- ARROW_DOWN: '\u001b[B',
9
- ARROW_LEFT: '\u001b[D',
10
- ARROW_RIGHT: '\u001b[C',
11
- ESCAPE: '\u001b',
12
- };
@@ -1,2 +0,0 @@
1
- import { type Board } from '../lib/types/board.model.js';
2
- export declare const board: Board;