UNPKG

@botonic/react

Version:

Build Chatbots using React

18 lines 970 B
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { INPUT, isBrowser } from '@botonic/core'; import React from 'react'; import { ROLES } from '../constants'; import { staticAsset } from '../util/environment'; import { Message } from './message'; const serialize = audioProps => { return { audio: audioProps.src }; }; export const Audio = props => { props = Object.assign(Object.assign({}, props), { src: staticAsset(props.src) }); let content = props.children; if (isBrowser()) content = (_jsxs("audio", Object.assign({ style: { maxWidth: '100%' }, id: 'myAudio', controls: true }, { children: [_jsx("source", { src: props.src, type: 'audio/mpeg' }), "Your browser does not support this audio format."] }))); return (_jsx(Message, Object.assign({ role: ROLES.AUDIO_MESSAGE, json: serialize(props) }, props, { type: INPUT.AUDIO }, { children: content }))); }; Audio.serialize = serialize; //# sourceMappingURL=audio.js.map