@botonic/plugin-flow-builder
Version:
Use Flow Builder to show your contents
42 lines • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowElement = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@botonic/react");
const content_fields_base_1 = require("./content-fields-base");
const flow_button_1 = require("./flow-button");
class FlowElement extends content_fields_base_1.ContentFieldsBase {
constructor() {
super(...arguments);
this.title = '';
this.subtitle = '';
this.image = '';
this.hidden = false;
}
static fromHubtypeCMS(component, locale, cmsApi) {
const newElement = new FlowElement(component.id);
newElement.title = this.getTextByLocale(locale, component.title);
newElement.subtitle = this.getTextByLocale(locale, component.subtitle);
newElement.image = this.getAssetByLocale(locale, component.image);
newElement.button = flow_button_1.FlowButton.fromHubtypeCMS(component.button, locale, cmsApi);
return newElement;
}
static fromAIAgent(id, element) {
const newElement = new FlowElement(id);
newElement.title = element.title;
newElement.subtitle = element.subtitle;
newElement.image = element.image;
newElement.button = flow_button_1.FlowButton.fromAIAgent({
id: '',
text: element.button.text,
url: element.button.url,
});
return newElement;
}
toBotonic(parentId) {
var _a;
return ((0, jsx_runtime_1.jsxs)(react_1.Element, { children: [(0, jsx_runtime_1.jsx)(react_1.Pic, { src: this.image }), (0, jsx_runtime_1.jsx)(react_1.Title, { children: this.title }), (0, jsx_runtime_1.jsx)(react_1.Subtitle, { children: this.subtitle }), (_a = this.button) === null || _a === void 0 ? void 0 : _a.renderButton(0)] }, `${parentId}-${this.id}`));
}
}
exports.FlowElement = FlowElement;
//# sourceMappingURL=flow-element.js.map