@zohoim/chat-components 1.0.9-alpha.0 → 1.0.9-beta.1
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 +2 -2
- package/es/ActionIcon/ActionIcon.js +3 -1
- package/es/ActionIcon/props/propTypes.js +2 -1
- package/es/ActionIconWrapper/ActionIconWrapper.js +6 -3
- package/es/ActionIconWrapper/css/ActionIconWrapper.module.css +1 -1
- package/es/ActionIconWrapper/css/cssJSLogic.js +4 -2
- package/es/ActionIconWrapper/props/propTypes.js +2 -1
- package/es/AttachmentHandler/AttachmentHandler.js +84 -0
- package/es/AttachmentHandler/css/AttachmentHandler.module.css +17 -0
- package/es/AttachmentHandler/index.js +1 -0
- package/es/AttachmentHandler/props/defaultProps.js +10 -0
- package/es/AttachmentHandler/props/propTypes.js +17 -0
- package/es/AttachmentPreview/AttachmentPreview.js +113 -0
- package/es/AttachmentPreview/css/AttachmentPreview.module.css +31 -0
- package/es/AttachmentPreview/index.js +1 -0
- package/es/AttachmentPreview/props/defaultProps.js +7 -0
- package/es/AttachmentPreview/props/propTypes.js +31 -0
- package/es/AttachmentPreviewBody/AttachmentPreviewBody.js +76 -0
- package/es/AttachmentPreviewBody/css/AttachmentPreviewBody.module.css +63 -0
- package/es/AttachmentPreviewBody/index.js +1 -0
- package/es/AttachmentPreviewBody/props/defaultProps.js +7 -0
- package/es/AttachmentPreviewBody/props/propTypes.js +20 -0
- package/es/AttachmentPreviewHeader/AttachmentPreviewHeader.js +84 -0
- package/es/AttachmentPreviewHeader/css/AttachmentPreviewHeader.module.css +45 -0
- package/es/AttachmentPreviewHeader/index.js +1 -0
- package/es/AttachmentPreviewHeader/props/defaultProps.js +7 -0
- package/es/AttachmentPreviewHeader/props/propTypes.js +16 -0
- package/es/Emoji/Emoji.js +72 -0
- package/es/Emoji/css/Emoji.module.css +47 -0
- package/es/Emoji/css/cssJSLogic.js +18 -0
- package/es/Emoji/index.js +1 -0
- package/es/Emoji/props/defaultProps.js +8 -0
- package/es/Emoji/props/propTypes.js +16 -0
- package/es/EmojiPopup/EmojiPopup.js +116 -0
- package/es/EmojiPopup/css/EmojiPopup.module.css +50 -0
- package/es/EmojiPopup/index.js +1 -0
- package/es/EmojiPopup/props/defaultProps.js +11 -0
- package/es/EmojiPopup/props/propTypes.js +21 -0
- package/es/Emojis/Emojis.js +81 -0
- package/es/Emojis/index.js +1 -0
- package/es/Emojis/props/defaultProps.js +10 -0
- package/es/Emojis/props/propTypes.js +19 -0
- package/es/EmojisEmptyState/EmojisEmptyState.js +50 -0
- package/es/EmojisEmptyState/css/EmojisEmptyState.module.css +18 -0
- package/es/EmojisEmptyState/index.js +1 -0
- package/es/EmojisEmptyState/props/defaultProps.js +9 -0
- package/es/EmojisEmptyState/props/propTypes.js +8 -0
- package/es/EmojisFooter/EmojisFooter.js +71 -0
- package/es/EmojisFooter/css/EmojisFooter.module.css +40 -0
- package/es/EmojisFooter/index.js +1 -0
- package/es/EmojisFooter/props/defaultProps.js +7 -0
- package/es/EmojisFooter/props/propTypes.js +12 -0
- package/es/EmojisHeader/EmojisHeader.js +65 -0
- package/es/EmojisHeader/css/EmojisHeader.module.css +38 -0
- package/es/EmojisHeader/index.js +1 -0
- package/es/EmojisHeader/props/defaultProps.js +8 -0
- package/es/EmojisHeader/props/propTypes.js +13 -0
- package/es/EmojisList/EmojisList.js +133 -0
- package/es/EmojisList/css/EmojisList.module.css +50 -0
- package/es/EmojisList/css/cssJSLogic.js +25 -0
- package/es/EmojisList/index.js +1 -0
- package/es/EmojisList/props/defaultProps.js +10 -0
- package/es/EmojisList/props/propTypes.js +20 -0
- package/es/MessageAction/MessageAction.js +2 -0
- package/es/MessageAction/props/propTypes.js +2 -1
- package/es/MessageActions/MessageActions.js +2 -1
- package/es/MessageActionsMore/MessageActionsMore.js +6 -4
- package/es/MessageActionsMore/css/MessageActionsMore.module.css +1 -0
- package/es/MessageActionsMore/props/propTypes.js +5 -2
- package/es/MessageActionsWrapper/MessageActionsWrapper.js +2 -1
- package/es/MessageActionsWrapper/css/MessageActionsWrapper.module.css +4 -0
- package/es/Theme/ThemeAssets.js +2 -20
- package/es/Theme/ThemeWrapper.js +23 -14
- package/es/Theme/TooltipWrapper.js +1 -1
- package/es/Theme/props/defaultProps.js +2 -1
- package/es/Theme/props/propTypes.js +2 -1
- package/es/Theme/themeVariables/commonThemeColorVariable.js +17 -0
- package/es/Theme/themeVariables/dark/blueTheme.js +121 -0
- package/es/Theme/themeVariables/dark/commonColorVariable.js +27 -0
- package/es/Theme/themeVariables/dark/greenTheme.js +119 -0
- package/es/Theme/themeVariables/dark/orangeTheme.js +119 -0
- package/es/Theme/themeVariables/dark/redTheme.js +119 -0
- package/es/Theme/themeVariables/dark/yellowTheme.js +119 -0
- package/es/Theme/themeVariables/light/blueTheme.js +123 -0
- package/es/Theme/themeVariables/light/commonColorVariable.js +46 -0
- package/es/Theme/themeVariables/light/greenTheme.js +117 -0
- package/es/Theme/themeVariables/light/orangeTheme.js +117 -0
- package/es/Theme/themeVariables/light/redTheme.js +117 -0
- package/es/Theme/themeVariables/light/yellowTheme.js +117 -0
- package/es/Theme/themeVariables/pureDark/blueTheme.js +120 -0
- package/es/Theme/themeVariables/pureDark/commonColorVariable.js +29 -0
- package/es/Theme/themeVariables/pureDark/greenTheme.js +119 -0
- package/es/Theme/themeVariables/pureDark/orangeTheme.js +119 -0
- package/es/Theme/themeVariables/pureDark/redTheme.js +119 -0
- package/es/Theme/themeVariables/pureDark/yellowTheme.js +119 -0
- package/es/Theme/utils/getThemeConfigurations.js +56 -2
- package/es/constants/index.js +7 -1
- package/es/constants/propConstants/editorPropConstants.js +3 -0
- package/es/constants/propConstants/popupPropConstants.js +2 -0
- package/es/im/IMAttachmentHandler/IMAttachmentHandler.js +50 -0
- package/es/im/IMAttachmentHandler/index.js +1 -0
- package/es/im/IMAttachmentHandler/props/defaultProps.js +10 -0
- package/es/im/IMAttachmentHandler/props/propTypes.js +28 -0
- package/es/im/IMIntegrationIcon/css/IMIntegrationIcon.module.css +2 -2
- package/es/im/ReplyComposer/ReplyComposer.js +137 -0
- package/es/im/ReplyComposer/css/ReplyComposer.module.css +5 -0
- package/es/im/ReplyComposer/index.js +1 -0
- package/es/im/ReplyComposer/props/defaultProps.js +7 -0
- package/es/im/ReplyComposer/props/propTypes.js +60 -0
- package/es/im/ReplyComposerFooter/ReplyComposerFooter.js +41 -0
- package/es/im/ReplyComposerFooter/css/ReplyComposerFooter.module.css +5 -0
- package/es/im/ReplyComposerFooter/index.js +1 -0
- package/es/im/ReplyComposerFooter/props/defaultProps.js +8 -0
- package/es/im/ReplyComposerFooter/props/propTypes.js +17 -0
- package/es/im/ReplyEditor/ReplyEditor.js +103 -0
- package/es/im/ReplyEditor/css/ReplyEditor.module.css +30 -0
- package/es/im/ReplyEditor/css/cssJSLogic.js +10 -0
- package/es/im/ReplyEditor/index.js +1 -0
- package/es/im/ReplyEditor/props/defaultProps.js +8 -0
- package/es/im/ReplyEditor/props/propTypes.js +27 -0
- package/es/im/ReplyEditorExtensions/ReplyEditorExtensions.js +149 -0
- package/es/im/ReplyEditorExtensions/css/ReplyEditorExtensions.module.css +5 -0
- package/es/im/ReplyEditorExtensions/index.js +1 -0
- package/es/im/ReplyEditorExtensions/props/defaultProps.js +6 -0
- package/es/im/ReplyEditorExtensions/props/propTypes.js +16 -0
- package/es/im/ReplyEditorSuggestions/ReplyEditorSuggestions.js +87 -0
- package/es/im/ReplyEditorSuggestions/css/ReplyEditorSuggestions.module.css +8 -0
- package/es/im/ReplyEditorSuggestions/index.js +1 -0
- package/es/im/ReplyEditorSuggestions/props/defaultProps.js +6 -0
- package/es/im/ReplyEditorSuggestions/props/propTypes.js +20 -0
- package/es/im/ReplyEditorSuggestionsPopup/ReplyEditorSuggestionsPopup.js +90 -0
- package/es/im/ReplyEditorSuggestionsPopup/css/ReplyEditorSuggestionsPopup.module.css +7 -0
- package/es/im/ReplyEditorSuggestionsPopup/index.js +1 -0
- package/es/im/ReplyEditorSuggestionsPopup/props/defaultProps.js +10 -0
- package/es/im/ReplyEditorSuggestionsPopup/props/propTypes.js +21 -0
- package/es/im/index.js +8 -1
- package/es/index.js +13 -2
- package/es/rte/Editor/Editor.js +80 -0
- package/es/rte/Editor/css/Editor.module.css +19 -0
- package/es/rte/Editor/index.js +1 -0
- package/es/rte/Editor/props/defaultProps.js +21 -0
- package/es/rte/Editor/props/propTypes.js +52 -0
- package/es/rte/index.js +1 -0
- package/package.json +13 -20
- package/assets/Appearance/dark/mode/General_DarkMode.module.css +0 -71
- package/assets/Appearance/dark/themes/blue/blue_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/green/green_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/orange/orange_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/red/red_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/yellow/yellow_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/light/mode/General_LightMode.module.css +0 -71
- package/assets/Appearance/light/themes/blue/blue_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/green/green_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/orange/orange_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/red/red_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/yellow/yellow_General_LightTheme.module.css +0 -35
- package/assets/Appearance/pureDark/mode/General_PureDarkMode.module.css +0 -71
- package/assets/Appearance/pureDark/themes/blue/blue_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/green/green_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/orange/orange_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/red/red_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/yellow/yellow_General_PureDarkTheme.module.css +0 -35
- package/es/Theme/constants/index.js +0 -41
- package/lib/index.js +0 -382
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ In this Library, We Provide Some Basic Message Components to Build Your Chat App
|
|
|
10
10
|
|
|
11
11
|
> import MessageBubble from '@zohoim/chat-components/es/MessageBubble/MessageBubble’;
|
|
12
12
|
|
|
13
|
-
# 1.0.
|
|
13
|
+
# 1.0.9
|
|
14
14
|
|
|
15
|
-
-
|
|
15
|
+
- chat bubble ui issues fixes
|
|
16
16
|
- @zohodesk/components version update
|
|
17
17
|
|
|
18
18
|
# 1.0.6
|
|
@@ -41,7 +41,8 @@ export default function ActionIcon(props) {
|
|
|
41
41
|
id,
|
|
42
42
|
title,
|
|
43
43
|
isDisabled,
|
|
44
|
-
needIconOnly
|
|
44
|
+
needIconOnly,
|
|
45
|
+
isActive
|
|
45
46
|
} = props;
|
|
46
47
|
const {
|
|
47
48
|
actionIconWrapperProps = dummyObject
|
|
@@ -68,6 +69,7 @@ export default function ActionIcon(props) {
|
|
|
68
69
|
}, [iconStyle, id]);
|
|
69
70
|
return needIconOnly ? renderIcon() : /*#__PURE__*/React.createElement(ActionIconWrapper, {
|
|
70
71
|
id: id,
|
|
72
|
+
isActive: isActive,
|
|
71
73
|
isDisabled: isDisabled,
|
|
72
74
|
onClick: onClick,
|
|
73
75
|
onMouseEnter: onMouseEnter,
|
|
@@ -23,7 +23,8 @@ export default function ActionIconWrapper(props) {
|
|
|
23
23
|
onMouseEnter: propOnMouseEnter,
|
|
24
24
|
id,
|
|
25
25
|
title,
|
|
26
|
-
isDisabled
|
|
26
|
+
isDisabled,
|
|
27
|
+
isActive
|
|
27
28
|
} = props;
|
|
28
29
|
const {
|
|
29
30
|
onClick,
|
|
@@ -32,7 +33,8 @@ export default function ActionIconWrapper(props) {
|
|
|
32
33
|
onClick: propOnClick,
|
|
33
34
|
onMouseEnter: propOnMouseEnter,
|
|
34
35
|
id,
|
|
35
|
-
isDisabled
|
|
36
|
+
isDisabled,
|
|
37
|
+
isActive
|
|
36
38
|
});
|
|
37
39
|
/* External CSS Customization */
|
|
38
40
|
|
|
@@ -42,7 +44,8 @@ export default function ActionIconWrapper(props) {
|
|
|
42
44
|
const {
|
|
43
45
|
actionIconWrapperClass
|
|
44
46
|
} = cssJSLogic({
|
|
45
|
-
isDisabled
|
|
47
|
+
isDisabled,
|
|
48
|
+
isActive
|
|
46
49
|
}, newStyle);
|
|
47
50
|
/* Render Icon */
|
|
48
51
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
border-radius: var(--actionIconWrapper-border_radius);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.actionIconWrapper:hover {
|
|
24
|
+
.actionIconWrapper:hover, .actionIconWrapperActive{
|
|
25
25
|
background-color: var(--imlib_chat_components_actionIconWrapper_bg_color);
|
|
26
26
|
border-color: var(--imlib_chat_components_actionIconWrapper_border_color);
|
|
27
27
|
}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { compileClassNames } from '@zohodesk/utils';
|
|
3
3
|
export default function cssJSLogic(props, style) {
|
|
4
4
|
const {
|
|
5
|
-
isDisabled
|
|
5
|
+
isDisabled,
|
|
6
|
+
isActive
|
|
6
7
|
} = props;
|
|
7
8
|
const actionIconWrapperClass = compileClassNames({
|
|
8
9
|
[style.actionIconWrapper]: true,
|
|
9
|
-
[style.disabled]: isDisabled
|
|
10
|
+
[style.disabled]: isDisabled,
|
|
11
|
+
[style.actionIconWrapperActive]: isActive
|
|
10
12
|
});
|
|
11
13
|
return {
|
|
12
14
|
actionIconWrapperClass
|
|
@@ -7,6 +7,7 @@ const actionIconWrapperPropTypes = {
|
|
|
7
7
|
renderIcon: PropTypes.func.isRequired,
|
|
8
8
|
customStyle: PropTypes.object,
|
|
9
9
|
isDisabled: PropTypes.bool,
|
|
10
|
-
title: PropTypes.string
|
|
10
|
+
title: PropTypes.string,
|
|
11
|
+
isActive: PropTypes.bool
|
|
11
12
|
};
|
|
12
13
|
export default actionIconWrapperPropTypes;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
/** ** Component *** */
|
|
4
|
+
|
|
5
|
+
import IconButton from '@zohodesk/dot/es/IconButton/IconButton';
|
|
6
|
+
import { Container } from '@zohodesk/components/es/Layout';
|
|
7
|
+
/** ** Hooks *** */
|
|
8
|
+
|
|
9
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
10
|
+
import useAttachmentHandler from '@zohoim/chat-components-hooks/es/AttachmentHandler/useAttachmentHandler';
|
|
11
|
+
/** ** Constants *** */
|
|
12
|
+
|
|
13
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
14
|
+
import attachmentHandlerDefaultProps from "./props/defaultProps";
|
|
15
|
+
import attachmentHandlerPropTypes from "./props/propTypes";
|
|
16
|
+
/** ** Methods *** */
|
|
17
|
+
|
|
18
|
+
import renderHandler from '@zohoim/chat-components-utils/es/common/renderHandler';
|
|
19
|
+
/** ** Styles *** */
|
|
20
|
+
|
|
21
|
+
import style from "./css/AttachmentHandler.module.css";
|
|
22
|
+
export default function AttachmentHandler(props) {
|
|
23
|
+
const {
|
|
24
|
+
customStyle,
|
|
25
|
+
iconName,
|
|
26
|
+
iconSize,
|
|
27
|
+
iconTitle,
|
|
28
|
+
renderCustomIcon,
|
|
29
|
+
getRef: propGetRef,
|
|
30
|
+
supportedFileTypes,
|
|
31
|
+
isMultiAttachment,
|
|
32
|
+
onAttach: propOnAttach,
|
|
33
|
+
customProps = dummyObject
|
|
34
|
+
} = props;
|
|
35
|
+
const {
|
|
36
|
+
inputProps = dummyObject
|
|
37
|
+
} = customProps;
|
|
38
|
+
const {
|
|
39
|
+
onAttach,
|
|
40
|
+
onAttachmentClick,
|
|
41
|
+
getRef
|
|
42
|
+
} = useAttachmentHandler({
|
|
43
|
+
onAttach: propOnAttach,
|
|
44
|
+
getRef: propGetRef
|
|
45
|
+
});
|
|
46
|
+
/* External customization */
|
|
47
|
+
|
|
48
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
49
|
+
const inputEl = useMemo(() => /*#__PURE__*/React.createElement("input", {
|
|
50
|
+
ref: getRef,
|
|
51
|
+
accept: supportedFileTypes,
|
|
52
|
+
hidden: true,
|
|
53
|
+
multiple: isMultiAttachment,
|
|
54
|
+
onChange: onAttach,
|
|
55
|
+
size: "1",
|
|
56
|
+
type: "file",
|
|
57
|
+
...inputProps
|
|
58
|
+
}), [supportedFileTypes, getRef, onAttach, isMultiAttachment, inputProps]);
|
|
59
|
+
const customIcon = useMemo(() => {
|
|
60
|
+
/* Render Custom Icon */
|
|
61
|
+
const icon = renderHandler(renderCustomIcon)({
|
|
62
|
+
onClick: onAttachmentClick
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (icon) {
|
|
66
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, icon, inputEl);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return null;
|
|
70
|
+
}, [renderCustomIcon, onAttachmentClick, inputEl]);
|
|
71
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
72
|
+
alignBox: "column"
|
|
73
|
+
}, customIcon || /*#__PURE__*/React.createElement(IconButton, {
|
|
74
|
+
className: newStyle.iconButton,
|
|
75
|
+
iconClass: newStyle.icon,
|
|
76
|
+
iconName: iconName,
|
|
77
|
+
iconSize: iconSize,
|
|
78
|
+
onClick: onAttachmentClick,
|
|
79
|
+
title: iconTitle
|
|
80
|
+
}, inputEl));
|
|
81
|
+
}
|
|
82
|
+
AttachmentHandler.propTypes = attachmentHandlerPropTypes;
|
|
83
|
+
AttachmentHandler.defaultProps = attachmentHandlerDefaultProps;
|
|
84
|
+
AttachmentHandler.displayName = 'AttachmentHandler';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** ** Styles *** */
|
|
2
|
+
|
|
3
|
+
.attachmentHandler {
|
|
4
|
+
/** ** Use this class for css customisation *** */
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
[dir=ltr] .iconButton {
|
|
8
|
+
margin-right: var(--zd_size5) ;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[dir=rtl] .iconButton {
|
|
12
|
+
margin-left: var(--zd_size5) ;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.icon {
|
|
16
|
+
color: initial;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttachmentHandler } from "./AttachmentHandler";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** ** Constants *** */
|
|
2
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
3
|
+
const attachmentHandlerDefaultProps = {
|
|
4
|
+
customStyle: dummyObject,
|
|
5
|
+
iconName: 'ZD-TT-image',
|
|
6
|
+
iconSize: '14',
|
|
7
|
+
iconTitle: 'Upload',
|
|
8
|
+
isMultiAttachment: false
|
|
9
|
+
};
|
|
10
|
+
export default attachmentHandlerDefaultProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const attachmentHandlerPropTypes = {
|
|
4
|
+
customStyle: PropTypes.object,
|
|
5
|
+
iconName: PropTypes.string.isRequired,
|
|
6
|
+
iconSize: PropTypes.number,
|
|
7
|
+
iconTitle: PropTypes.string,
|
|
8
|
+
renderCustomIcon: PropTypes.func,
|
|
9
|
+
getRef: PropTypes.func,
|
|
10
|
+
supportedFileTypes: PropTypes.string,
|
|
11
|
+
isMultiAttachment: PropTypes.bool,
|
|
12
|
+
onAttach: PropTypes.func.isRequired,
|
|
13
|
+
customProps: PropTypes.shape({
|
|
14
|
+
inputProps: PropTypes.object
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
export default attachmentHandlerPropTypes;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
|
|
3
|
+
/** ** Libraries *** */
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
|
+
/** ** Components *** */
|
|
6
|
+
|
|
7
|
+
import { Container, Box } from '@zohodesk/components/es/Layout';
|
|
8
|
+
import AttachmentPreviewHeader from "../AttachmentPreviewHeader/AttachmentPreviewHeader";
|
|
9
|
+
import AttachmentPreviewBody from "../AttachmentPreviewBody/AttachmentPreviewBody";
|
|
10
|
+
/** ** Hooks *** */
|
|
11
|
+
|
|
12
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
13
|
+
import useAttachmentPreview from '@zohoim/chat-components-hooks/es/AttachmentPreview/useAttachmentPreview';
|
|
14
|
+
import useAttachmentPreviewEditor from '@zohoim/chat-components-hooks/es/AttachmentPreview/useAttachmentPreviewEditor';
|
|
15
|
+
/** ** Constants *** */
|
|
16
|
+
|
|
17
|
+
import attachmentPreviewDefaultProps from "./props/defaultProps";
|
|
18
|
+
import attachmentPreviewPropTypes from "./props/propTypes";
|
|
19
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
20
|
+
import { mediaTypes } from '@zohoim/chat-components-utils/es/constants/messageConstants';
|
|
21
|
+
/** ** Styles *** */
|
|
22
|
+
|
|
23
|
+
import style from "./css/AttachmentPreview.module.css";
|
|
24
|
+
const {
|
|
25
|
+
IMAGE
|
|
26
|
+
} = mediaTypes;
|
|
27
|
+
export default function AttachmentPreview(props) {
|
|
28
|
+
const {
|
|
29
|
+
customStyle,
|
|
30
|
+
isDescriptionNeeded,
|
|
31
|
+
files,
|
|
32
|
+
customProps,
|
|
33
|
+
onSubmit,
|
|
34
|
+
onCancel,
|
|
35
|
+
texts,
|
|
36
|
+
descriptionDetails,
|
|
37
|
+
onDescriptionChange: propOnDescriptionChange,
|
|
38
|
+
needCloseOnEscape
|
|
39
|
+
} = props;
|
|
40
|
+
const {
|
|
41
|
+
editorProps = dummyObject,
|
|
42
|
+
attachmentPreviewHeaderProps = dummyObject,
|
|
43
|
+
attachmentPreviewBodyProps = dummyObject
|
|
44
|
+
} = customProps || dummyObject;
|
|
45
|
+
const {
|
|
46
|
+
submitText = 'Submit',
|
|
47
|
+
cancelText = 'Cancel',
|
|
48
|
+
placeHolder = 'Add a description for the image'
|
|
49
|
+
} = texts || dummyObject;
|
|
50
|
+
/* External customization */
|
|
51
|
+
|
|
52
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
53
|
+
const {
|
|
54
|
+
selectedFile,
|
|
55
|
+
isShow,
|
|
56
|
+
description,
|
|
57
|
+
onDescriptionChange,
|
|
58
|
+
onEscape
|
|
59
|
+
} = useAttachmentPreview({
|
|
60
|
+
files,
|
|
61
|
+
onDescriptionChange: propOnDescriptionChange,
|
|
62
|
+
descriptionDetails,
|
|
63
|
+
needCloseOnEscape,
|
|
64
|
+
onCancel
|
|
65
|
+
});
|
|
66
|
+
const {
|
|
67
|
+
onEditorKeyDown
|
|
68
|
+
} = useAttachmentPreviewEditor({
|
|
69
|
+
editorProps,
|
|
70
|
+
onPreviewPopupKeyDown: onEscape
|
|
71
|
+
});
|
|
72
|
+
const {
|
|
73
|
+
fileName,
|
|
74
|
+
formattedFileSize: fileSize,
|
|
75
|
+
attachmentURL,
|
|
76
|
+
fileFormat,
|
|
77
|
+
mediaType,
|
|
78
|
+
attachmentId
|
|
79
|
+
} = selectedFile;
|
|
80
|
+
const isImageFile = useMemo(() => mediaType === IMAGE, [mediaType]);
|
|
81
|
+
return isShow ? /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: newStyle.attachmentPreview
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
84
|
+
align: "both",
|
|
85
|
+
alignBox: "column"
|
|
86
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: `${newStyle.uploadPrev} ${newStyle.container}`
|
|
88
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AttachmentPreviewHeader, {
|
|
89
|
+
cancelText: cancelText,
|
|
90
|
+
fileName: fileName,
|
|
91
|
+
fileSize: fileSize,
|
|
92
|
+
onCancel: onCancel,
|
|
93
|
+
onSubmit: onSubmit,
|
|
94
|
+
submitText: submitText,
|
|
95
|
+
...attachmentPreviewHeaderProps
|
|
96
|
+
})), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AttachmentPreviewBody, {
|
|
97
|
+
attachmentId: attachmentId,
|
|
98
|
+
attachmentURL: attachmentURL,
|
|
99
|
+
description: description,
|
|
100
|
+
editorProps: editorProps,
|
|
101
|
+
fileFormat: fileFormat,
|
|
102
|
+
isDescriptionNeeded: isDescriptionNeeded,
|
|
103
|
+
isImageFile: isImageFile,
|
|
104
|
+
mediaType: mediaType,
|
|
105
|
+
onDescriptionChange: onDescriptionChange,
|
|
106
|
+
onEditorKeyDown: onEditorKeyDown,
|
|
107
|
+
placeHolder: placeHolder,
|
|
108
|
+
...attachmentPreviewBodyProps
|
|
109
|
+
}))))) : null;
|
|
110
|
+
}
|
|
111
|
+
AttachmentPreview.propTypes = attachmentPreviewPropTypes;
|
|
112
|
+
AttachmentPreview.defaultProps = attachmentPreviewDefaultProps;
|
|
113
|
+
AttachmentPreview.displayName = 'AttachmentPreview';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** ** Styles *** */
|
|
2
|
+
.attachmentPreview {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0 ;
|
|
5
|
+
bottom: 0 ;
|
|
6
|
+
/* z-index: 9999; */
|
|
7
|
+
z-index: 2147483643;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
background-color: rgba(42, 45, 54, 0.94);
|
|
10
|
+
}
|
|
11
|
+
[dir=ltr] .attachmentPreview {
|
|
12
|
+
animation: scaleIn 0.3s ease;
|
|
13
|
+
right: 0 ;
|
|
14
|
+
left: 0 ;
|
|
15
|
+
}
|
|
16
|
+
[dir=rtl] .attachmentPreview {
|
|
17
|
+
animation: scaleIn 0.3s ease;
|
|
18
|
+
left: 0 ;
|
|
19
|
+
right: 0 ;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.container {
|
|
23
|
+
position: relative;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.uploadPrev {
|
|
27
|
+
width: 100% ;
|
|
28
|
+
max-width: 43.75rem;
|
|
29
|
+
background-color: #fff;
|
|
30
|
+
border-radius: 5px;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttachmentPreview } from "./AttachmentPreview";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const attachmentPreviewPropTypes = {
|
|
4
|
+
customStyle: PropTypes.object,
|
|
5
|
+
isDescriptionNeeded: PropTypes.bool,
|
|
6
|
+
files: PropTypes.arrayOf(PropTypes.shape({
|
|
7
|
+
id: PropTypes.string,
|
|
8
|
+
name: PropTypes.string,
|
|
9
|
+
size: PropTypes.string,
|
|
10
|
+
type: PropTypes.string,
|
|
11
|
+
url: PropTypes.string
|
|
12
|
+
})).isRequired,
|
|
13
|
+
customProps: PropTypes.shape({
|
|
14
|
+
attachmentIconProps: PropTypes.object,
|
|
15
|
+
cancelButtonProps: PropTypes.object,
|
|
16
|
+
editorProps: PropTypes.object,
|
|
17
|
+
submitButtonProps: PropTypes.object
|
|
18
|
+
}),
|
|
19
|
+
onSubmit: PropTypes.func,
|
|
20
|
+
onCancel: PropTypes.func,
|
|
21
|
+
texts: PropTypes.shape({
|
|
22
|
+
cancelText: PropTypes.string,
|
|
23
|
+
editText: PropTypes.string,
|
|
24
|
+
placeHolder: PropTypes.string,
|
|
25
|
+
submitText: PropTypes.string
|
|
26
|
+
}).isRequired,
|
|
27
|
+
descriptionDetails: PropTypes.object,
|
|
28
|
+
onDescriptionChange: PropTypes.func,
|
|
29
|
+
needCloseOnEscape: PropTypes.bool
|
|
30
|
+
};
|
|
31
|
+
export default attachmentPreviewPropTypes;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
/** ** Components *** */
|
|
4
|
+
|
|
5
|
+
import { Container } from '@zohodesk/components/es/Layout';
|
|
6
|
+
import Editor from "../rte/Editor/Editor";
|
|
7
|
+
import AttachmentIcon from "../AttachmentIcon/AttachmentIcon";
|
|
8
|
+
/** ** Hooks *** */
|
|
9
|
+
|
|
10
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
11
|
+
/** ** Constants *** */
|
|
12
|
+
|
|
13
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
14
|
+
import attachmentPreviewBodyDefaultProps from "./props/defaultProps";
|
|
15
|
+
import attachmentPreviewBodyPropTypes from "./props/propTypes";
|
|
16
|
+
/** ** Styles *** */
|
|
17
|
+
|
|
18
|
+
import style from "./css/AttachmentPreviewBody.module.css";
|
|
19
|
+
export default function AttachmentPreviewBody(props) {
|
|
20
|
+
const {
|
|
21
|
+
customStyle,
|
|
22
|
+
customProps,
|
|
23
|
+
isImageFile,
|
|
24
|
+
attachmentURL,
|
|
25
|
+
fileFormat,
|
|
26
|
+
mediaType,
|
|
27
|
+
isDescriptionNeeded,
|
|
28
|
+
description,
|
|
29
|
+
attachmentId,
|
|
30
|
+
onDescriptionChange,
|
|
31
|
+
onEditorKeyDown,
|
|
32
|
+
placeHolder,
|
|
33
|
+
editorProps
|
|
34
|
+
} = props;
|
|
35
|
+
const {
|
|
36
|
+
attachmentIconProps = dummyObject
|
|
37
|
+
} = customProps || {};
|
|
38
|
+
/* External customization */
|
|
39
|
+
|
|
40
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
41
|
+
const iconCustomStyle = useMemo(() => ({
|
|
42
|
+
icon: newStyle.attachmentIcon
|
|
43
|
+
}), [newStyle.attachmentIcon]);
|
|
44
|
+
const editorCustomStyle = useMemo(() => ({
|
|
45
|
+
editorWrapper: newStyle.editorWrapper,
|
|
46
|
+
editableDiv: newStyle.editableDiv
|
|
47
|
+
}), [newStyle.editorWrapper, newStyle.editableDiv]);
|
|
48
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
49
|
+
align: "both",
|
|
50
|
+
alignBox: "column",
|
|
51
|
+
className: `${newStyle.zoomContent} ${newStyle.imgContent}`
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: newStyle.fileContainer
|
|
54
|
+
}, isImageFile ? /*#__PURE__*/React.createElement("img", {
|
|
55
|
+
alt: "",
|
|
56
|
+
className: newStyle.imgZoomOut,
|
|
57
|
+
src: attachmentURL
|
|
58
|
+
}) : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(AttachmentIcon, {
|
|
59
|
+
customStyle: iconCustomStyle,
|
|
60
|
+
fileFormat: fileFormat,
|
|
61
|
+
mediaType: mediaType,
|
|
62
|
+
...attachmentIconProps
|
|
63
|
+
}))), isDescriptionNeeded ? /*#__PURE__*/React.createElement(Editor, {
|
|
64
|
+
content: description,
|
|
65
|
+
customStyle: editorCustomStyle,
|
|
66
|
+
id: `${attachmentId}_Attach_Editor`,
|
|
67
|
+
needAutoFocus: true,
|
|
68
|
+
onChange: onDescriptionChange,
|
|
69
|
+
onKeyDown: onEditorKeyDown,
|
|
70
|
+
placeHolder: placeHolder,
|
|
71
|
+
...editorProps
|
|
72
|
+
}) : null);
|
|
73
|
+
}
|
|
74
|
+
AttachmentPreviewBody.propTypes = attachmentPreviewBodyPropTypes;
|
|
75
|
+
AttachmentPreviewBody.defaultProps = attachmentPreviewBodyDefaultProps;
|
|
76
|
+
AttachmentPreviewBody.displayName = 'AttachmentPreviewBody';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** ** Styles *** */
|
|
2
|
+
.attachmentIcon {
|
|
3
|
+
width: var(--zd_size60) !important;
|
|
4
|
+
height: var(--zd_size60) !important;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.editorWrapper {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
height: 100% ;
|
|
11
|
+
width: 100% ;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.editableDiv {
|
|
15
|
+
min-height: var(--zd_size48) !important;
|
|
16
|
+
background-color: transparent !important;
|
|
17
|
+
border: 0 !important;
|
|
18
|
+
border-bottom: 1px solid rgb(211, 223, 215) !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.editableDiv:hover {
|
|
22
|
+
border-color: rgb(120, 129, 144) !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.editableDiv:focus {
|
|
26
|
+
border-color: rgb(38, 169, 66) !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.imgContent,
|
|
30
|
+
.zoomContent {
|
|
31
|
+
overflow: auto;
|
|
32
|
+
position: relative;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.imgContent, .zoomContent {
|
|
37
|
+
background: var(--zd_im_chat_attachment_preview_bg);
|
|
38
|
+
background-color: #f5f6f7;
|
|
39
|
+
padding: var(--zd_size40);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[dir=ltr] .imgContent, [dir=ltr] .zoomContent {
|
|
43
|
+
border-bottom-left-radius: var(--zd_size5);
|
|
44
|
+
border-bottom-right-radius: var(--zd_size5);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[dir=rtl] .imgContent, [dir=rtl] .zoomContent {
|
|
48
|
+
border-bottom-right-radius: var(--zd_size5);
|
|
49
|
+
border-bottom-left-radius: var(--zd_size5);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.fileContainer {
|
|
53
|
+
height: var(--zd_size225);
|
|
54
|
+
composes: dflex from '~@zohodesk/components/es/common/common.module.css';
|
|
55
|
+
composes: alignVertical from '~@zohodesk/components/es/common/common.module.css';
|
|
56
|
+
composes: alignHorizontal from '~@zohodesk/components/es/common/common.module.css';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.imgZoomOut {
|
|
60
|
+
width: auto ;
|
|
61
|
+
max-width: 100% ;
|
|
62
|
+
max-height: 100% ;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AttachmentPreviewBody } from "./AttachmentPreviewBody";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const attachmentPreviewBodyPropTypes = {
|
|
4
|
+
customStyle: PropTypes.object,
|
|
5
|
+
customProps: PropTypes.shape({
|
|
6
|
+
attachmentIconProps: PropTypes.object
|
|
7
|
+
}),
|
|
8
|
+
isImageFile: PropTypes.bool,
|
|
9
|
+
attachmentURL: PropTypes.string,
|
|
10
|
+
fileFormat: PropTypes.string,
|
|
11
|
+
mediaType: PropTypes.string,
|
|
12
|
+
isDescriptionNeeded: PropTypes.bool,
|
|
13
|
+
description: PropTypes.string,
|
|
14
|
+
attachmentId: PropTypes.string,
|
|
15
|
+
onDescriptionChange: PropTypes.func,
|
|
16
|
+
onEditorKeyDown: PropTypes.func,
|
|
17
|
+
placeHolder: PropTypes.string,
|
|
18
|
+
editorProps: PropTypes.object
|
|
19
|
+
};
|
|
20
|
+
export default attachmentPreviewBodyPropTypes;
|