UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

21 lines (20 loc) 1.34 kB
import React, { useMemo } from 'react'; import { useTranslationContext } from '../../context'; const UnMemoizedAttachmentActions = (props) => { const { actionHandler, actions, id, text } = props; const { t } = useTranslationContext('UnMemoizedAttachmentActions'); const handleActionClick = (event, name, value) => actionHandler?.(name, value, event); const knownActionText = useMemo(() => ({ Cancel: t('Cancel'), Send: t('Send'), Shuffle: t('Shuffle'), }), [t]); return (React.createElement("div", { className: 'str-chat__message-attachment-actions' }, React.createElement("div", { className: 'str-chat__message-attachment-actions-form' }, React.createElement("span", null, text), actions.map((action) => (React.createElement("button", { className: `str-chat__message-attachment-actions-button str-chat__message-attachment-actions-button--${action.style}`, "data-testid": `${action.name}`, "data-value": action.value, key: `${id}-${action.value}`, onClick: (event) => handleActionClick(event, action.name, action.value) }, action.text ? (knownActionText[action.text] ?? t(action.text)) : null)))))); }; /** * A component for rendering the actions you can take on an attachment. */ export const AttachmentActions = React.memo(UnMemoizedAttachmentActions);