1.0.3 • Published 3 years ago

tui-ts v1.0.3

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

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" });
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.1-beta.0

3 years ago

1.0.0-beta.0

3 years ago