UNPKG

@azure/communication-react

Version:

React library for building modern communication user experiences utilizing Azure Communication Services

37 lines 1.33 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import React from 'react'; import { Icon } from '@fluentui/react'; import { isMessageTooLong } from './SendBoxUtils'; import { _formatString } from "../../../../acs-ui-common/src"; import { MAXIMUM_LENGTH_OF_MESSAGE } from '../utils/SendBoxUtils'; /** * @private */ export const onRenderCancelIcon = (className) => { return React.createElement(Icon, { iconName: 'EditBoxCancel', className: className }); }; /** * @private */ export const onRenderSubmitIcon = (className) => { return React.createElement(Icon, { iconName: 'EditBoxSubmit', className: className }); }; function isMessageEmpty(messageText) { return messageText.trim().length === 0; } /** * @private */ export function getMessageState(messageText) { return isMessageEmpty(messageText) ? 'too short' : isMessageTooLong(messageText.length) ? 'too long' : 'OK'; } /** * @private */ export const getTextValidationErrorMessage = (messageState, tooLongString, tooShortString, imageOverflow = false) => { return messageState === 'too long' || imageOverflow ? _formatString(tooLongString, { limitNumber: `${MAXIMUM_LENGTH_OF_MESSAGE}` }) : messageState === 'too short' ? tooShortString : undefined; }; //# sourceMappingURL=ChatMessageComponentAsEditBoxUtils.js.map