1.0.3 • Published 3 years ago
tui-ts v1.0.3
About
"tui-ts" is a package that makes it extremely easy to build text-based user interfaces using context menus.
Installation
Using NPM:
npm i tui-ts
Using Yarn:
yarn add tui-ts
Example
// import the functions and the "UserInput" type.
import { createContextMenu, UserInput, build } from "tui-ts";
// create the first context menu.
createContextMenu({
id: "main",
run: () => {
console.log("this is the main menu!");
}
});
// create the second context menu.
createContextMenu({
// by defining "main" as the parentId,
// this context menu becomes a child of the first created context menu.
parentId: "main",
id: "some-other-menu",
run: (userInput: UserInput) => {
console.log(userInput);
console.log("this is another menu.");
}
});
// build the application.
build();
Documentation
build(): void
// example:
import { build } from "tui-ts";
build();
createContextMenu(contextMenuConfig: Readonly\): ContextMenu
// example:
import { createContextMenu, UserInput } from "tui-ts";
createContextMenu({
id: "foo",
run: (userInput: UserInput) => {
console.log(userInput);
}
});
getState(): Readonly\
// example:
import { getState } from "tui-ts";
const state = getState();
console.log(state["foo"]);
select(contextMenuId: ContextMenuId): ContextMenu
// example:
import { select } from "tui-ts";
select("foo");
setState(state: State): void
// example:
import { getState, setState } from "tui-ts";
const state = getState();
setState({ ...state, foo: "bar" });