UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

45 lines 1.53 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const terminal_kit_1 = __importDefault(require("terminal-kit")); const termKit_utility_1 = __importDefault(require("./termKit.utility")); const TkBaseWidget_1 = __importDefault(require("./TkBaseWidget")); const termKit = terminal_kit_1.default; class TKButtonWidget extends TkBaseWidget_1.default { button; type = 'button'; constructor(options) { super({ // shouldLockHeightWithParent: true, // shouldLockWidthWithParent: true, ...options, }); const { parent, text, ...rest } = options; const frame = termKit_utility_1.default.buildFrame(options, parent); this.button = new termKit.Button({ parent: parent ? parent.getTermKitElement() : undefined, content: text, ...rest, ...frame, }); this.button.on('submit', this.handleClick.bind(this)); this.button.__widget = this; this.calculateSizeLockDeltas(); } handleClick() { void this.emit('click'); } getText() { throw new Error('Method not implemented.'); } setText(text) { this.button.setContent(text); } getTermKitElement() { return this.button; } } exports.default = TKButtonWidget; //# sourceMappingURL=TKButtonWidget.js.map