UNPKG

@botonic/react

Version:

Build Chatbots using React

32 lines 1.32 kB
import { __awaiter } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { CoreBot } from '@botonic/core'; import React from 'react'; import { Text } from './components/text'; import { RequestContext } from './contexts'; export class ReactBot extends CoreBot { constructor(options) { super(Object.assign({ defaultRoutes: [ { path: '404', action: () => _jsx(Text, { children: "I don't understand you" }), // eslint-disable-line }, ], renderer: args => this.renderReactActions(args) }, options)); } renderReactActions({ request, actions }) { return __awaiter(this, void 0, void 0, function* () { const renderedActions = []; let props; let renderedAction; for (const Action of actions) { if (Action) { props = Action.botonicInit ? yield Action.botonicInit(request) : {}; renderedAction = (_jsx(RequestContext.Provider, Object.assign({ value: request }, { children: _jsx(Action, Object.assign({}, props)) }))); renderedActions.push(renderedAction); } } return renderedActions; }); } } //# sourceMappingURL=react-bot.js.map