UNPKG

react-antd-admin-panel

Version:

Easy prototyping admin panel using React and Antd

35 lines 1.55 kB
export default class Item { constructor(key, value, title, text) { this.propsToAdd = ['id', 'text', 'render', 'style', 'object']; this.key(key); this.value(value !== null && value !== void 0 ? value : this._key); this.title(title !== null && title !== void 0 ? title : this._value); } id(v) { this._id = v; return this; } key(v) { this._key = v; return this; } text(v) { this._text = v; return this; } type(v) { this._type = v; return this; } value(v) { this._value = `${v}`; return this; } style(v) { this._style = v; return this; } title(v) { this._title = v ? (isNaN(v) ? v[0].toUpperCase() + v.substr(1) : `${v}`) : undefined; return this; } object(v) { this._object = v; return this; } render(v) { this._render = v; return this; } access(v) { this._access = v; return this; } description(v) { this._description = v; return this; } disabled(v) { this._disabled = v; return this; } getObject() { var _a, _b; let addProps = {}; // @ts-ignore this.propsToAdd.forEach((r) => { if (this[`_${r}`]) addProps[r] = this[`_${r}`]; }); return (Object.assign({ id: this._id, key: this._key, value: this._value, label: (_b = (_a = this._render) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : this._title, title: this._title, }, addProps)); } } //# sourceMappingURL=Item.js.map