UNPKG

@try-at-software/input-elements

Version:

A package providing different input elements that are extensible and easily configurable for your custom needs.

30 lines (29 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InputElement = void 0; class InputElement { constructor(update) { this._isRendered = false; /** @inheritdoc */ this.update = () => { // This function should never ever be called in such a manner. // Instead, a custom function should be passed to the constructor and immediately after that - assigned to this property. throw new Error('This function should never be called!'); }; if (!update) throw new Error('No update callback was provided to the input element.'); this.update = update; } /** @inheritdoc */ render() { this._isRendered = true; return this.renderComponent(); } updateInternally() { // System events should not lead to re-render if the input element is never visualized. if (!this._isRendered) return; this.update(); } } exports.InputElement = InputElement;