epiq 0.0.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.
Files changed (108) hide show
  1. package/dist/app.d.ts +5 -0
  2. package/dist/app.js +12 -0
  3. package/dist/board/actions/board-action-map.d.ts +11 -0
  4. package/dist/board/actions/board-action-map.js +11 -0
  5. package/dist/board/actions/move-actions-routes.d.ts +4 -0
  6. package/dist/board/actions/move-actions-routes.js +31 -0
  7. package/dist/board/actions/move-actions.d.ts +5 -0
  8. package/dist/board/actions/move-actions.js +49 -0
  9. package/dist/board/board-action-map.d.ts +9 -0
  10. package/dist/board/board-action-map.js +7 -0
  11. package/dist/board/components/Board.d.ts +6 -0
  12. package/dist/board/components/Board.js +19 -0
  13. package/dist/board/components/Help.d.ts +4 -0
  14. package/dist/board/components/Help.js +21 -0
  15. package/dist/board/components/Logo.d.ts +2 -0
  16. package/dist/board/components/Logo.js +21 -0
  17. package/dist/board/components/ScrollBox.d.ts +9 -0
  18. package/dist/board/components/ScrollBox.js +22 -0
  19. package/dist/board/components/Swimlane.d.ts +8 -0
  20. package/dist/board/components/Swimlane.js +10 -0
  21. package/dist/board/components/Swimlanes.d.ts +8 -0
  22. package/dist/board/components/Swimlanes.js +20 -0
  23. package/dist/board/components/TicketListItem.d.ts +6 -0
  24. package/dist/board/components/TicketListItem.js +12 -0
  25. package/dist/board/components/TicketUI.d.ts +8 -0
  26. package/dist/board/components/TicketUI.js +9 -0
  27. package/dist/board/mock/board.d.ts +2 -0
  28. package/dist/board/mock/board.js +474 -0
  29. package/dist/board/model/board.model.d.ts +26 -0
  30. package/dist/board/model/board.model.js +6 -0
  31. package/dist/board/move-actions-routes.d.ts +4 -0
  32. package/dist/board/move-actions-routes.js +31 -0
  33. package/dist/board/move-actions.d.ts +5 -0
  34. package/dist/board/move-actions.js +49 -0
  35. package/dist/board/render/color.d.ts +7 -0
  36. package/dist/board/render/color.js +21 -0
  37. package/dist/cli.d.ts +2 -0
  38. package/dist/cli.js +57 -0
  39. package/dist/components/Board.d.ts +6 -0
  40. package/dist/components/Board.js +15 -0
  41. package/dist/components/Help.d.ts +4 -0
  42. package/dist/components/Help.js +21 -0
  43. package/dist/components/Swimlane.d.ts +8 -0
  44. package/dist/components/Swimlane.js +10 -0
  45. package/dist/components/TicketListItem.d.ts +6 -0
  46. package/dist/components/TicketListItem.js +12 -0
  47. package/dist/lib/actions/board-action-map.d.ts +9 -0
  48. package/dist/lib/actions/board-action-map.js +7 -0
  49. package/dist/lib/actions/move-actions-utils.d.ts +5 -0
  50. package/dist/lib/actions/move-actions-utils.js +43 -0
  51. package/dist/lib/actions/move-actions.d.ts +4 -0
  52. package/dist/lib/actions/move-actions.js +31 -0
  53. package/dist/lib/board/board-action-map.d.ts +9 -0
  54. package/dist/lib/board/board-action-map.js +7 -0
  55. package/dist/lib/board/move-actions-routes.d.ts +4 -0
  56. package/dist/lib/board/move-actions-routes.js +31 -0
  57. package/dist/lib/board/move-actions.d.ts +5 -0
  58. package/dist/lib/board/move-actions.js +43 -0
  59. package/dist/lib/board-utils.d.ts +7 -0
  60. package/dist/lib/board-utils.js +33 -0
  61. package/dist/lib/default-actions-routes.d.ts +4 -0
  62. package/dist/lib/default-actions-routes.js +47 -0
  63. package/dist/lib/default-actions.d.ts +4 -0
  64. package/dist/lib/default-actions.js +47 -0
  65. package/dist/lib/navigation-context.d.ts +16 -0
  66. package/dist/lib/navigation-context.js +1 -0
  67. package/dist/lib/navigation.d.ts +10 -0
  68. package/dist/lib/navigation.js +74 -0
  69. package/dist/lib/render-utils.d.ts +10 -0
  70. package/dist/lib/render-utils.js +12 -0
  71. package/dist/lib/state.d.ts +8 -0
  72. package/dist/lib/state.js +8 -0
  73. package/dist/lib/types/action-map.model.d.ts +14 -0
  74. package/dist/lib/types/action-map.model.js +4 -0
  75. package/dist/lib/types/board.model.d.ts +21 -0
  76. package/dist/lib/types/board.model.js +5 -0
  77. package/dist/lib/types/navigation.model.d.ts +9 -0
  78. package/dist/lib/types/navigation.model.js +1 -0
  79. package/dist/lib/utils/array-utils.d.ts +5 -0
  80. package/dist/lib/utils/array-utils.js +7 -0
  81. package/dist/lib/utils/default-action-utils.d.ts +7 -0
  82. package/dist/lib/utils/default-action-utils.js +50 -0
  83. package/dist/lib/utils/default-actions.d.ts +7 -0
  84. package/dist/lib/utils/default-actions.js +50 -0
  85. package/dist/lib/utils/key-intent.d.ts +16 -0
  86. package/dist/lib/utils/key-intent.js +65 -0
  87. package/dist/lib/utils.d.ts +10 -0
  88. package/dist/lib/utils.js +12 -0
  89. package/dist/mock/board.d.ts +2 -0
  90. package/dist/mock/board.js +139 -0
  91. package/dist/navigation/actions/default-actions-routes.d.ts +4 -0
  92. package/dist/navigation/actions/default-actions-routes.js +47 -0
  93. package/dist/navigation/actions/default-actions.d.ts +7 -0
  94. package/dist/navigation/actions/default-actions.js +48 -0
  95. package/dist/navigation/model/action-map.model.d.ts +14 -0
  96. package/dist/navigation/model/action-map.model.js +4 -0
  97. package/dist/navigation/model/navigation-ctx.model.d.ts +16 -0
  98. package/dist/navigation/model/navigation-ctx.model.js +2 -0
  99. package/dist/navigation/model/navigation-tree.model.d.ts +9 -0
  100. package/dist/navigation/model/navigation-tree.model.js +1 -0
  101. package/dist/navigation/navigation.d.ts +10 -0
  102. package/dist/navigation/navigation.js +74 -0
  103. package/dist/navigation/state/state.d.ts +11 -0
  104. package/dist/navigation/state/state.js +10 -0
  105. package/dist/navigation/utils/key-intent.d.ts +16 -0
  106. package/dist/navigation/utils/key-intent.js +65 -0
  107. package/package.json +57 -0
  108. package/readme.md +37 -0
@@ -0,0 +1,74 @@
1
+ import readline from 'readline';
2
+ import { navigationState } from './state/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, breadCrumb, 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 }, breadCrumb, idx, onSelectChange) {
72
+ children.forEach((c, i) => (c.isSelected = i === idx));
73
+ onSelectChange(children[idx], breadCrumb);
74
+ }
@@ -0,0 +1,11 @@
1
+ import { ActionEntry, ModeOptions } from '../model/action-map.model.js';
2
+ import { NavigateCtx } from '../model/navigation-ctx.model.js';
3
+ import { NavigationTree } from '../model/navigation-tree.model.js';
4
+ export declare let navigationState: {
5
+ mode: ModeOptions;
6
+ availableActions: ActionEntry<[NavigateCtx]>[];
7
+ viewHelp: boolean;
8
+ currentNode: NavigationTree<NavigationTree> | null;
9
+ breadCrumb: NavigationTree<NavigationTree>[];
10
+ };
11
+ export declare const setState: (cb: (oldState: typeof navigationState) => typeof navigationState) => void;
@@ -0,0 +1,10 @@
1
+ export let navigationState = {
2
+ mode: 'default',
3
+ availableActions: [],
4
+ viewHelp: false,
5
+ currentNode: null,
6
+ breadCrumb: [],
7
+ };
8
+ export const setState = (cb) => {
9
+ navigationState = cb(navigationState);
10
+ };
@@ -0,0 +1,16 @@
1
+ import readline from 'readline';
2
+ import { NavigateCtx } from '../model/navigation-ctx.model.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;
@@ -0,0 +1,65 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "epiq",
3
+ "version": "0.0.0",
4
+ "license": "MIT",
5
+ "bin": "dist/cli.js",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=16"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "test": "prettier --check . && xo && ava",
14
+ "execute": "node dist/cli.js"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "ink": "^4.1.0",
21
+ "meow": "^11.0.0",
22
+ "react": "^18.2.0"
23
+ },
24
+ "devDependencies": {
25
+ "@sindresorhus/tsconfig": "^3.0.1",
26
+ "@types/react": "^18.0.32",
27
+ "@vdemedes/prettier-config": "^2.0.1",
28
+ "ava": "^5.2.0",
29
+ "chalk": "^5.2.0",
30
+ "eslint-config-xo-react": "^0.27.0",
31
+ "eslint-plugin-react": "^7.32.2",
32
+ "eslint-plugin-react-hooks": "^4.6.0",
33
+ "ink-testing-library": "^3.0.0",
34
+ "prettier": "^2.8.7",
35
+ "ts-node": "^10.9.1",
36
+ "tsx": "^4.20.3",
37
+ "typescript": "^5.0.3",
38
+ "xo": "^0.53.1"
39
+ },
40
+ "ava": {
41
+ "extensions": {
42
+ "ts": "module",
43
+ "tsx": "module"
44
+ },
45
+ "nodeArguments": [
46
+ "--loader=ts-node/esm"
47
+ ]
48
+ },
49
+ "xo": {
50
+ "extends": "xo-react",
51
+ "prettier": true,
52
+ "rules": {
53
+ "react/prop-types": "off"
54
+ }
55
+ },
56
+ "prettier": "@vdemedes/prettier-config"
57
+ }
package/readme.md ADDED
@@ -0,0 +1,37 @@
1
+ # epiq
2
+
3
+ ## Local dev
4
+
5
+ Start dev server in background terminal session:
6
+
7
+ ```bash
8
+ $ npm run dev
9
+ ```
10
+
11
+ Run app with:
12
+
13
+ ```bash
14
+ $ npm run execute
15
+ ```
16
+
17
+ ## Install (WIP!)
18
+
19
+ ```bash
20
+ $ npm install --global epiq
21
+ ```
22
+
23
+ ## CLI (WIP!)
24
+
25
+ ```
26
+ $ epiq --help
27
+
28
+ Usage
29
+ $ epiq
30
+
31
+ Options
32
+ --name Your name
33
+
34
+ Examples
35
+ $ epiq --name=Jane
36
+ Hello, Jane
37
+ ```