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.
- package/dist/app.d.ts +5 -0
- package/dist/app.js +12 -0
- package/dist/board/actions/board-action-map.d.ts +11 -0
- package/dist/board/actions/board-action-map.js +11 -0
- package/dist/board/actions/move-actions-routes.d.ts +4 -0
- package/dist/board/actions/move-actions-routes.js +31 -0
- package/dist/board/actions/move-actions.d.ts +5 -0
- package/dist/board/actions/move-actions.js +49 -0
- package/dist/board/board-action-map.d.ts +9 -0
- package/dist/board/board-action-map.js +7 -0
- package/dist/board/components/Board.d.ts +6 -0
- package/dist/board/components/Board.js +19 -0
- package/dist/board/components/Help.d.ts +4 -0
- package/dist/board/components/Help.js +21 -0
- package/dist/board/components/Logo.d.ts +2 -0
- package/dist/board/components/Logo.js +21 -0
- package/dist/board/components/ScrollBox.d.ts +9 -0
- package/dist/board/components/ScrollBox.js +22 -0
- package/dist/board/components/Swimlane.d.ts +8 -0
- package/dist/board/components/Swimlane.js +10 -0
- package/dist/board/components/Swimlanes.d.ts +8 -0
- package/dist/board/components/Swimlanes.js +20 -0
- package/dist/board/components/TicketListItem.d.ts +6 -0
- package/dist/board/components/TicketListItem.js +12 -0
- package/dist/board/components/TicketUI.d.ts +8 -0
- package/dist/board/components/TicketUI.js +9 -0
- package/dist/board/mock/board.d.ts +2 -0
- package/dist/board/mock/board.js +474 -0
- package/dist/board/model/board.model.d.ts +26 -0
- package/dist/board/model/board.model.js +6 -0
- package/dist/board/move-actions-routes.d.ts +4 -0
- package/dist/board/move-actions-routes.js +31 -0
- package/dist/board/move-actions.d.ts +5 -0
- package/dist/board/move-actions.js +49 -0
- package/dist/board/render/color.d.ts +7 -0
- package/dist/board/render/color.js +21 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +57 -0
- package/dist/components/Board.d.ts +6 -0
- package/dist/components/Board.js +15 -0
- package/dist/components/Help.d.ts +4 -0
- package/dist/components/Help.js +21 -0
- package/dist/components/Swimlane.d.ts +8 -0
- package/dist/components/Swimlane.js +10 -0
- package/dist/components/TicketListItem.d.ts +6 -0
- package/dist/components/TicketListItem.js +12 -0
- package/dist/lib/actions/board-action-map.d.ts +9 -0
- package/dist/lib/actions/board-action-map.js +7 -0
- package/dist/lib/actions/move-actions-utils.d.ts +5 -0
- package/dist/lib/actions/move-actions-utils.js +43 -0
- package/dist/lib/actions/move-actions.d.ts +4 -0
- package/dist/lib/actions/move-actions.js +31 -0
- package/dist/lib/board/board-action-map.d.ts +9 -0
- package/dist/lib/board/board-action-map.js +7 -0
- package/dist/lib/board/move-actions-routes.d.ts +4 -0
- package/dist/lib/board/move-actions-routes.js +31 -0
- package/dist/lib/board/move-actions.d.ts +5 -0
- package/dist/lib/board/move-actions.js +43 -0
- package/dist/lib/board-utils.d.ts +7 -0
- package/dist/lib/board-utils.js +33 -0
- package/dist/lib/default-actions-routes.d.ts +4 -0
- package/dist/lib/default-actions-routes.js +47 -0
- package/dist/lib/default-actions.d.ts +4 -0
- package/dist/lib/default-actions.js +47 -0
- package/dist/lib/navigation-context.d.ts +16 -0
- package/dist/lib/navigation-context.js +1 -0
- package/dist/lib/navigation.d.ts +10 -0
- package/dist/lib/navigation.js +74 -0
- package/dist/lib/render-utils.d.ts +10 -0
- package/dist/lib/render-utils.js +12 -0
- package/dist/lib/state.d.ts +8 -0
- package/dist/lib/state.js +8 -0
- package/dist/lib/types/action-map.model.d.ts +14 -0
- package/dist/lib/types/action-map.model.js +4 -0
- package/dist/lib/types/board.model.d.ts +21 -0
- package/dist/lib/types/board.model.js +5 -0
- package/dist/lib/types/navigation.model.d.ts +9 -0
- package/dist/lib/types/navigation.model.js +1 -0
- package/dist/lib/utils/array-utils.d.ts +5 -0
- package/dist/lib/utils/array-utils.js +7 -0
- package/dist/lib/utils/default-action-utils.d.ts +7 -0
- package/dist/lib/utils/default-action-utils.js +50 -0
- package/dist/lib/utils/default-actions.d.ts +7 -0
- package/dist/lib/utils/default-actions.js +50 -0
- package/dist/lib/utils/key-intent.d.ts +16 -0
- package/dist/lib/utils/key-intent.js +65 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/lib/utils.js +12 -0
- package/dist/mock/board.d.ts +2 -0
- package/dist/mock/board.js +139 -0
- package/dist/navigation/actions/default-actions-routes.d.ts +4 -0
- package/dist/navigation/actions/default-actions-routes.js +47 -0
- package/dist/navigation/actions/default-actions.d.ts +7 -0
- package/dist/navigation/actions/default-actions.js +48 -0
- package/dist/navigation/model/action-map.model.d.ts +14 -0
- package/dist/navigation/model/action-map.model.js +4 -0
- package/dist/navigation/model/navigation-ctx.model.d.ts +16 -0
- package/dist/navigation/model/navigation-ctx.model.js +2 -0
- package/dist/navigation/model/navigation-tree.model.d.ts +9 -0
- package/dist/navigation/model/navigation-tree.model.js +1 -0
- package/dist/navigation/navigation.d.ts +10 -0
- package/dist/navigation/navigation.js +74 -0
- package/dist/navigation/state/state.d.ts +11 -0
- package/dist/navigation/state/state.js +10 -0
- package/dist/navigation/utils/key-intent.d.ts +16 -0
- package/dist/navigation/utils/key-intent.js +65 -0
- package/package.json +57 -0
- 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,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
|
+
```
|