@zohoim/chat-components 0.0.1-cx
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/es/ActionIcon/ActionIcon.js +82 -0
- package/es/ActionIcon/css/ActionIcon.module.css +8 -0
- package/es/ActionIcon/index.js +1 -0
- package/es/ActionIcon/props/defaultProps.js +8 -0
- package/es/ActionIcon/props/propTypes.js +17 -0
- package/es/ActionIconWrapper/ActionIconWrapper.js +61 -0
- package/es/ActionIconWrapper/css/ActionIconWrapper.module.css +32 -0
- package/es/ActionIconWrapper/css/cssJSLogic.js +14 -0
- package/es/ActionIconWrapper/index.js +1 -0
- package/es/ActionIconWrapper/props/defaultProps.js +6 -0
- package/es/ActionIconWrapper/props/propTypes.js +12 -0
- package/es/AttachmentBubble/AttachmentBubble.js +87 -0
- package/es/AttachmentBubble/css/AttachmentBubble.module.css +55 -0
- package/es/AttachmentBubble/css/cssJSLogic.js +18 -0
- package/es/AttachmentBubble/index.js +1 -0
- package/es/AttachmentBubble/props/defaultProps.js +8 -0
- package/es/AttachmentBubble/props/propTypes.js +19 -0
- package/es/AttachmentBubbleInfo/AttachmentBubbleInfo.js +48 -0
- package/es/AttachmentBubbleInfo/css/AttachmentBubbleInfo.module.css +39 -0
- package/es/AttachmentBubbleInfo/css/cssJSLogic.js +13 -0
- package/es/AttachmentBubbleInfo/index.js +1 -0
- package/es/AttachmentBubbleInfo/props/defaultProps.js +6 -0
- package/es/AttachmentBubbleInfo/props/propTypes.js +9 -0
- package/es/AttachmentIcon/AttachmentIcon.js +60 -0
- package/es/AttachmentIcon/css/AttachmentIcon.module.css +8 -0
- package/es/AttachmentIcon/css/cssJSLogic.js +13 -0
- package/es/AttachmentIcon/index.js +1 -0
- package/es/AttachmentIcon/props/defaultProps.js +8 -0
- package/es/AttachmentIcon/props/propTypes.js +21 -0
- package/es/AttachmentIcon/utils/getAttachmentIconComponent.js +81 -0
- package/es/Audio/Audio.js +38 -0
- package/es/Audio/css/Audio.module.css +7 -0
- package/es/Audio/index.js +1 -0
- package/es/Audio/props/defaultProps.js +6 -0
- package/es/Audio/props/propTypes.js +8 -0
- package/es/AudioBubble/AudioBubble.js +56 -0
- package/es/AudioBubble/css/AudioBubble.module.css +4 -0
- package/es/AudioBubble/index.js +1 -0
- package/es/AudioBubble/props/defaultProps.js +7 -0
- package/es/AudioBubble/props/propTypes.js +16 -0
- package/es/Fonts/puviFont.module.css +62 -0
- package/es/ImageBubble/ImageBubble.js +70 -0
- package/es/ImageBubble/css/ImageBubble.module.css +63 -0
- package/es/ImageBubble/css/cssJSLogic.js +15 -0
- package/es/ImageBubble/index.js +1 -0
- package/es/ImageBubble/props/defaultProps.js +6 -0
- package/es/ImageBubble/props/propTypes.js +13 -0
- package/es/LazyLoadImage/LazyLoadImage.js +37 -0
- package/es/LazyLoadImage/css/LazyLoadImage.module.css +5 -0
- package/es/LazyLoadImage/index.js +1 -0
- package/es/LazyLoadImage/props/defaultProps.js +6 -0
- package/es/LazyLoadImage/props/propTypes.js +8 -0
- package/es/LocationBubble/LocationBubble.js +62 -0
- package/es/LocationBubble/css/LocationBubble.module.css +57 -0
- package/es/LocationBubble/css/cssJSLogic.js +13 -0
- package/es/LocationBubble/images/location.png +0 -0
- package/es/LocationBubble/index.js +1 -0
- package/es/LocationBubble/props/defaultProps.js +6 -0
- package/es/LocationBubble/props/propTypes.js +8 -0
- package/es/MediaBubbleWrapper/MediaBubbleWrapper.js +62 -0
- package/es/MediaBubbleWrapper/css/MediaBubbleWrapper.module.css +7 -0
- package/es/MediaBubbleWrapper/index.js +1 -0
- package/es/MediaBubbleWrapper/props/defaultProps.js +7 -0
- package/es/MediaBubbleWrapper/props/propTypes.js +17 -0
- package/es/Message/Message.js +126 -0
- package/es/Message/index.js +1 -0
- package/es/Message/props/defaultProps.js +12 -0
- package/es/Message/props/propTypes.js +41 -0
- package/es/MessageAction/MessageAction.js +60 -0
- package/es/MessageAction/index.js +1 -0
- package/es/MessageAction/props/defaultProps.js +8 -0
- package/es/MessageAction/props/propTypes.js +21 -0
- package/es/MessageActions/MessageActions.js +120 -0
- package/es/MessageActions/css/MessageActions.module.css +24 -0
- package/es/MessageActions/index.js +1 -0
- package/es/MessageActions/props/defaultProps.js +10 -0
- package/es/MessageActions/props/propTypes.js +25 -0
- package/es/MessageActionsMore/MessageActionsMore.js +101 -0
- package/es/MessageActionsMore/css/MessageActionsMore.module.css +23 -0
- package/es/MessageActionsMore/index.js +1 -0
- package/es/MessageActionsMore/props/defaultProps.js +9 -0
- package/es/MessageActionsMore/props/propTypes.js +13 -0
- package/es/MessageActionsWrapper/MessageActionsWrapper.js +68 -0
- package/es/MessageActionsWrapper/css/MessageActionsWrapper.module.css +3 -0
- package/es/MessageActionsWrapper/index.js +1 -0
- package/es/MessageActionsWrapper/props/defaultProps.js +9 -0
- package/es/MessageActionsWrapper/props/propTypes.js +15 -0
- package/es/MessageAvatar/MessageAvatar.js +49 -0
- package/es/MessageAvatar/css/MessageAvatar.module.css +23 -0
- package/es/MessageAvatar/index.js +1 -0
- package/es/MessageAvatar/props/defaultProps.js +7 -0
- package/es/MessageAvatar/props/propTypes.js +13 -0
- package/es/MessageBox/MessageBox.js +66 -0
- package/es/MessageBox/css/MessageBox.module.css +56 -0
- package/es/MessageBox/css/cssJSLogic.js +18 -0
- package/es/MessageBox/index.js +1 -0
- package/es/MessageBox/props/defaultProps.js +6 -0
- package/es/MessageBox/props/propTypes.js +13 -0
- package/es/MessageBubble/MessageBubble.js +116 -0
- package/es/MessageBubble/css/MessageBubble.module.css +101 -0
- package/es/MessageBubble/css/cssJSLogic.js +34 -0
- package/es/MessageBubble/index.js +1 -0
- package/es/MessageBubble/props/defaultProps.js +11 -0
- package/es/MessageBubble/props/propTypes.js +17 -0
- package/es/MessageStatus/MessageStatus.js +77 -0
- package/es/MessageStatus/css/MessageStatus.module.css +17 -0
- package/es/MessageStatus/css/cssJSLogic.js +26 -0
- package/es/MessageStatus/index.js +1 -0
- package/es/MessageStatus/props/defaultProps.js +6 -0
- package/es/MessageStatus/props/propTypes.js +12 -0
- package/es/MoreActionItem/MoreActionItem.js +72 -0
- package/es/MoreActionItem/css/MoreActionItem.module.css +27 -0
- package/es/MoreActionItem/index.js +1 -0
- package/es/MoreActionItem/props/defaultProps.js +7 -0
- package/es/MoreActionItem/props/propTypes.js +14 -0
- package/es/ReplyBubble/ReplyBubble.js +118 -0
- package/es/ReplyBubble/css/ReplyBubble.module.css +23 -0
- package/es/ReplyBubble/css/cssJSLogic.js +14 -0
- package/es/ReplyBubble/index.js +1 -0
- package/es/ReplyBubble/props/defaultProps.js +8 -0
- package/es/ReplyBubble/props/propTypes.js +28 -0
- package/es/ReplyBubbleContent/ReplyBubbleContent.js +61 -0
- package/es/ReplyBubbleContent/css/ReplyBubbleContent.module.css +75 -0
- package/es/ReplyBubbleContent/css/cssJSLogic.js +13 -0
- package/es/ReplyBubbleContent/index.js +1 -0
- package/es/ReplyBubbleContent/props/defaultProps.js +6 -0
- package/es/ReplyBubbleContent/props/propTypes.js +11 -0
- package/es/ReplyBubbleHeader/ReplyBubbleHeader.js +74 -0
- package/es/ReplyBubbleHeader/css/ReplyBubbleHeader.module.css +44 -0
- package/es/ReplyBubbleHeader/css/cssJSLogic.js +12 -0
- package/es/ReplyBubbleHeader/index.js +1 -0
- package/es/ReplyBubbleHeader/props/defaultProps.js +7 -0
- package/es/ReplyBubbleHeader/props/propTypes.js +13 -0
- package/es/TextBubble/TextBubble.js +49 -0
- package/es/TextBubble/css/TextBubble.module.css +35 -0
- package/es/TextBubble/css/cssJSLogic.js +18 -0
- package/es/TextBubble/index.js +1 -0
- package/es/TextBubble/props/defaultProps.js +6 -0
- package/es/TextBubble/props/propTypes.js +10 -0
- package/es/Theme/ThemeAssets.js +78 -0
- package/es/Theme/ThemeWrapper.js +88 -0
- package/es/Theme/TooltipWrapper.js +85 -0
- package/es/Theme/constants/index.js +41 -0
- package/es/Theme/css/TooltipWrapper.module.css +10 -0
- package/es/Theme/index.js +1 -0
- package/es/Theme/props/defaultProps.js +10 -0
- package/es/Theme/props/propTypes.js +14 -0
- package/es/Theme/themeVariables/commonThemeColorVariable.js +17 -0
- package/es/Theme/themeVariables/dark/blueTheme.js +116 -0
- package/es/Theme/themeVariables/dark/commonColorVariable.js +16 -0
- package/es/Theme/themeVariables/dark/greenTheme.js +115 -0
- package/es/Theme/themeVariables/dark/orangeTheme.js +115 -0
- package/es/Theme/themeVariables/dark/redTheme.js +115 -0
- package/es/Theme/themeVariables/dark/yellowTheme.js +115 -0
- package/es/Theme/themeVariables/light/blueTheme.js +114 -0
- package/es/Theme/themeVariables/light/commonColorVariable.js +35 -0
- package/es/Theme/themeVariables/light/greenTheme.js +114 -0
- package/es/Theme/themeVariables/light/orangeTheme.js +114 -0
- package/es/Theme/themeVariables/light/redTheme.js +114 -0
- package/es/Theme/themeVariables/light/yellowTheme.js +114 -0
- package/es/Theme/themeVariables/pureDark/blueTheme.js +115 -0
- package/es/Theme/themeVariables/pureDark/commonColorVariable.js +18 -0
- package/es/Theme/themeVariables/pureDark/greenTheme.js +115 -0
- package/es/Theme/themeVariables/pureDark/orangeTheme.js +115 -0
- package/es/Theme/themeVariables/pureDark/redTheme.js +115 -0
- package/es/Theme/themeVariables/pureDark/yellowTheme.js +115 -0
- package/es/Theme/utils/combineConfigurations.js +17 -0
- package/es/Theme/utils/flatVariables.js +12 -0
- package/es/Theme/utils/getCustomizedCssVariables.js +19 -0
- package/es/Theme/utils/getThemeConfigurations.js +81 -0
- package/es/Theme/utils/getWrapperDivProps.js +16 -0
- package/es/Video/Video.js +38 -0
- package/es/Video/css/Video.module.css +5 -0
- package/es/Video/index.js +1 -0
- package/es/Video/props/defaultProps.js +6 -0
- package/es/Video/props/propTypes.js +8 -0
- package/es/VideoBubble/VideoBubble.js +66 -0
- package/es/VideoBubble/css/VideoBubble.module.css +12 -0
- package/es/VideoBubble/css/cssJSLogic.js +14 -0
- package/es/VideoBubble/index.js +1 -0
- package/es/VideoBubble/props/defaultProps.js +7 -0
- package/es/VideoBubble/props/propTypes.js +17 -0
- package/es/constants/index.js +1 -0
- package/es/css/common.module.css +6 -0
- package/es/icons/create-icon-components.js +172 -0
- package/es/icons/factory/attachments/audio.svg +19 -0
- package/es/icons/factory/attachments/code.svg +21 -0
- package/es/icons/factory/attachments/image.svg +20 -0
- package/es/icons/factory/attachments/pdf.svg +19 -0
- package/es/icons/factory/attachments/ppt.svg +1 -0
- package/es/icons/factory/attachments/text.svg +22 -0
- package/es/icons/factory/attachments/unknown.svg +21 -0
- package/es/icons/factory/attachments/video.svg +19 -0
- package/es/icons/factory/attachments/xls.svg +1 -0
- package/es/icons/factory/attachments/zip.svg +27 -0
- package/es/icons/factory/common/alertTriangle.svg +5 -0
- package/es/icons/factory/common/article.svg +4 -0
- package/es/icons/factory/common/reply.svg +6 -0
- package/es/icons/factory/messageStatus/clock.svg +7 -0
- package/es/icons/factory/messageStatus/doubleTick.svg +1 -0
- package/es/icons/factory/messageStatus/failed.svg +7 -0
- package/es/icons/factory/messageStatus/tick.svg +1 -0
- package/es/icons/icon.template.js +28 -0
- package/es/icons/iconSrc/attachments/Audio.js +38 -0
- package/es/icons/iconSrc/attachments/Code.js +44 -0
- package/es/icons/iconSrc/attachments/Image.js +43 -0
- package/es/icons/iconSrc/attachments/Pdf.js +38 -0
- package/es/icons/iconSrc/attachments/Ppt.js +26 -0
- package/es/icons/iconSrc/attachments/Text.js +47 -0
- package/es/icons/iconSrc/attachments/Txt.js +47 -0
- package/es/icons/iconSrc/attachments/Unknown.js +42 -0
- package/es/icons/iconSrc/attachments/Video.js +38 -0
- package/es/icons/iconSrc/attachments/Xls.js +26 -0
- package/es/icons/iconSrc/attachments/Zip.js +86 -0
- package/es/icons/iconSrc/attachments/index.js +10 -0
- package/es/icons/iconSrc/common/AlertTriangle.js +23 -0
- package/es/icons/iconSrc/common/Article.js +17 -0
- package/es/icons/iconSrc/common/Reply.js +13 -0
- package/es/icons/iconSrc/common/index.js +3 -0
- package/es/icons/iconSrc/messageStatus/Clock.js +14 -0
- package/es/icons/iconSrc/messageStatus/DoubleTick.js +16 -0
- package/es/icons/iconSrc/messageStatus/Failed.js +14 -0
- package/es/icons/iconSrc/messageStatus/Tick.js +13 -0
- package/es/icons/iconSrc/messageStatus/index.js +4 -0
- package/es/im/ArticleBubble/ArticleBubble.js +80 -0
- package/es/im/ArticleBubble/css/ArticleBubble.module.css +75 -0
- package/es/im/ArticleBubble/css/cssJSLogic.js +12 -0
- package/es/im/ArticleBubble/index.js +1 -0
- package/es/im/ArticleBubble/props/defaultProps.js +6 -0
- package/es/im/ArticleBubble/props/propTypes.js +14 -0
- package/es/im/IMIntegrationIcon/IMIntegrationIcon.js +73 -0
- package/es/im/IMIntegrationIcon/css/IMIntegrationIcon.module.css +72 -0
- package/es/im/IMIntegrationIcon/css/cssJSLogic.js +53 -0
- package/es/im/IMIntegrationIcon/index.js +1 -0
- package/es/im/IMIntegrationIcon/props/defaultProps.js +11 -0
- package/es/im/IMIntegrationIcon/props/propTypes.js +14 -0
- package/es/im/IMMessage/IMMessage.js +197 -0
- package/es/im/IMMessage/css/IMMessage.module.css +36 -0
- package/es/im/IMMessage/css/cssJSLogic.js +15 -0
- package/es/im/IMMessage/index.js +1 -0
- package/es/im/IMMessage/props/defaultProps.js +16 -0
- package/es/im/IMMessage/props/propTypes.js +126 -0
- package/es/im/IMMessageContent/IMMessageContent.js +128 -0
- package/es/im/IMMessageContent/css/IMMessageContent.module.css +8 -0
- package/es/im/IMMessageContent/index.js +1 -0
- package/es/im/IMMessageContent/props/defaultProps.js +9 -0
- package/es/im/IMMessageContent/props/propTypes.js +54 -0
- package/es/im/IMMessageMeta/IMMessageMeta.js +72 -0
- package/es/im/IMMessageMeta/css/IMMessageMeta.module.css +46 -0
- package/es/im/IMMessageMeta/css/cssJSLogic.js +29 -0
- package/es/im/IMMessageMeta/index.js +1 -0
- package/es/im/IMMessageMeta/props/defaultProps.js +11 -0
- package/es/im/IMMessageMeta/props/propTypes.js +42 -0
- package/es/im/IMMessageMetaInfo/IMMessageMetaInfo.js +29 -0
- package/es/im/IMMessageMetaInfo/css/IMMessageMetaInfo.module.css +14 -0
- package/es/im/IMMessageMetaInfo/index.js +1 -0
- package/es/im/IMMessageMetaInfo/props/defaultProps.js +8 -0
- package/es/im/IMMessageMetaInfo/props/propTypes.js +8 -0
- package/es/im/IMPermaLink/IMPermaLink.js +48 -0
- package/es/im/IMPermaLink/css/IMPermaLink.module.css +14 -0
- package/es/im/IMPermaLink/css/cssJSLogic.js +14 -0
- package/es/im/IMPermaLink/index.js +1 -0
- package/es/im/IMPermaLink/props/defaultProps.js +6 -0
- package/es/im/IMPermaLink/props/propTypes.js +11 -0
- package/es/im/IMReplyBubble/IMReplyBubble.js +52 -0
- package/es/im/IMReplyBubble/index.js +1 -0
- package/es/im/IMReplyBubble/props/defaultProps.js +7 -0
- package/es/im/IMReplyBubble/props/propTypes.js +29 -0
- package/es/im/IMTextBubble/IMTextBubble.js +40 -0
- package/es/im/IMTextBubble/index.js +1 -0
- package/es/im/IMTextBubble/props/defaultProps.js +8 -0
- package/es/im/IMTextBubble/props/propTypes.js +31 -0
- package/es/im/css/common.module.css +6 -0
- package/es/im/index.js +9 -0
- package/es/index.js +32 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** ** Libraries *** */
|
|
4
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
/** ** Components *** */
|
|
6
|
+
|
|
7
|
+
import ActionIconWrapper from '../ActionIconWrapper/ActionIconWrapper';
|
|
8
|
+
/** ** Icons *** */
|
|
9
|
+
// import ReplyIcon from '@zohodesk/icon/es/general/Reply';
|
|
10
|
+
|
|
11
|
+
import ReloadIcon from '@zohodesk/icon/es/general/Reload';
|
|
12
|
+
import CopyIcon from '@zohodesk/icon/es/general/Copy';
|
|
13
|
+
import DownloadIcon from '@zohodesk/icon/es/general/Cloud';
|
|
14
|
+
import DeleteIcon from '@zohodesk/icon/es/general/Delete';
|
|
15
|
+
import ForwardIcon from '@zohodesk/icon/es/channels/EmailForward';
|
|
16
|
+
import ReplyIcon from '../icons/iconSrc/common/Reply';
|
|
17
|
+
/** ** Hooks *** */
|
|
18
|
+
|
|
19
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
20
|
+
/** ** Constants *** */
|
|
21
|
+
|
|
22
|
+
import actionIconDefaultProps from './props/defaultProps';
|
|
23
|
+
import actionIconPropTypes from './props/propTypes';
|
|
24
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
25
|
+
import { defaultMessageActions } from '@zohoim/chat-components-utils/es/constants/messageActionConstants';
|
|
26
|
+
/** ** Styles *** */
|
|
27
|
+
|
|
28
|
+
import style from './css/ActionIcon.module.css';
|
|
29
|
+
const {
|
|
30
|
+
REPLY,
|
|
31
|
+
COPY,
|
|
32
|
+
DOWNLOAD,
|
|
33
|
+
RESEND,
|
|
34
|
+
DELETE,
|
|
35
|
+
FORWARD
|
|
36
|
+
} = defaultMessageActions;
|
|
37
|
+
export default function ActionIcon(props) {
|
|
38
|
+
const {
|
|
39
|
+
customStyle,
|
|
40
|
+
customProps,
|
|
41
|
+
onClick,
|
|
42
|
+
onMouseEnter,
|
|
43
|
+
id,
|
|
44
|
+
title,
|
|
45
|
+
isDisabled,
|
|
46
|
+
needIconOnly
|
|
47
|
+
} = props;
|
|
48
|
+
const {
|
|
49
|
+
actionIconWrapperProps = dummyObject
|
|
50
|
+
} = customProps;
|
|
51
|
+
/* External customization */
|
|
52
|
+
|
|
53
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
54
|
+
const iconStyle = useMemo(() => ({
|
|
55
|
+
base: newStyle.icon
|
|
56
|
+
}), [newStyle.icon]);
|
|
57
|
+
const renderIcon = useCallback(() => {
|
|
58
|
+
const iconMapping = {
|
|
59
|
+
[REPLY]: ReplyIcon,
|
|
60
|
+
[COPY]: CopyIcon,
|
|
61
|
+
[DOWNLOAD]: DownloadIcon,
|
|
62
|
+
[RESEND]: ReloadIcon,
|
|
63
|
+
[DELETE]: DeleteIcon,
|
|
64
|
+
[FORWARD]: ForwardIcon
|
|
65
|
+
};
|
|
66
|
+
const IconComponent = iconMapping[id];
|
|
67
|
+
return IconComponent ? /*#__PURE__*/React.createElement(IconComponent, {
|
|
68
|
+
customStyle: iconStyle
|
|
69
|
+
}) : null;
|
|
70
|
+
}, [iconStyle, id]);
|
|
71
|
+
return needIconOnly ? renderIcon() : /*#__PURE__*/React.createElement(ActionIconWrapper, _extends({
|
|
72
|
+
id: id,
|
|
73
|
+
isDisabled: isDisabled,
|
|
74
|
+
onClick: onClick,
|
|
75
|
+
onMouseEnter: onMouseEnter,
|
|
76
|
+
renderIcon: renderIcon,
|
|
77
|
+
title: title
|
|
78
|
+
}, actionIconWrapperProps));
|
|
79
|
+
}
|
|
80
|
+
ActionIcon.propTypes = actionIconPropTypes;
|
|
81
|
+
ActionIcon.defaultProps = actionIconDefaultProps;
|
|
82
|
+
ActionIcon.displayName = 'ActionIcon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ActionIcon } from './ActionIcon';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** ** Constants *** */
|
|
2
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
3
|
+
const actionIconDefaultProps = {
|
|
4
|
+
customStyle: dummyObject,
|
|
5
|
+
customProps: dummyObject,
|
|
6
|
+
needIconOnly: false
|
|
7
|
+
};
|
|
8
|
+
export default actionIconDefaultProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
/** ** Constants *** */
|
|
4
|
+
|
|
5
|
+
import { defaultMessageActions } from '@zohoim/chat-components-utils/es/constants/messageActionConstants';
|
|
6
|
+
const actionIconPropTypes = {
|
|
7
|
+
id: PropTypes.oneOf(Object.values(defaultMessageActions)).isRequired,
|
|
8
|
+
onClick: PropTypes.func.isRequired,
|
|
9
|
+
customProps: PropTypes.shape({
|
|
10
|
+
actionIconWrapperProps: PropTypes.object
|
|
11
|
+
}),
|
|
12
|
+
customStyle: PropTypes.object,
|
|
13
|
+
isDisabled: PropTypes.bool,
|
|
14
|
+
needIconOnly: PropTypes.bool,
|
|
15
|
+
title: PropTypes.string
|
|
16
|
+
};
|
|
17
|
+
export default actionIconPropTypes;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/** ** Hooks *** */
|
|
4
|
+
|
|
5
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
6
|
+
import useActionIconWrapper from '@zohoim/chat-components-hooks/es/ActionIconWrapper/useActionIconWrapper';
|
|
7
|
+
/** ** Constants *** */
|
|
8
|
+
|
|
9
|
+
import actionIconWrapperDefaultProps from './props/defaultProps';
|
|
10
|
+
import actionIconWrapperPropTypes from './props/propTypes';
|
|
11
|
+
/** ** Methods *** */
|
|
12
|
+
|
|
13
|
+
import renderHandler from '@zohoim/chat-components-utils/es/common/renderHandler';
|
|
14
|
+
import cssJSLogic from './css/cssJSLogic';
|
|
15
|
+
/** ** Styles *** */
|
|
16
|
+
|
|
17
|
+
import style from './css/ActionIconWrapper.module.css';
|
|
18
|
+
export default function ActionIconWrapper(props) {
|
|
19
|
+
const {
|
|
20
|
+
renderIcon,
|
|
21
|
+
customStyle,
|
|
22
|
+
onClick: propOnClick,
|
|
23
|
+
onMouseEnter: propOnMouseEnter,
|
|
24
|
+
id,
|
|
25
|
+
title,
|
|
26
|
+
isDisabled
|
|
27
|
+
} = props;
|
|
28
|
+
const {
|
|
29
|
+
onClick,
|
|
30
|
+
onMouseEnter
|
|
31
|
+
} = useActionIconWrapper({
|
|
32
|
+
onClick: propOnClick,
|
|
33
|
+
onMouseEnter: propOnMouseEnter,
|
|
34
|
+
id,
|
|
35
|
+
isDisabled
|
|
36
|
+
});
|
|
37
|
+
/* External CSS Customization */
|
|
38
|
+
|
|
39
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
40
|
+
/* css classnames added based on logic */
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
actionIconWrapperClass
|
|
44
|
+
} = cssJSLogic({
|
|
45
|
+
isDisabled
|
|
46
|
+
}, newStyle);
|
|
47
|
+
/* Render Icon */
|
|
48
|
+
|
|
49
|
+
const icon = renderHandler(renderIcon)({
|
|
50
|
+
id
|
|
51
|
+
});
|
|
52
|
+
return icon ? /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: actionIconWrapperClass,
|
|
54
|
+
"data-title": title,
|
|
55
|
+
onClick: onClick,
|
|
56
|
+
onMouseEnter: onMouseEnter
|
|
57
|
+
}, icon) : null;
|
|
58
|
+
}
|
|
59
|
+
ActionIconWrapper.propTypes = actionIconWrapperPropTypes;
|
|
60
|
+
ActionIconWrapper.defaultProps = actionIconWrapperDefaultProps;
|
|
61
|
+
ActionIconWrapper.displayName = 'ActionIconWrapper';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.varClass {
|
|
2
|
+
--actionIconWrapper-height: var(--zd_size26);
|
|
3
|
+
--actionIconWrapper-width: var(--zd_size26);
|
|
4
|
+
--actionIconWrapper-border: 1px;
|
|
5
|
+
--actionIconWrapper-border_radius: 4px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.actionIconWrapper {
|
|
9
|
+
composes: varClass;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
display: -webkit-inline-flex;
|
|
12
|
+
display: -ms-inline-flexbox;
|
|
13
|
+
color: var(--imlib_chat_components_actionIconWrapper_color);
|
|
14
|
+
position: relative;
|
|
15
|
+
width: var(--actionIconWrapper-width);
|
|
16
|
+
height: var(--actionIconWrapper-height);
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
border: var(--actionIconWrapper-border) solid transparent;
|
|
21
|
+
border-radius: var(--actionIconWrapper-border_radius);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.actionIconWrapper:hover {
|
|
25
|
+
background-color: var(--imlib_chat_components_actionIconWrapper_bg_color);
|
|
26
|
+
border-color: var(--imlib_chat_components_actionIconWrapper_border_color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.disabled {
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
opacity: 0.4;
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** ** Methods *** */
|
|
2
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
3
|
+
export default function cssJSLogic(props, style) {
|
|
4
|
+
const {
|
|
5
|
+
isDisabled
|
|
6
|
+
} = props;
|
|
7
|
+
const actionIconWrapperClass = compileClassNames({
|
|
8
|
+
[style.actionIconWrapper]: true,
|
|
9
|
+
[style.disabled]: isDisabled
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
actionIconWrapperClass
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ActionIconWrapper } from './ActionIconWrapper';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const actionIconWrapperPropTypes = {
|
|
4
|
+
id: PropTypes.string.isRequired,
|
|
5
|
+
onClick: PropTypes.func.isRequired,
|
|
6
|
+
onMouseEnter: PropTypes.func,
|
|
7
|
+
renderIcon: PropTypes.func.isRequired,
|
|
8
|
+
customStyle: PropTypes.object,
|
|
9
|
+
isDisabled: PropTypes.bool,
|
|
10
|
+
title: PropTypes.string
|
|
11
|
+
};
|
|
12
|
+
export default actionIconWrapperPropTypes;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/** ** Libraries *** */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
/** ** Hooks *** */
|
|
6
|
+
|
|
7
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
8
|
+
import useAttachmentBubble from '@zohoim/chat-components-hooks/es/AttachmentBubble/useAttachmentBubble';
|
|
9
|
+
/** ** Constants *** */
|
|
10
|
+
|
|
11
|
+
import attachmentBubbleDefaultProps from './props/defaultProps';
|
|
12
|
+
import attachmentBubblePropTypes from './props/propTypes';
|
|
13
|
+
/** ** Styles *** */
|
|
14
|
+
|
|
15
|
+
import style from './css/AttachmentBubble.module.css';
|
|
16
|
+
/** ** Components *** */
|
|
17
|
+
|
|
18
|
+
import AttachmentBubbleInfo from '../AttachmentBubbleInfo/AttachmentBubbleInfo';
|
|
19
|
+
import AttachmentIcon from '../AttachmentIcon/AttachmentIcon';
|
|
20
|
+
import { Container, Box } from '@zohodesk/components/es/Layout';
|
|
21
|
+
/** ** Methods *** */
|
|
22
|
+
|
|
23
|
+
import cssJSLogic from './css/cssJSLogic';
|
|
24
|
+
export default function AttachmentBubble(props) {
|
|
25
|
+
const {
|
|
26
|
+
customStyle,
|
|
27
|
+
customProps,
|
|
28
|
+
attachmentDetails,
|
|
29
|
+
isFailed,
|
|
30
|
+
isSending,
|
|
31
|
+
onClick: propOnClick,
|
|
32
|
+
attachmentBubbleTitle
|
|
33
|
+
} = props;
|
|
34
|
+
const {
|
|
35
|
+
attachmentBubbleInfoProps,
|
|
36
|
+
attachmentIconProps
|
|
37
|
+
} = customProps;
|
|
38
|
+
const {
|
|
39
|
+
formattedFileSize: fileSize,
|
|
40
|
+
fileName,
|
|
41
|
+
fileFormat,
|
|
42
|
+
isDisabled,
|
|
43
|
+
isValidAttachment,
|
|
44
|
+
mediaType,
|
|
45
|
+
onClick
|
|
46
|
+
} = useAttachmentBubble({
|
|
47
|
+
attachmentDetails,
|
|
48
|
+
onClick: propOnClick
|
|
49
|
+
});
|
|
50
|
+
/* External CSS Customization */
|
|
51
|
+
|
|
52
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
53
|
+
/* css classnames added based on logic */
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
attachmentBubbleClass
|
|
57
|
+
} = cssJSLogic({
|
|
58
|
+
isFailed,
|
|
59
|
+
isSending,
|
|
60
|
+
isDisabled
|
|
61
|
+
}, newStyle);
|
|
62
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
63
|
+
alignBox: "row",
|
|
64
|
+
className: attachmentBubbleClass,
|
|
65
|
+
"data-title": attachmentBubbleTitle,
|
|
66
|
+
isCover: false,
|
|
67
|
+
onClick: onClick
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
69
|
+
className: newStyle.attachmentBubbleIcon
|
|
70
|
+
}, /*#__PURE__*/React.createElement(AttachmentIcon, _extends({
|
|
71
|
+
fileFormat: fileFormat,
|
|
72
|
+
isDisabled: isDisabled,
|
|
73
|
+
isValidAttachment: isValidAttachment,
|
|
74
|
+
mediaType: mediaType
|
|
75
|
+
}, attachmentIconProps))), /*#__PURE__*/React.createElement(Box, {
|
|
76
|
+
className: newStyle.attachmentBubbleContent,
|
|
77
|
+
flexible: true
|
|
78
|
+
}, /*#__PURE__*/React.createElement(AttachmentBubbleInfo, _extends({
|
|
79
|
+
fileName: fileName,
|
|
80
|
+
fileSize: fileSize
|
|
81
|
+
}, attachmentBubbleInfoProps, {
|
|
82
|
+
isFailed: isFailed
|
|
83
|
+
}))));
|
|
84
|
+
}
|
|
85
|
+
AttachmentBubble.propTypes = attachmentBubblePropTypes;
|
|
86
|
+
AttachmentBubble.defaultProps = attachmentBubbleDefaultProps;
|
|
87
|
+
AttachmentBubble.displayName = 'AttachmentBubble';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.attachmentBubble {
|
|
2
|
+
width: 100% ;
|
|
3
|
+
background-color: var(--imlib_chat_components_attachmentBubble_bg_color);
|
|
4
|
+
border-radius: 3px;
|
|
5
|
+
border: 1px solid var(--imlib_chat_components_attachmentBubble_border_color);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.disabledAttachmentBubble {
|
|
9
|
+
opacity: 0.5;
|
|
10
|
+
cursor: not-allowed;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.failedAttachmentBubble {
|
|
14
|
+
background-color: var(
|
|
15
|
+
--imlib_chat_components_attachmentBubble_bg_color_failed
|
|
16
|
+
);
|
|
17
|
+
border-color: var(
|
|
18
|
+
--imlib_chat_components_attachmentBubble_border_color_failed
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sendingdAttachmentBubble {
|
|
23
|
+
opacity: 0.1;
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.attachmentBubbleCursor {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.attachmentBubbleIcon {
|
|
32
|
+
width: var(--zd_size60) ;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[dir=ltr] .attachmentBubbleIcon {
|
|
39
|
+
border-right: 1px solid
|
|
40
|
+
var(--imlib_chat_components_attachmentBubble_border_color);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[dir=rtl] .attachmentBubbleIcon {
|
|
44
|
+
border-left: 1px solid var(--imlib_chat_components_attachmentBubble_border_color);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.failedAttachmentBubble .attachmentBubbleIcon {
|
|
48
|
+
border-color: var(
|
|
49
|
+
--imlib_chat_components_attachmentBubble_border_color_failed
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.attachmentBubbleIcon, .attachmentBubbleContent {
|
|
54
|
+
padding: var(--zd_size10) ;
|
|
55
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
2
|
+
export default function cssJSLogic(props, style) {
|
|
3
|
+
const {
|
|
4
|
+
isFailed,
|
|
5
|
+
isSending,
|
|
6
|
+
isDisabled
|
|
7
|
+
} = props;
|
|
8
|
+
const attachmentBubbleClass = compileClassNames({
|
|
9
|
+
[style.attachmentBubble]: true,
|
|
10
|
+
[style.disabledAttachmentBubble]: isDisabled,
|
|
11
|
+
[style.failedAttachmentBubble]: isFailed,
|
|
12
|
+
[style.attachmentBubbleCursor]: !isSending && !isDisabled,
|
|
13
|
+
[style.sendingdAttachmentBubble]: isSending
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
attachmentBubbleClass
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttachmentBubble } from './AttachmentBubble';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** ** Constants *** */
|
|
2
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
3
|
+
const attachmentBubbleDefaultProps = {
|
|
4
|
+
attachmentBubbleTitle: '',
|
|
5
|
+
customStyle: dummyObject,
|
|
6
|
+
customProps: dummyObject
|
|
7
|
+
};
|
|
8
|
+
export default attachmentBubbleDefaultProps;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const attachmentBubblePropTypes = {
|
|
4
|
+
attachmentDetails: PropTypes.shape({
|
|
5
|
+
name: PropTypes.string.isRequired,
|
|
6
|
+
size: PropTypes.string.isRequired,
|
|
7
|
+
type: PropTypes.string.isRequired
|
|
8
|
+
}).isRequired,
|
|
9
|
+
customProps: PropTypes.shape({
|
|
10
|
+
attachmentBubbleInfoProps: PropTypes.object,
|
|
11
|
+
attachmentIconProps: PropTypes.object
|
|
12
|
+
}),
|
|
13
|
+
customStyle: PropTypes.object,
|
|
14
|
+
isFailed: PropTypes.bool,
|
|
15
|
+
isSending: PropTypes.bool,
|
|
16
|
+
onClick: PropTypes.func,
|
|
17
|
+
attachmentBubbleTitle: PropTypes.string
|
|
18
|
+
};
|
|
19
|
+
export default attachmentBubblePropTypes;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/** ** Hooks *** */
|
|
4
|
+
|
|
5
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
6
|
+
/** ** Constants *** */
|
|
7
|
+
|
|
8
|
+
import attachmentBubbleInfoDefaultProps from './props/defaultProps';
|
|
9
|
+
import attachmentBubbleInfoPropTypes from './props/propTypes';
|
|
10
|
+
/** ** Components *** */
|
|
11
|
+
|
|
12
|
+
import { Container, Box } from '@zohodesk/components/es/Layout';
|
|
13
|
+
/** ** Styles *** */
|
|
14
|
+
|
|
15
|
+
import style from './css/AttachmentBubbleInfo.module.css';
|
|
16
|
+
/** ** Methods *** */
|
|
17
|
+
|
|
18
|
+
import cssJSLogic from './css/cssJSLogic';
|
|
19
|
+
export default function AttachmentBubbleInfo(props) {
|
|
20
|
+
const {
|
|
21
|
+
customStyle,
|
|
22
|
+
fileName,
|
|
23
|
+
fileSize,
|
|
24
|
+
isFailed
|
|
25
|
+
} = props;
|
|
26
|
+
/* External css customization */
|
|
27
|
+
|
|
28
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
29
|
+
/* css classnames added based on logic */
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
attachmentBubbleInfoClass
|
|
33
|
+
} = cssJSLogic({
|
|
34
|
+
isFailed
|
|
35
|
+
}, newStyle);
|
|
36
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
37
|
+
className: attachmentBubbleInfoClass,
|
|
38
|
+
isCover: false
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
40
|
+
className: newStyle.fileName,
|
|
41
|
+
"data-title": fileName
|
|
42
|
+
}, fileName), fileSize ? /*#__PURE__*/React.createElement(Box, {
|
|
43
|
+
className: newStyle.fileSize
|
|
44
|
+
}, fileSize) : null);
|
|
45
|
+
}
|
|
46
|
+
AttachmentBubbleInfo.propTypes = attachmentBubbleInfoPropTypes;
|
|
47
|
+
AttachmentBubbleInfo.defaultProps = attachmentBubbleInfoDefaultProps;
|
|
48
|
+
AttachmentBubbleInfo.displayName = 'AttachmentBubbleInfo';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.varClass {
|
|
2
|
+
--attachmentBubbleInfo-fileName_font_size: var(--zd_font_size15);
|
|
3
|
+
--attachmentBubbleInfo-fileName_font_family: var(--zd_semibold);
|
|
4
|
+
--attachmentBubbleInfo-fileSize_font_size: var(--zd_font_size13);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.fileName {
|
|
8
|
+
composes: varClass;
|
|
9
|
+
font-size: var(--attachmentBubbleInfo-fileName_font_size);
|
|
10
|
+
font-family: var(--attachmentBubbleInfo-fileName_font_family);
|
|
11
|
+
color: var(--imlib_chat_components_attachmentBubbleInfo_fileName_color);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.failedAttachmentBubbleInfo .fileName{
|
|
15
|
+
color: var(--imlib_chat_components_attachmentBubbleInfo_fileName_color_failed);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.fileSize {
|
|
19
|
+
composes: varClass;
|
|
20
|
+
font-size: var(--attachmentBubbleInfo-fileSize_font_size);
|
|
21
|
+
color: var(--imlib_chat_components_attachmentBubbleInfo_fileSize_color);
|
|
22
|
+
margin-top: var(--zd_size5) ;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.failedAttachmentBubbleInfo .fileSize{
|
|
26
|
+
color: var(--imlib_chat_components_attachmentBubbleInfo_fileSize_color_failed);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.fileName,
|
|
30
|
+
.fileSize {
|
|
31
|
+
composes: dotted from "../../css/common.module.css";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.attachmentBubbleInfo {
|
|
35
|
+
width: 100% ;
|
|
36
|
+
line-height: normal;
|
|
37
|
+
/* Use this class name for css customization */
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
2
|
+
export default function cssJSLogic(props, style) {
|
|
3
|
+
const {
|
|
4
|
+
isFailed
|
|
5
|
+
} = props;
|
|
6
|
+
const attachmentBubbleInfoClass = compileClassNames({
|
|
7
|
+
[style.attachmentBubbleInfo]: true,
|
|
8
|
+
[style.failedAttachmentBubbleInfo]: isFailed
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
attachmentBubbleInfoClass
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttachmentBubbleInfo } from './AttachmentBubbleInfo';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const attachmentBubbleInfoPropTypes = {
|
|
4
|
+
fileName: PropTypes.string.isRequired,
|
|
5
|
+
fileSize: PropTypes.string.isRequired,
|
|
6
|
+
customStyle: PropTypes.object,
|
|
7
|
+
isFailed: PropTypes.bool
|
|
8
|
+
};
|
|
9
|
+
export default attachmentBubbleInfoPropTypes;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
/** ** Hooks *** */
|
|
4
|
+
|
|
5
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
6
|
+
/** ** Constants *** */
|
|
7
|
+
|
|
8
|
+
import attachmentIconDefaultProps from './props/defaultProps';
|
|
9
|
+
import attachmentIconPropTypes from './props/propTypes';
|
|
10
|
+
/** ** Methods *** */
|
|
11
|
+
|
|
12
|
+
import cssJSLogic from './css/cssJSLogic';
|
|
13
|
+
import getAttachmentIconComponent from './utils/getAttachmentIconComponent';
|
|
14
|
+
import renderHandler from '@zohoim/chat-components-utils/es/common/renderHandler';
|
|
15
|
+
/** ** Styles *** */
|
|
16
|
+
|
|
17
|
+
import style from './css/AttachmentIcon.module.css';
|
|
18
|
+
export default function AttachmentIcon(props) {
|
|
19
|
+
const {
|
|
20
|
+
customStyle,
|
|
21
|
+
fileFormat,
|
|
22
|
+
mediaType,
|
|
23
|
+
isDisabled,
|
|
24
|
+
renderCustomIcon,
|
|
25
|
+
isValidAttachment
|
|
26
|
+
} = props;
|
|
27
|
+
/* External CSS Customization */
|
|
28
|
+
|
|
29
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
30
|
+
/* css classnames added based on logic */
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
iconStyleClass
|
|
34
|
+
} = cssJSLogic({
|
|
35
|
+
isDisabled
|
|
36
|
+
}, newStyle);
|
|
37
|
+
const iconCustomStyle = useMemo(() => ({
|
|
38
|
+
base: iconStyleClass
|
|
39
|
+
}), [iconStyleClass]);
|
|
40
|
+
/* Custom Icon Renderer */
|
|
41
|
+
|
|
42
|
+
if (renderCustomIcon) {
|
|
43
|
+
const fileIcon = renderHandler(renderCustomIcon)();
|
|
44
|
+
return fileIcon;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
IconComponent
|
|
49
|
+
} = getAttachmentIconComponent({
|
|
50
|
+
fileFormat,
|
|
51
|
+
mediaType,
|
|
52
|
+
isValidAttachment
|
|
53
|
+
});
|
|
54
|
+
return IconComponent ? /*#__PURE__*/React.createElement(IconComponent, {
|
|
55
|
+
customStyle: iconCustomStyle
|
|
56
|
+
}) : null;
|
|
57
|
+
}
|
|
58
|
+
AttachmentIcon.propTypes = attachmentIconPropTypes;
|
|
59
|
+
AttachmentIcon.defaultProps = attachmentIconDefaultProps;
|
|
60
|
+
AttachmentIcon.displayName = 'AttachmentIcon';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
2
|
+
export default function cssJSLogic(props, style) {
|
|
3
|
+
const {
|
|
4
|
+
isDisabled
|
|
5
|
+
} = props;
|
|
6
|
+
const iconStyleClass = compileClassNames({
|
|
7
|
+
[style.icon]: true,
|
|
8
|
+
[style.disabledIcon]: isDisabled
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
iconStyleClass
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttachmentIcon } from './AttachmentIcon';
|