@cometchat/chat-uikit-react-native 4.0.0 → 4.0.2

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.
Files changed (134) hide show
  1. package/LICENSE.md +3 -0
  2. package/README.md +1 -1
  3. package/android/src/main/java/com/reactnativecometchatuikit/{RNSoundModule.java → CometChatSoundModule.java} +22 -22
  4. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -1
  5. package/ios/{RNSound.h → CometChatSoundModule.h} +1 -1
  6. package/ios/{RNSound.m → CometChatSoundModule.m} +2 -2
  7. package/package.json +3 -3
  8. package/src/AI/AIConversationStarter/AIConversationStarter.ts +33 -0
  9. package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +231 -0
  10. package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +8 -0
  11. package/src/AI/AIConversationStarter/configuration.ts +18 -0
  12. package/src/AI/AIConversationStarter/style.ts +76 -0
  13. package/src/AI/AIEnabler.ts +115 -0
  14. package/src/AI/AIEnablerDecorator.tsx +324 -0
  15. package/src/AI/AIExtensionDataSource.ts +12 -0
  16. package/src/AI/AISmartReplies/AISmartReplies.ts +28 -0
  17. package/src/AI/AISmartReplies/AISmartRepliesDecorator.ts +18 -0
  18. package/src/AI/AISmartReplies/AISmartRepliesStyle.ts +16 -0
  19. package/src/AI/AISmartReplies/configuration.ts +17 -0
  20. package/src/AI/CardView.tsx +81 -0
  21. package/src/AI/CardViewStyle.ts +37 -0
  22. package/src/AI/configuration.ts +17 -0
  23. package/src/AI/resources/ai-empty.png +0 -0
  24. package/src/AI/resources/ai-error.png +0 -0
  25. package/src/AI/resources/ai.png +0 -0
  26. package/src/AI/resources/index.ts +11 -0
  27. package/src/AI/resources/spineer.png +0 -0
  28. package/src/AI/style.ts +177 -0
  29. package/src/AI/utils.ts +39 -0
  30. package/src/CometChatConversations/CometChatConversations.tsx +56 -46
  31. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +13 -4
  32. package/src/CometChatMessageHeader/listners.ts +5 -4
  33. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +35 -35
  34. package/src/CometChatMessageList/CometChatMessageList.tsx +274 -158
  35. package/src/CometChatMessages/CometChatMessages.tsx +4 -3
  36. package/src/CometChatTabs/CometChatTabs.tsx +1 -1
  37. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +4 -10
  38. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
  39. package/src/index.ts +61 -4
  40. package/src/shared/CometChatUiKit/CometChatUIKit.ts +108 -7
  41. package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
  42. package/src/shared/constants/UIKitConstants.ts +81 -47
  43. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +46 -0
  44. package/src/shared/events/CometChatUIEventHandler/Listener.ts +66 -3
  45. package/src/shared/events/CometChatUIEvents.ts +1 -0
  46. package/src/shared/events/ListenerInitializer.ts +73 -0
  47. package/src/shared/events/messages.ts +14 -0
  48. package/src/shared/framework/DataSource.ts +12 -1
  49. package/src/shared/framework/DataSourceDecorator.tsx +37 -2
  50. package/src/shared/framework/MessageDataSource.tsx +85 -5
  51. package/src/shared/index.ts +44 -0
  52. package/src/shared/modals/InteractiveData/InteractiveActions/APIAction.ts +118 -0
  53. package/src/shared/modals/InteractiveData/InteractiveActions/CustomAction.ts +19 -0
  54. package/src/shared/modals/InteractiveData/InteractiveActions/URLNavigationAction.ts +34 -0
  55. package/src/shared/modals/InteractiveData/InteractiveActions/index.ts +3 -0
  56. package/src/shared/modals/InteractiveData/InteractiveData/InteractiveCardData.ts +69 -0
  57. package/src/shared/modals/InteractiveData/InteractiveData/InteractiveFormData.ts +119 -0
  58. package/src/shared/modals/InteractiveData/InteractiveData/index.ts +2 -0
  59. package/src/shared/modals/InteractiveData/InteractiveElements/BaseInputElement.ts +102 -0
  60. package/src/shared/modals/InteractiveData/InteractiveElements/BaseInteractiveElement.ts +45 -0
  61. package/src/shared/modals/InteractiveData/InteractiveElements/ButtonElement.ts +61 -0
  62. package/src/shared/modals/InteractiveData/InteractiveElements/CheckboxElement.ts +75 -0
  63. package/src/shared/modals/InteractiveData/InteractiveElements/DropdownElement.ts +83 -0
  64. package/src/shared/modals/InteractiveData/InteractiveElements/LabelElement.ts +32 -0
  65. package/src/shared/modals/InteractiveData/InteractiveElements/OptionElement.ts +39 -0
  66. package/src/shared/modals/InteractiveData/InteractiveElements/RadioButtonElement.ts +76 -0
  67. package/src/shared/modals/InteractiveData/InteractiveElements/SingleSelectElement.ts +76 -0
  68. package/src/shared/modals/InteractiveData/InteractiveElements/TextInputElement.ts +101 -0
  69. package/src/shared/modals/InteractiveData/InteractiveElements/index.ts +10 -0
  70. package/src/shared/modals/InteractiveData/InteractiveEntities/ActionEntity.ts +41 -0
  71. package/src/shared/modals/InteractiveData/InteractiveEntities/ElementEntity.ts +64 -0
  72. package/src/shared/modals/InteractiveData/InteractiveEntities/index.ts +2 -0
  73. package/src/shared/modals/InteractiveData/InteractiveMessage/CardMessage.ts +142 -0
  74. package/src/shared/modals/InteractiveData/InteractiveMessage/CustomInteractiveMessage.ts +38 -0
  75. package/src/shared/modals/InteractiveData/InteractiveMessage/FormMessage.ts +152 -0
  76. package/src/shared/modals/InteractiveData/InteractiveMessage/index.ts +3 -0
  77. package/src/shared/modals/InteractiveData/index.ts +28 -0
  78. package/src/shared/modals/index.ts +19 -0
  79. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +8 -1
  80. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +8 -1
  81. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +8 -1
  82. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +8 -1
  83. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +8 -1
  84. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +8 -1
  85. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +8 -1
  86. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +8 -1
  87. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +8 -1
  88. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +8 -1
  89. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +8 -1
  90. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +8 -1
  91. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +8 -1
  92. package/src/shared/resources/CometChatSoundManager/CometChatSoundManager.js +2 -2
  93. package/src/shared/resources/CometChatSoundManager/sound.js +35 -35
  94. package/src/shared/utils/InteractiveMessageUtils.ts +20 -0
  95. package/src/shared/utils/NetworkUtils.tsx +20 -0
  96. package/src/shared/utils/conversationUtils.ts +9 -6
  97. package/src/shared/views/CometChatButton/CometChatButton.tsx +32 -22
  98. package/src/shared/views/CometChatCardBubble/CardBubbleStyle.tsx +47 -0
  99. package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +173 -0
  100. package/src/shared/views/CometChatCardBubble/index.tsx +1 -0
  101. package/src/shared/views/CometChatCheckBox/CheckBoxStyle.tsx +43 -0
  102. package/src/shared/views/CometChatCheckBox/CometChatCheckBox.tsx +79 -0
  103. package/src/shared/views/CometChatDate/CometChatDate.tsx +2 -3
  104. package/src/shared/views/CometChatDropDown/CometChatDropDown.tsx +126 -0
  105. package/src/shared/views/CometChatDropDown/DropDownStyle.tsx +39 -0
  106. package/src/shared/views/CometChatDropDown/resources/downArrowIcon.png +0 -0
  107. package/src/shared/views/CometChatDropDown/resources/index.js +5 -0
  108. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +464 -0
  109. package/src/shared/views/CometChatFormBubble/FormBubbleStyle.tsx +91 -0
  110. package/src/shared/views/CometChatFormBubble/index.tsx +1 -0
  111. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +13 -5
  112. package/src/shared/views/CometChatImageBubble/ImageBubbleStyle.ts +14 -3
  113. package/src/shared/views/CometChatLabel/CometChatLabel.tsx +27 -0
  114. package/src/shared/views/CometChatLabel/LabelStyle.ts +19 -0
  115. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +5 -4
  116. package/src/shared/views/CometChatQuickView/CometChatQuickView.tsx +66 -0
  117. package/src/shared/views/CometChatQuickView/QuickViewStyle.ts +55 -0
  118. package/src/shared/views/CometChatRadioButton/CometChatRadioButton.tsx +67 -0
  119. package/src/shared/views/CometChatRadioButton/RadioButtonStyle.tsx +38 -0
  120. package/src/shared/views/CometChatSingleSelect/CometChatSingleSelect.tsx +63 -0
  121. package/src/shared/views/CometChatSingleSelect/SingleStyle.tsx +35 -0
  122. package/src/shared/views/CometChatTextInput/CometChatTextInput.tsx +67 -0
  123. package/src/shared/views/CometChatTextInput/TextInputStyle.tsx +26 -0
  124. package/src/shared/views/index.ts +7 -1
  125. package/LICENSE +0 -21
  126. package/android/.idea/.gitignore +0 -3
  127. package/android/local.properties +0 -8
  128. package/src/.DS_Store +0 -0
  129. package/src/CometChatMessageInformation/.DS_Store +0 -0
  130. package/src/calls/CometChatCallHistory/.DS_Store +0 -0
  131. package/src/shared/framework/.DS_Store +0 -0
  132. package/src/shared/views/.DS_Store +0 -0
  133. package/src/shared/views/CometChatAudioBubble/.DS_Store +0 -0
  134. package/src/shared/views/CometChatFileBubble/.DS_Store +0 -0
@@ -0,0 +1,79 @@
1
+ import { View, Text, TouchableOpacity, Image } from 'react-native'
2
+ import React, { useContext } from 'react'
3
+ import { CheckboxElement, OptionElement } from '../../modals/InteractiveData'
4
+ import { ICONS } from '../../assets/images';
5
+ import { CometChatContextType } from '../../base';
6
+ import { CometChatContext } from '../../CometChatContext';
7
+ import { CheckBoxStyle, CheckBoxStyleInterface } from './CheckBoxStyle';
8
+
9
+ export interface CometChatCheckBoxInterface {
10
+ onChange?: (option: OptionElement) => void,
11
+ data: CheckboxElement,
12
+ showError: boolean,
13
+ selectedOptions: string[],
14
+ style?: CheckBoxStyleInterface,
15
+ }
16
+
17
+ const CometChatCheckBox = (props: CometChatCheckBoxInterface) => {
18
+ const { onChange, data, showError, selectedOptions, style } = props;
19
+
20
+ const { theme } = useContext<CometChatContextType>(CometChatContext);
21
+ const _style = new CheckBoxStyle({
22
+ activeBackgroundColor: theme.palette.getPrimary(),
23
+ inactiveBackgroundColor: theme.palette.getBackgroundColor(),
24
+ titleFont: theme.typography.subtitle1,
25
+ border: { borderWidth: 1, borderColor: theme.palette.getAccent200() },
26
+ checkboxTintColor: theme.palette.getBackgroundColor(),
27
+ titleColor: theme.palette.getAccent(),
28
+ optionColor: theme.palette.getAccent(),
29
+ optionFont: theme.typography.subtitle1,
30
+ ...style,
31
+ });
32
+
33
+ const {
34
+ activeBackgroundColor,
35
+ checkboxTintColor,
36
+ inactiveBackgroundColor,
37
+ optionColor,
38
+ optionFont,
39
+ titleColor,
40
+ titleFont,
41
+ border,
42
+ } = _style;
43
+
44
+ function _checkSelectedOption(option: OptionElement) {
45
+ return selectedOptions.find((selectedOption) => selectedOption === option.getValue()) ? true : false;
46
+ }
47
+ return (
48
+ <View style={{ marginVertical: 10 }}>
49
+
50
+ <Text style={[titleFont, { color: titleColor }]}>{data.getLabel()}{!data.getOptional() && "*"}</Text>
51
+
52
+ {data.getOptions().map((option, index) => (
53
+ <View key={index} style={{ flexDirection: "row", alignItems: "center", marginTop: 3 }}>
54
+ <TouchableOpacity style={{
55
+ height: 20, width: 20, backgroundColor: _checkSelectedOption(option) ? activeBackgroundColor : inactiveBackgroundColor,
56
+ borderRadius: 5, marginRight: 5, alignItems: "center", justifyContent: "center",
57
+ borderColor: showError ? theme.palette.getError() : border.borderColor,
58
+ borderWidth: border.borderWidth,
59
+ }}
60
+ onPress={() => onChange(option)}
61
+ >
62
+ {_checkSelectedOption(option) && <Image
63
+ style={{
64
+ height: 15,
65
+ width: 15,
66
+ tintColor: checkboxTintColor,
67
+ }}
68
+ source={ICONS.CHECK_MARK}
69
+ />}
70
+ </TouchableOpacity>
71
+ <Text style={[optionFont, { color: optionColor }]}>{option.getLabel()}</Text>
72
+ </View>
73
+ ))}
74
+
75
+ </View>
76
+ )
77
+ }
78
+
79
+ export default CometChatCheckBox
@@ -108,9 +108,8 @@ export const CometChatDate = (props: CometChatDateInterface) => {
108
108
 
109
109
  const getTimeFormat = () => {
110
110
  let timeString = date.getHours();
111
- let postString = 'AM';
112
- if (timeString >= 12) {
113
- postString = 'PM';
111
+ let postString = timeString >= 12 ? 'PM' : 'AM';
112
+ if (timeString > 12) {
114
113
  timeString = timeString - 12;
115
114
  }
116
115
  let minutes: any = date.getMinutes();
@@ -0,0 +1,126 @@
1
+ import React, { useState, useContext, useEffect } from 'react';
2
+ import { View, Text, TouchableOpacity, StyleSheet, Image, ScrollView } from 'react-native';
3
+ import { DownArrow } from './resources';
4
+ import { CometChatContextType } from '../../base';
5
+ import { CometChatContext } from '../../CometChatContext';
6
+ import { DropDownStyle, DropDownStyleInterface } from './DropDownStyle';
7
+
8
+ export interface CometChatButtonInterface {
9
+ options: any[],
10
+ arrowIconURL?: string,
11
+ dropdownStyle?: object,
12
+ onOptionChange?: any,
13
+ selectedOption?: any,
14
+ data: any,
15
+ showError: boolean,
16
+ style?: DropDownStyleInterface
17
+ }
18
+
19
+ const CometChatDropdown = (props: CometChatButtonInterface) => {
20
+ const { options,
21
+ arrowIconURL = DownArrow,
22
+ dropdownStyle = {},
23
+ onOptionChange,
24
+ selectedOption, data, showError, style } = props;
25
+ const { theme } = useContext<CometChatContextType>(CometChatContext);
26
+
27
+ const _style = new DropDownStyle({
28
+ activeBackgroundColor: theme.palette.getPrimary(),
29
+ inactiveBackgroundColor: theme.palette.getBackgroundColor(),
30
+ border: { borderWidth: 1, borderColor: theme.palette.getAccent200() },
31
+ titleFont: theme.typography.subtitle1,
32
+ optionColor: theme.palette.getAccent(),
33
+ titleColor: theme.palette.getAccent(),
34
+ ...style,
35
+ });
36
+
37
+ const {
38
+ activeBackgroundColor,
39
+ inactiveBackgroundColor,
40
+ optionColor,
41
+ optionFont,
42
+ titleColor,
43
+ titleFont,
44
+ border,
45
+ } = _style;
46
+
47
+ const [openDropdown, setOpenDropdown] = useState(false);
48
+ const [currentOption, setCurrentOption] = useState({ label: selectedOption || "Select an option" });
49
+
50
+ useEffect(() => {
51
+ if (!selectedOption) return;
52
+ let selectedObj = options.find((option) => option.value === selectedOption);
53
+ selectedObj && setCurrentOption(selectedObj);
54
+ }, [selectedOption])
55
+
56
+ const onDropDownToggle = () => {
57
+ setOpenDropdown(!openDropdown);
58
+ };
59
+
60
+ const onOptionSelect = option => {
61
+ setCurrentOption(option);
62
+ onOptionChange && onOptionChange(option); // Assuming that onOptionChange function is passed as a prop
63
+ onDropDownToggle();
64
+ };
65
+
66
+ return (
67
+ <View style={{ ...styles.defaultDropdownStyle, ...dropdownStyle }}>
68
+ <Text style={[titleFont, { color: titleColor }]}>{data.getLabel()}{!data.getOptional() && "*"}</Text>
69
+
70
+ <View style={{ position: "relative" }}>
71
+ <TouchableOpacity onPress={onDropDownToggle} style={[styles.dropdownButton, { borderColor: showError ? theme.palette.getError() : border.borderColor, borderWidth: border.borderWidth }]}>
72
+ <Text style={[optionFont, { color: optionColor }]}>{currentOption.label}</Text>
73
+ {/* Display arrow icon */}
74
+ {arrowIconURL && <Image source={arrowIconURL} style={[styles.dropdownArrow, openDropdown && { transform: [{ rotate: '180deg' }] }]} />}
75
+ </TouchableOpacity>
76
+
77
+ {openDropdown && (
78
+ <ScrollView style={[styles.dropdownOptions, { borderColor: border.borderColor, borderWidth: border.borderWidth, backgroundColor: inactiveBackgroundColor }]}>
79
+ {options.map((option, index) => (
80
+ <TouchableOpacity
81
+ activeOpacity={1}
82
+ style={{
83
+ backgroundColor: currentOption.label === option.label ? activeBackgroundColor : inactiveBackgroundColor,
84
+ height: 35,
85
+ justifyContent: "center", paddingHorizontal: 8
86
+ }}
87
+ key={index} onPress={() => onOptionSelect(option)}>
88
+ <Text style={[optionFont, { color: optionColor }]}>{option.label}</Text>
89
+ </TouchableOpacity>
90
+ ))}
91
+ </ScrollView>
92
+ )}
93
+ </View>
94
+
95
+ </View>
96
+ );
97
+ };
98
+
99
+ const styles = StyleSheet.create({
100
+ defaultDropdownStyle: {
101
+ // position: "relative",
102
+ zIndex: 1,
103
+ marginVertical: 10,
104
+ // Your default dropdown style here
105
+ },
106
+ dropdownButton: {
107
+ borderWidth: 1, flexDirection: "row",
108
+ justifyContent: "space-between", height: 35,
109
+ alignItems: "center", paddingHorizontal: 8, marginTop: 5,
110
+ // Your dropdown button style here
111
+ },
112
+ dropdownArrow: {
113
+ height: 15, width: 15,
114
+ // Your dropdown arrow style here
115
+ },
116
+ dropdownOptions: {
117
+ maxHeight: 150,
118
+ position: "absolute",
119
+ top: 40, width: "100%",
120
+ borderWidth: 1,
121
+ borderTopWidth: 0,
122
+ // Your dropdown options style here
123
+ },
124
+ });
125
+
126
+ export default CometChatDropdown;
@@ -0,0 +1,39 @@
1
+ import { BorderStyle, BorderStyleInterface, FontStyle } from "../../base";
2
+
3
+ export interface DropDownStyleInterface {
4
+ titleFont?: FontStyle;
5
+ titleColor?: string;
6
+ border?: BorderStyleInterface;
7
+ activeBackgroundColor?: string;
8
+ inactiveBackgroundColor?: string;
9
+ optionColor?: string;
10
+ optionFont?: FontStyle;
11
+ }
12
+
13
+ export class DropDownStyle {
14
+ titleFont?: FontStyle;
15
+ titleColor?: string;
16
+ border?: BorderStyleInterface;
17
+ activeBackgroundColor?: string;
18
+ inactiveBackgroundColor?: string;
19
+ optionColor?: string;
20
+ optionFont?: FontStyle;
21
+
22
+ constructor({
23
+ titleFont = new FontStyle({}),
24
+ titleColor = "",
25
+ border = new BorderStyle({}),
26
+ activeBackgroundColor = "",
27
+ inactiveBackgroundColor = "",
28
+ optionColor = "",
29
+ optionFont = new FontStyle({}),
30
+ }: DropDownStyleInterface) {
31
+ this.titleFont = titleFont;
32
+ this.titleColor = titleColor;
33
+ this.border = border;
34
+ this.activeBackgroundColor = activeBackgroundColor;
35
+ this.inactiveBackgroundColor = inactiveBackgroundColor;
36
+ this.optionColor = optionColor;
37
+ this.optionFont = optionFont;
38
+ }
39
+ }
@@ -0,0 +1,5 @@
1
+ import DownArrow from "./downArrowIcon.png";
2
+
3
+ export {
4
+ DownArrow
5
+ }