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
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export declare const main: () => void;
2
+ import './debug-logger.js';
3
+ export declare let triggerRender: () => void;
package/dist/cli.js CHANGED
@@ -3,11 +3,14 @@ import { render } from 'ink';
3
3
  import meow from 'meow';
4
4
  import React from 'react';
5
5
  import App from './app.js';
6
- import { BoardActions } from './board/actions/board-action-map.js';
6
+ import { Hints } from './board/hints/hints.js';
7
7
  import { board } from './board/mock/board.js';
8
- import { buildDefaultActions } from './navigation/actions/default-actions-routes.js';
8
+ import { ContextualActionMap } from './navigation/actions/board-action-map.js';
9
+ import { inputActions } from './navigation/actions/input/input-actions.js';
10
+ import { DefaultActions } from './navigation/actions/default/default-actions.js';
9
11
  import { navigate } from './navigation/navigation.js';
10
- import { setState } from './navigation/state/state.js';
12
+ import { patchState, updateState } from './navigation/state/state.js';
13
+ import './debug-logger.js';
11
14
  const cli = meow(`
12
15
  Usage
13
16
  $ epiq
@@ -27,31 +30,51 @@ const cli = meow(`
27
30
  },
28
31
  });
29
32
  cli;
30
- export const main = () => {
33
+ (() => {
31
34
  console.clear();
35
+ const onBeforeRender = () => {
36
+ updateState(state => {
37
+ const { currentNode, mode } = state;
38
+ const hints = (currentNode && Hints[currentNode.actionContext + mode]) ??
39
+ (currentNode && Hints[currentNode.actionContext]) ?? [''];
40
+ return {
41
+ ...state,
42
+ availableHints: hints,
43
+ };
44
+ });
45
+ };
32
46
  navigate({
33
47
  index: 0,
34
48
  breadCrumb: [board],
35
49
  callbacks: {
36
50
  render: () => {
51
+ onBeforeRender();
37
52
  render(React.createElement(App, { board: board }));
38
53
  },
39
54
  onSelectChange: (selected, breadCrumb) => {
40
- if (!selected)
41
- return;
42
- const type = selected
43
- .actionContext; // Fix so that we can infer this type
44
- setState(state => ({
45
- ...state,
46
- currentNode: selected,
55
+ // container is the "list" we are navigating in (board → swimlanes, swimlane → tickets, etc)
56
+ const container = breadCrumb.at(-1);
57
+ // still remember which *child* is selected for rendering
58
+ const currentNode = selected ?? container;
59
+ // but build actions from the container type, not the selected child
60
+ const containerType = container
61
+ .actionContext;
62
+ patchState({
63
+ currentNode,
47
64
  breadCrumb,
48
- availableActions: [...buildDefaultActions(), ...BoardActions[type]],
49
- }));
65
+ availableActions: [
66
+ ...DefaultActions,
67
+ ...ContextualActionMap[containerType],
68
+ ...inputActions,
69
+ ],
70
+ });
50
71
  },
51
72
  },
52
73
  });
74
+ })();
75
+ export let triggerRender = () => {
76
+ render(React.createElement(App, { board: board }));
53
77
  };
54
- main();
55
78
  process.stdout.on('resize', () => {
56
79
  render(React.createElement(App, { board: board }));
57
80
  });
@@ -0,0 +1,2 @@
1
+ export declare function bug(...args: any[]): void;
2
+ export {};
@@ -0,0 +1,15 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import util from 'util';
4
+ const DEFAULT_PATH = path.resolve(process.cwd(), 'debug.log');
5
+ export function bug(...args) {
6
+ const timestamp = new Date().toISOString();
7
+ const message = util.format(...args);
8
+ const line = `[${timestamp}] ${message}\n`;
9
+ // Ensure parent directory exists
10
+ fs.mkdirSync(path.dirname(DEFAULT_PATH), { recursive: true });
11
+ // appendFileSync creates the file if it does not exist
12
+ fs.appendFileSync(DEFAULT_PATH, line, 'utf8');
13
+ }
14
+ // make it global
15
+ globalThis.bug = bug;
@@ -0,0 +1,2 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const AddItemActions: ActionEntry[];
@@ -0,0 +1,25 @@
1
+ import { board } from '../../../board/mock/board.js';
2
+ import { triggerRender } from '../../../cli.js';
3
+ import { Mode } from '../../model/action-map.model.js';
4
+ import { KeyIntent } from '../../utils/key-intent.js';
5
+ export const AddItemActions = [
6
+ {
7
+ intent: KeyIntent.AddItem,
8
+ mode: Mode.DEFAULT,
9
+ description: '[A] Add item',
10
+ action: () => {
11
+ const newItem = {
12
+ id: `item-${Date.now()}`,
13
+ name: 'New Item',
14
+ actionContext: 'SWIMLANE',
15
+ children: [],
16
+ isSelected: false,
17
+ childrenRenderAxis: 'vertical',
18
+ enableChildNavigationAcrossContainers: true,
19
+ description: '',
20
+ };
21
+ board.children.push(newItem);
22
+ triggerRender();
23
+ },
24
+ },
25
+ ];
@@ -0,0 +1,2 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const AddItemActions: ActionEntry[];
@@ -0,0 +1,25 @@
1
+ import { board } from '../../../board/mock/board.js';
2
+ import { triggerRender } from '../../../cli.js';
3
+ import { Mode } from '../../model/action-map.model.js';
4
+ import { KeyIntent } from '../../utils/key-intent.js';
5
+ export const AddItemActions = [
6
+ {
7
+ intent: KeyIntent.AddItem,
8
+ mode: Mode.DEFAULT,
9
+ description: '[A] Add item',
10
+ action: () => {
11
+ const newItem = {
12
+ id: `item-${Date.now()}`,
13
+ name: 'New Item',
14
+ actionContext: 'SWIMLANE',
15
+ children: [],
16
+ isSelected: false,
17
+ childrenRenderAxis: 'vertical',
18
+ enableChildNavigationAcrossContainers: true,
19
+ description: '',
20
+ };
21
+ board.children.push(newItem);
22
+ triggerRender();
23
+ },
24
+ },
25
+ ];
@@ -0,0 +1,3 @@
1
+ import { CommandLineActionEntry } from '../../model/action-map.model.js';
2
+ export declare const addSwimlaneAction: NonNullable<CommandLineActionEntry['action']>;
3
+ export declare const addTicketAction: NonNullable<CommandLineActionEntry['action']>;
@@ -0,0 +1,35 @@
1
+ import { BoardItemTypes, } from '../../../board/model/board.model.js';
2
+ export const addSwimlaneAction = async (ctx, _, { value }) => {
3
+ const newItem = {
4
+ id: `${Date.now()}`,
5
+ name: value || 'New lane',
6
+ description: '...',
7
+ actionContext: BoardItemTypes.SWIMLANE,
8
+ children: [],
9
+ isSelected: false,
10
+ childrenRenderAxis: 'vertical',
11
+ enableChildNavigationAcrossContainers: true,
12
+ };
13
+ const parent = ctx.navigationNode;
14
+ parent.children ?? (parent.children = []);
15
+ const newItemIndex = parent.children.length;
16
+ parent.children.push(newItem);
17
+ ctx.updateSelection(newItemIndex);
18
+ };
19
+ export const addTicketAction = async (ctx, _, { value }) => {
20
+ const newItem = {
21
+ id: `asdf${Date.now()}`,
22
+ name: value || 'New issue',
23
+ actionContext: BoardItemTypes.TICKET_LIST_ITEM,
24
+ children: [],
25
+ isSelected: false,
26
+ childrenRenderAxis: 'vertical',
27
+ enableChildNavigationAcrossContainers: true,
28
+ description: '',
29
+ };
30
+ const parent = ctx.navigationNode;
31
+ parent.children ?? (parent.children = []);
32
+ const newItemIndex = parent.children.length;
33
+ parent.children.push(newItem);
34
+ ctx.updateSelection(newItemIndex);
35
+ };
@@ -0,0 +1,10 @@
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 {};
@@ -0,0 +1,12 @@
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]: [],
5
+ [BoardItemTypes.SWIMLANE]: [...toggleMoveMode, ...moveWithinParent],
6
+ [BoardItemTypes.TICKET_LIST_ITEM]: [
7
+ ...toggleMoveMode,
8
+ ...moveWithinParent,
9
+ ...moveAcrossParents,
10
+ ],
11
+ [BoardItemTypes.TICKET]: [],
12
+ };
@@ -1,7 +1,7 @@
1
- import { NavigateCtx } from '../navigation-context.js';
1
+ import { NavigateCtx } from '../../model/navigation-ctx.model.js';
2
2
  export declare const navigateToNextItem: (ctx: NavigateCtx) => void;
3
3
  export declare const navigateToPreviousItem: (ctx: NavigateCtx) => void;
4
4
  export declare const navigateToNextContainer: (ctx: NavigateCtx) => void;
5
5
  export declare const navigateToPreviousContainer: (ctx: NavigateCtx) => void;
6
- export declare const enterChildNode: (ctx: NavigateCtx) => void;
6
+ export declare const enterChildNode: (ctx: NavigateCtx) => Promise<void>;
7
7
  export declare const exitToParentNode: (ctx: NavigateCtx) => void;
@@ -1,12 +1,12 @@
1
- // -- Basic item navigation --
2
1
  const navigateByOffset = (ctx, offset) => {
3
2
  const len = ctx.children.length;
3
+ if (len === 0)
4
+ return;
4
5
  const newIndex = (ctx.getSelectedIndex() + offset + len) % len;
5
- ctx.select(newIndex);
6
+ ctx.updateSelection(newIndex);
6
7
  };
7
8
  export const navigateToNextItem = (ctx) => navigateByOffset(ctx, 1);
8
9
  export const navigateToPreviousItem = (ctx) => navigateByOffset(ctx, -1);
9
- // -- Cross-container navigation --
10
10
  const navigateToSiblingContainer = (ctx, direction) => {
11
11
  if (!ctx.navigationNode.enableChildNavigationAcrossContainers)
12
12
  return;
@@ -31,16 +31,17 @@ const navigateToSiblingContainer = (ctx, direction) => {
31
31
  };
32
32
  export const navigateToNextContainer = (ctx) => navigateToSiblingContainer(ctx, 1);
33
33
  export const navigateToPreviousContainer = (ctx) => navigateToSiblingContainer(ctx, -1);
34
- export const enterChildNode = (ctx) => {
35
- const current = ctx.navigationNode.children[ctx._selectedIndex];
36
- if (!current)
34
+ export const enterChildNode = async (ctx) => {
35
+ const currentNode = ctx.breadCrumb.at(-1);
36
+ const focusNode = currentNode?.children[ctx.getSelectedIndex()];
37
+ if (!currentNode || !focusNode)
38
+ return;
39
+ if (!focusNode?.children?.length) {
40
+ await ctx.enterChildNode(focusNode);
37
41
  return;
38
- if (!current.children?.length) {
39
- ctx.confirm(current);
40
42
  }
41
43
  else {
42
- ctx.select(-1);
43
- ctx.enterChildNode(current);
44
+ ctx.enterChildNode(focusNode);
44
45
  }
45
46
  };
46
47
  export const exitToParentNode = (ctx) => {
@@ -0,0 +1,2 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const DefaultActions: ActionEntry[];
@@ -0,0 +1,78 @@
1
+ import { Mode } from '../../model/action-map.model.js';
2
+ import { patchState } from '../../state/state.js';
3
+ import { KeyIntent } from '../../utils/key-intent.js';
4
+ import { enterChildNode, exitToParentNode, navigateToNextContainer, navigateToNextItem, navigateToPreviousContainer, navigateToPreviousItem, } from './default-action-utils.js';
5
+ export const DefaultActions = [
6
+ {
7
+ intent: KeyIntent.ToggleCommandLine,
8
+ mode: Mode.DEFAULT,
9
+ description: '[:] Toggle command line',
10
+ action: () => patchState({
11
+ mode: Mode.COMMAND_LINE,
12
+ }),
13
+ },
14
+ {
15
+ intent: KeyIntent.ToggleCommandLine,
16
+ mode: Mode.COMMAND_LINE,
17
+ description: '[ESC] Toggle command line',
18
+ action: () => patchState({
19
+ mode: Mode.DEFAULT,
20
+ }),
21
+ },
22
+ // {
23
+ // intent: KeyIntent.ToggleHelp,
24
+ // mode: Mode.DEFAULT,
25
+ // description: '[F1] Toggle HELP menu',
26
+ // action: () =>
27
+ // setState(state => ({
28
+ // ...state,
29
+ // mode: Mode.HELP,
30
+ // })),
31
+ // },
32
+ // {
33
+ // intent: KeyIntent.ToggleHelp,
34
+ // mode: Mode.HELP,
35
+ // description: '[F1] Close HELP menu',
36
+ // action: () =>
37
+ // setState(state => ({
38
+ // ...state,
39
+ // mode: Mode.DEFAULT,
40
+ // })),
41
+ // },
42
+ {
43
+ intent: KeyIntent.Confirm,
44
+ mode: Mode.DEFAULT,
45
+ description: '[ENTER/E] Confirm/Enter context',
46
+ action: enterChildNode,
47
+ },
48
+ {
49
+ intent: KeyIntent.Exit,
50
+ mode: Mode.DEFAULT,
51
+ description: '[ESC/Q] Exit application',
52
+ action: exitToParentNode,
53
+ },
54
+ {
55
+ mode: Mode.DEFAULT,
56
+ description: '[ARROWS/HJKL] Navigate',
57
+ },
58
+ {
59
+ intent: KeyIntent.NavPreviousItem,
60
+ mode: Mode.DEFAULT,
61
+ action: navigateToPreviousItem,
62
+ },
63
+ {
64
+ intent: KeyIntent.NavNextItem,
65
+ mode: Mode.DEFAULT,
66
+ action: navigateToNextItem,
67
+ },
68
+ {
69
+ intent: KeyIntent.NavToPreviousContainer,
70
+ mode: Mode.DEFAULT,
71
+ action: navigateToPreviousContainer,
72
+ },
73
+ {
74
+ intent: KeyIntent.NavToNextContainer,
75
+ mode: Mode.DEFAULT,
76
+ action: navigateToNextContainer,
77
+ },
78
+ ];
@@ -0,0 +1,2 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const onConfirmCommandLineSequenceInput: (...args: Parameters<NonNullable<ActionEntry["action"]>>) => void;
@@ -0,0 +1,18 @@
1
+ import { commandLineSequenceActions } from '../../command-line/command-line-sequence-actions.js';
2
+ import { getCommandLineIntent } from '../../command-line/command-line-sequence-intent.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 = getCommandLineIntent(command);
13
+ const actionMeta = commandLineSequenceActions.find(x => x.intent === intent);
14
+ actionMeta?.action?.(ctx, actionMeta, { command, value });
15
+ updateCommandHistory();
16
+ clearCommandLine();
17
+ return;
18
+ };
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,47 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const inputActions: ActionEntry[];
@@ -0,0 +1,43 @@
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 { KeyIntent } from '../../utils/key-intent.js';
5
+ import { onConfirmCommandLineSequenceInput } from './command-line-input.js';
6
+ export const inputActions = [
7
+ {
8
+ intent: KeyIntent.ToggleHelp,
9
+ mode: Mode.HELP,
10
+ action: () => {
11
+ patchState({
12
+ mode: Mode.DEFAULT,
13
+ });
14
+ },
15
+ },
16
+ {
17
+ intent: KeyIntent.Confirm,
18
+ mode: Mode.COMMAND_LINE,
19
+ action: (...args) => {
20
+ onConfirmCommandLineSequenceInput(...args);
21
+ },
22
+ },
23
+ {
24
+ intent: KeyIntent.CaptureInput,
25
+ mode: Mode.COMMAND_LINE,
26
+ action: (_1, _2, { sequence }) => updateCommandLineInput(s => s + sequence),
27
+ },
28
+ {
29
+ intent: KeyIntent.EraseInput,
30
+ mode: Mode.COMMAND_LINE,
31
+ action: () => updateCommandLineInput(s => s.slice(0, -1)),
32
+ },
33
+ {
34
+ intent: KeyIntent.GetLastCommandFromHistory,
35
+ mode: Mode.COMMAND_LINE,
36
+ action: () => getPrevCommand(),
37
+ },
38
+ {
39
+ intent: KeyIntent.GetNextCommandFromHistory,
40
+ mode: Mode.COMMAND_LINE,
41
+ action: () => getNextCommand(),
42
+ },
43
+ ];
@@ -0,0 +1,4 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const toggleMoveMode: ActionEntry[];
3
+ export declare const moveWithinParent: ActionEntry[];
4
+ export declare const moveAcrossParents: ActionEntry[];
@@ -0,0 +1,55 @@
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,4 +1,4 @@
1
- import { NavigateCtx } from '../navigation-context.js';
1
+ import { NavigateCtx } from '../../model/navigation-ctx.model.js';
2
2
  export declare const moveChildToNextParent: (ctx: NavigateCtx) => void;
3
3
  export declare const moveChildToPreviousParent: (ctx: NavigateCtx) => void;
4
4
  export declare const moveChildPreviousWithinParent: (ctx: NavigateCtx) => void;
@@ -6,11 +6,12 @@ function moveItemInArray({ array, from, to, }) {
6
6
  array.splice(to, 0, item);
7
7
  }
8
8
  function moveNodeToSiblingContainer(ctx, direction) {
9
- const ancestors = ctx.breadCrumb;
10
- const parent = ancestors.at(-1);
11
- const grandParent = ancestors.at(-2);
9
+ const parent = ctx.breadCrumb.at(-1);
10
+ const grandParent = ctx.breadCrumb.at(-2);
12
11
  if (!parent || !grandParent)
13
12
  return;
13
+ if (!Array.isArray(grandParent.children))
14
+ return;
14
15
  const parentIndex = grandParent.children.findIndex(x => x.id === parent.id);
15
16
  const targetIndex = parentIndex + direction;
16
17
  if (parentIndex < 0 ||
@@ -20,21 +21,24 @@ function moveNodeToSiblingContainer(ctx, direction) {
20
21
  const sibling = grandParent.children[targetIndex];
21
22
  if (!sibling)
22
23
  return;
23
- if (!sibling?.children?.length && !Array.isArray(sibling.children))
24
+ if (!Array.isArray(parent.children))
24
25
  return;
25
- const currentIndex = ctx._selectedIndex;
26
+ if (!Array.isArray(sibling.children))
27
+ sibling.children = []; // normalize empty container
28
+ const currentIndex = ctx.getSelectedIndex();
26
29
  if (currentIndex < 0 || currentIndex >= parent.children.length)
27
30
  return;
28
31
  const [node] = parent.children.splice(currentIndex, 1);
32
+ if (!node)
33
+ return;
29
34
  sibling.children.push(node);
30
35
  const newBreadCrumb = [...ctx.breadCrumb.slice(0, -1), sibling];
31
- const newIndex = sibling.children.length - 1;
32
- ctx.reInvokeNavigate(newIndex, newBreadCrumb);
36
+ ctx.reInvokeNavigate(sibling.children.length - 1, newBreadCrumb);
33
37
  }
34
38
  export const moveChildToNextParent = (ctx) => moveNodeToSiblingContainer(ctx, 1);
35
39
  export const moveChildToPreviousParent = (ctx) => moveNodeToSiblingContainer(ctx, -1);
36
40
  function moveChildWithinParent(ctx, direction) {
37
- const from = ctx._selectedIndex;
41
+ const from = ctx._selectionIndex;
38
42
  const to = from + direction;
39
43
  if (to < 0 || to >= ctx.navigationNode.children.length)
40
44
  return;
@@ -43,7 +47,7 @@ function moveChildWithinParent(ctx, direction) {
43
47
  from,
44
48
  to,
45
49
  });
46
- ctx.select(to);
50
+ ctx.updateSelection(to);
47
51
  }
48
52
  export const moveChildPreviousWithinParent = (ctx) => moveChildWithinParent(ctx, -1);
49
53
  export const moveChildNextWithinParent = (ctx) => moveChildWithinParent(ctx, 1);
@@ -0,0 +1,4 @@
1
+ import { ActionEntry } from '../../model/action-map.model.js';
2
+ export declare const toggleMoveMode: ActionEntry[];
3
+ export declare const moveWithinParent: ActionEntry[];
4
+ export declare const moveAcrossParents: ActionEntry[];