UNPKG

fox-block-builder

Version:

Maintainable code for loop slack-block-kit-like modal builder

44 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PluginModalMetaBuilder = void 0; /** Конструктор обьекта метаданных модалки */ class PluginModalMetaBuilder { constructor(params = {}) { this.customValue = []; if (typeof params === 'string') { this.addString(params); } else { this.addMeta(params); } } addCustomValues(...values) { if (!this.customValue) { this.customValue = []; } this.customValue.push(...values); return this; } addMeta(params) { Object.entries(params).forEach(([key, value]) => { var _a; if (value !== undefined) { if (Array.isArray(value)) { this[key] = [...((_a = this[key]) !== null && _a !== void 0 ? _a : []), ...value]; } else { this[key] = value; } } }); return this; } addString(metaString = '') { return this.addMeta(JSON.parse(metaString)); } buildToJSON() { return JSON.stringify(this); } } exports.PluginModalMetaBuilder = PluginModalMetaBuilder; //# sourceMappingURL=plugin-modal-meta.builder.js.map