UNPKG

console-gui-tools

Version:

A simple library to draw option menu, text popup or other widgets and layout on a Node.js console.

117 lines 3.1 kB
import { ForegroundColorName } from "chalk/source/vendor/ansi-styles/index.js"; import InPageWidgetBuilder from "../InPageWidgetBuilder.js"; import { HEX, RGB } from "../Utils.js"; import Control from "./Control.js"; /** * @description The configuration for the Box class. * @typedef {Object} BoxConfig * * @prop {string} id - The id of the box. * @prop {number} x - The x position of the box. * @prop {number} y - The y position of the box. * @prop {number} [width] - The width of the box. * @prop {number} [height] - The height of the box. * @prop {BoxStyle} [style] - The style of the box. * @prop {boolean} [visible] - If the box is visible. * @prop {boolean} [draggable] - If the box is draggable. * * @export * @interface BoxConfig */ export interface BoxConfig { id: string; x: number; y: number; width?: number; height?: number; style?: BoxStyle; visible?: boolean; draggable?: boolean; } /** * @description The style of the box. * @typedef {Object} BoxStyle * * @prop {boolean} [boxed] - If the box is boxed. * @prop {chalk.ForegroundColorName | HEX | RGB | ""} [color] - The color of the box. * @prop {string} [label] - The label of the box. * * @export * @interface BoxStyle */ export interface BoxStyle { boxed?: boolean; color?: ForegroundColorName | HEX | RGB | ""; label?: string; } /** * @description The class that represents a box. * * ![image](https://user-images.githubusercontent.com/14907987/215069151-037e28d6-011f-428a-baac-3fe42ac0d540.png) * * Example of a box containing a list of process running on the computer. * * @param {BoxConfig} config - The configuration of the box. * * @example ```ts * const box = new Box({ * id: "box", * x: 0, * y: 0, * width: 10, * height: 5, * style: { boxed: true, color: "red", label: "Box" } * }) * box.setContent(new InPageWidgetBuilder(5).addText("Hello World!")) * ``` * * @export * @class Box * @extends {Control} */ export declare class Box extends Control { content: InPageWidgetBuilder; private style; constructor(config: BoxConfig); /** * @description Draws a line inside the box. It keeps the style of the text. * * @private * @param {Array<StyledElement>} line * @memberof Box */ private drawInnerLine; /** * @description Sets the content of the box. * * @returns {Box} * @memberof Box */ update: () => this; /** * @description Sets the label of the box. * * @param {string} text * @returns {Box} * @memberof Box */ setLabel: (text: string) => Box; /** * @description Sets the style of the box. * * @param {BoxStyle} style * @returns {Box} * @memberof Box */ setStyle: (style: BoxStyle) => Box; /** * @description Sets the content of the box. * * @param {InPageWidgetBuilder} content * @returns {Box} * @memberof Box */ setContent: (content: InPageWidgetBuilder) => Box; } export default Box; //# sourceMappingURL=Box.d.ts.map