UNPKG

@botonic/plugin-flow-builder

Version:

Use Flow Builder to show your contents

38 lines 1.68 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Element, Pic, Subtitle, Title } from '@botonic/react'; import { ContentFieldsBase } from './content-fields-base'; import { FlowButton } from './flow-button'; export class FlowElement extends 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 = 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 = FlowButton.fromAIAgent({ id: '', text: element.button.text, url: element.button.url, }); return newElement; } toBotonic(parentId) { var _a; return (_jsxs(Element, { children: [_jsx(Pic, { src: this.image }), _jsx(Title, { children: this.title }), _jsx(Subtitle, { children: this.subtitle }), (_a = this.button) === null || _a === void 0 ? void 0 : _a.renderButton(0)] }, `${parentId}-${this.id}`)); } } //# sourceMappingURL=flow-element.js.map