@cometchat/chat-uikit-react-native 4.3.16 → 4.3.17

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 (388) hide show
  1. package/package.json +1 -1
  2. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +20 -15
  3. package/src/AI/AIAssistBot/AIAssistBotStyle.ts +2 -2
  4. package/src/AI/AIAssistBot/AIAssistBotView.tsx +16 -14
  5. package/src/AI/AIAssistBot/configuration.ts +8 -7
  6. package/src/AI/AIAssistBot/resources/index.ts +1 -0
  7. package/src/AI/AIBaseConfiguration.ts +1 -0
  8. package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +27 -26
  9. package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +1 -0
  10. package/src/AI/AIConversationStarter/style.ts +29 -31
  11. package/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx +14 -13
  12. package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +5 -4
  13. package/src/AI/AIConversationSummary/resources/index.ts +1 -0
  14. package/src/AI/AIExtensionDataSource.ts +1 -0
  15. package/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx +28 -27
  16. package/src/AI/AISmartReplies/configuration.ts +2 -0
  17. package/src/AI/CardView.tsx +5 -5
  18. package/src/AI/resources/index.ts +3 -0
  19. package/src/AI/style.ts +68 -80
  20. package/src/CometChatAddMembers/AddMembersConfiguration.tsx +1 -0
  21. package/src/CometChatAddMembers/CometChatAddMembers.tsx +12 -12
  22. package/src/CometChatAddMembers/index.ts +10 -8
  23. package/src/CometChatBannedMembers/BannedMembersConfiguration.tsx +1 -0
  24. package/src/CometChatBannedMembers/CometChatBannedMembers.tsx +8 -8
  25. package/src/CometChatBannedMembers/index.ts +12 -7
  26. package/src/CometChatBannedMembers/resources/index.ts +1 -0
  27. package/src/CometChatContacts/CometChatContacts.tsx +9 -9
  28. package/src/CometChatContacts/ContactsConfiguration.tsx +1 -0
  29. package/src/CometChatContacts/Header.tsx +4 -4
  30. package/src/CometChatContacts/index.ts +5 -3
  31. package/src/CometChatConversations/CometChatConversations.tsx +204 -172
  32. package/src/CometChatConversations/index.ts +21 -10
  33. package/src/CometChatConversations/resources/index.ts +14 -0
  34. package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +6 -5
  35. package/src/CometChatConversationsWithMessages/index.ts +6 -5
  36. package/src/CometChatConversationsWithMessages/resources/index.ts +1 -0
  37. package/src/CometChatCreateGroup/CometChatCreateGroup.tsx +30 -30
  38. package/src/CometChatCreateGroup/CreateGroupConfiguration.ts +1 -0
  39. package/src/CometChatCreateGroup/Header.tsx +1 -1
  40. package/src/CometChatCreateGroup/index.ts +5 -6
  41. package/src/CometChatCreateGroup/resources/index.ts +3 -0
  42. package/src/CometChatDetails/CometChatDetails.tsx +29 -28
  43. package/src/CometChatDetails/DetailsConfiguration.tsx +1 -0
  44. package/src/CometChatDetails/Header.tsx +1 -1
  45. package/src/CometChatDetails/index.ts +17 -15
  46. package/src/CometChatDetails/listners.ts +16 -16
  47. package/src/CometChatDetails/resources/index.ts +5 -0
  48. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +52 -52
  49. package/src/CometChatGroupMembers/GroupMemberConfiguration.ts +1 -1
  50. package/src/CometChatGroupMembers/GroupMemberStyle.ts +3 -3
  51. package/src/CometChatGroupMembers/index.ts +8 -16
  52. package/src/CometChatGroupMembers/resources/index.ts +5 -0
  53. package/src/CometChatGroups/CometChatGroups.tsx +46 -46
  54. package/src/CometChatGroups/GroupsConfiguration.ts +10 -9
  55. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  56. package/src/CometChatGroups/index.ts +11 -10
  57. package/src/CometChatGroups/resources/index.ts +10 -0
  58. package/src/CometChatGroupsWithMessages/CometChatGroupsWithMessages.tsx +9 -8
  59. package/src/CometChatGroupsWithMessages/index.ts +6 -5
  60. package/src/CometChatGroupsWithMessages/resources/index.ts +1 -0
  61. package/src/CometChatJoinProtectedGroup/CometChatJoinProtectedGroup.tsx +22 -21
  62. package/src/CometChatJoinProtectedGroup/Header.tsx +1 -1
  63. package/src/CometChatJoinProtectedGroup/JoinProtectedGroupConfiguration.ts +1 -0
  64. package/src/CometChatJoinProtectedGroup/index.ts +5 -6
  65. package/src/CometChatJoinProtectedGroup/resources/index.ts +2 -0
  66. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +62 -59
  67. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +1 -0
  68. package/src/CometChatMessageComposer/index.ts +6 -7
  69. package/src/CometChatMessageComposer/resources/index.ts +10 -0
  70. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +33 -31
  71. package/src/CometChatMessageHeader/MessageHeaderConfiguration.tsx +1 -0
  72. package/src/CometChatMessageHeader/index.ts +12 -13
  73. package/src/CometChatMessageHeader/listners.ts +18 -18
  74. package/src/CometChatMessageHeader/resources/index.ts +3 -0
  75. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +28 -24
  76. package/src/CometChatMessageInformation/index.ts +8 -8
  77. package/src/CometChatMessageInformation/resources/index.ts +1 -0
  78. package/src/CometChatMessageList/CometChatMessageList.tsx +214 -195
  79. package/src/CometChatMessageList/MessageListConfiguration.ts +26 -25
  80. package/src/CometChatMessageList/index.ts +16 -18
  81. package/src/CometChatMessageList/resources/index.ts +7 -0
  82. package/src/CometChatMessages/CometChatMessages.tsx +29 -26
  83. package/src/CometChatMessages/MessagesConfiguration.ts +2 -0
  84. package/src/CometChatMessages/index.ts +8 -7
  85. package/src/CometChatMessages/resources/index.ts +1 -0
  86. package/src/CometChatTabs/CometChatTabs.tsx +13 -23
  87. package/src/CometChatTabs/CometChatTabsStyle.ts +2 -0
  88. package/src/CometChatTabs/index.ts +3 -8
  89. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +37 -37
  90. package/src/CometChatThreadedMessages/Header.tsx +2 -2
  91. package/src/CometChatThreadedMessages/ThreadedMessagesConfiguration.ts +1 -0
  92. package/src/CometChatThreadedMessages/index.ts +11 -12
  93. package/src/CometChatThreadedMessages/resources/index.ts +6 -0
  94. package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +5 -5
  95. package/src/CometChatTransferOwnership/TransferOwnershipConfiguration.ts +1 -0
  96. package/src/CometChatTransferOwnership/index.ts +10 -11
  97. package/src/CometChatUsers/CometChatUsers.tsx +11 -11
  98. package/src/CometChatUsers/UsersConfiguration.tsx +1 -0
  99. package/src/CometChatUsers/index.ts +8 -6
  100. package/src/CometChatUsersWithMessages/CometChatUsersWithMessages.tsx +6 -5
  101. package/src/CometChatUsersWithMessages/index.ts +6 -5
  102. package/src/calls/CallUtils.ts +4 -3
  103. package/src/calls/CallingDetailsUtils.tsx +9 -8
  104. package/src/calls/CallingExtension.tsx +2 -2
  105. package/src/calls/CallingExtentionDecorator.tsx +17 -17
  106. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +3 -2
  107. package/src/calls/CometChatCallBubble/index.ts +14 -10
  108. package/src/calls/CometChatCallBubble/resources/index.ts +3 -0
  109. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +1 -0
  110. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +19 -18
  111. package/src/calls/CometChatCallButtons/index.ts +10 -8
  112. package/src/calls/CometChatCallButtons/resources/index.ts +2 -0
  113. package/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts +2 -0
  114. package/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx +14 -13
  115. package/src/calls/CometChatCallLogDetails/index.ts +21 -10
  116. package/src/calls/CometChatCallLogDetails/resources/index.ts +1 -0
  117. package/src/calls/CometChatCallLogHistory/CallLogHistoryConfiguration.ts +3 -1
  118. package/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx +25 -24
  119. package/src/calls/CometChatCallLogHistory/index.ts +21 -10
  120. package/src/calls/CometChatCallLogHistory/resources/index.ts +13 -0
  121. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts +4 -2
  122. package/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx +13 -12
  123. package/src/calls/CometChatCallLogParticipants/index.ts +21 -10
  124. package/src/calls/CometChatCallLogParticipants/resources/index.ts +1 -0
  125. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts +5 -3
  126. package/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx +14 -13
  127. package/src/calls/CometChatCallLogRecordings/index.ts +21 -10
  128. package/src/calls/CometChatCallLogRecordings/resources/index.ts +2 -0
  129. package/src/calls/CometChatCallLogs/CallLogsConfiguration.ts +5 -3
  130. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +37 -36
  131. package/src/calls/CometChatCallLogs/index.ts +14 -10
  132. package/src/calls/CometChatCallLogs/resources/index.ts +11 -0
  133. package/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts +1 -0
  134. package/src/calls/CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx +3 -2
  135. package/src/calls/CometChatCallLogsWithDetails/index.ts +2 -4
  136. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +19 -15
  137. package/src/calls/CometChatIncomingCall/index.ts +10 -8
  138. package/src/calls/CometChatIncomingCall/resources/index.ts +4 -0
  139. package/src/calls/CometChatIncomingCall/styles.ts +0 -1
  140. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +5 -4
  141. package/src/calls/CometChatOngoingCall/index.ts +6 -6
  142. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +15 -13
  143. package/src/calls/CometChatOutgoingCall/index.ts +8 -6
  144. package/src/calls/CometChatOutgoingCall/resources/index.ts +1 -0
  145. package/src/calls/index.ts +99 -60
  146. package/src/calls/resources/index.ts +3 -0
  147. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -0
  148. package/src/extensions/CollaborativeBubble/resources/index.ts +1 -0
  149. package/src/extensions/CollaborativeBubble/styles.ts +1 -1
  150. package/src/extensions/CollaborativeDocument/CollaborativeDocumentConfiguration.tsx +1 -1
  151. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +10 -9
  152. package/src/extensions/CollaborativeDocument/index.ts +12 -9
  153. package/src/extensions/CollaborativeDocument/resources/index.ts +2 -0
  154. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardConfiguration.tsx +1 -1
  155. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +15 -14
  156. package/src/extensions/CollaborativeWhiteboard/index.ts +12 -9
  157. package/src/extensions/CollaborativeWhiteboard/resources/index.ts +2 -0
  158. package/src/extensions/ExtensionModerator.tsx +4 -4
  159. package/src/extensions/ImageModeration/ImageModerationDecorator.tsx +1 -1
  160. package/src/extensions/ImageModeration/ImageModerationFilter.tsx +2 -1
  161. package/src/extensions/ImageModeration/index.ts +15 -7
  162. package/src/extensions/ImageModeration/resources/index.ts +1 -0
  163. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +8 -8
  164. package/src/extensions/LinkPreview/LinkPreviewExtention.tsx +1 -1
  165. package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +2 -1
  166. package/src/extensions/LinkPreview/index.ts +18 -10
  167. package/src/extensions/LinkPreview/resources/index.ts +1 -0
  168. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +7 -7
  169. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +19 -17
  170. package/src/extensions/MessageTranslation/index.ts +7 -7
  171. package/src/extensions/MessageTranslation/resources/index.ts +1 -0
  172. package/src/extensions/Polls/Header.tsx +8 -8
  173. package/src/extensions/Polls/Polls.tsx +38 -33
  174. package/src/extensions/Polls/PollsBubble.tsx +35 -33
  175. package/src/extensions/Polls/PollsDecorator.tsx +7 -7
  176. package/src/extensions/Polls/index.ts +4 -5
  177. package/src/extensions/Polls/resources/index.ts +5 -0
  178. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -11
  179. package/src/extensions/SmartReplies/SmartRepliesView.tsx +4 -3
  180. package/src/extensions/SmartReplies/index.ts +6 -2
  181. package/src/extensions/SmartReplies/resources/index.ts +1 -0
  182. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +12 -10
  183. package/src/extensions/Stickers/CometChatStickerKeyboard/StickerKeyboardConfiguration.ts +2 -1
  184. package/src/extensions/Stickers/CometChatStickerKeyboard/hooks.ts +19 -17
  185. package/src/extensions/Stickers/StickersBubble.tsx +4 -4
  186. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +11 -10
  187. package/src/extensions/Stickers/index.ts +13 -8
  188. package/src/extensions/Stickers/resources/index.ts +1 -0
  189. package/src/extensions/TextModeration/TextModerationConfiguration.tsx +1 -1
  190. package/src/extensions/TextModeration/TextModerationExtension.tsx +1 -0
  191. package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +1 -0
  192. package/src/extensions/TextModeration/index.ts +5 -4
  193. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +5 -5
  194. package/src/extensions/ThumbnailGeneration/index.ts +6 -2
  195. package/src/extensions/ThumbnailGeneration/resources/index.ts +1 -0
  196. package/src/extensions/index.ts +92 -47
  197. package/src/index.ts +225 -232
  198. package/src/shared/CometChatContext.tsx +1 -1
  199. package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -36
  200. package/src/shared/CometChatUiKit/CometChatUIKitHelper.ts +1 -0
  201. package/src/shared/assets/images/index.ts +16 -0
  202. package/src/shared/assets/images/search.png +0 -0
  203. package/src/shared/base/FontStyle.ts +2 -2
  204. package/src/shared/base/index.ts +8 -11
  205. package/src/shared/base/vars.ts +2 -2
  206. package/src/shared/constants/UIKitConstants.ts +16 -1
  207. package/src/shared/events/CometChatMessageEvents/index.ts +6 -4
  208. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +221 -219
  209. package/src/shared/events/CometChatUIEventHandler/Listener.ts +39 -37
  210. package/src/shared/events/ListenerInitializer.ts +8 -1
  211. package/src/shared/events/messages.ts +2 -0
  212. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +11 -15
  213. package/src/shared/formatters/CometChatTextFormatter.ts +6 -5
  214. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -10
  215. package/src/shared/framework/DataSource.ts +17 -17
  216. package/src/shared/framework/DataSourceDecorator.tsx +3 -2
  217. package/src/shared/framework/ExtensionsDataSource.tsx +1 -0
  218. package/src/shared/framework/MessageDataSource.tsx +125 -117
  219. package/src/shared/framework/index.ts +12 -6
  220. package/src/shared/framework/resources/index.ts +20 -0
  221. package/src/shared/helper/helperFunctions.ts +7 -5
  222. package/src/shared/index.ts +109 -100
  223. package/src/shared/libs/CometChatCalendar/Calendars/BaseCalendar.tsx +6 -3
  224. package/src/shared/libs/CometChatCalendar/Calendars/DateSelectionCalendar.tsx +2 -0
  225. package/src/shared/libs/CometChatCalendar/Calendars/MultiDateSelectionCalendar.tsx +2 -0
  226. package/src/shared/libs/CometChatCalendar/Components/Day.tsx +2 -0
  227. package/src/shared/libs/CometChatCalendar/Components/Days.tsx +1 -0
  228. package/src/shared/libs/CometChatCalendar/Components/Month.tsx +1 -0
  229. package/src/shared/libs/CometChatCalendar/Components/Months.tsx +1 -0
  230. package/src/shared/libs/CometChatCalendar/Components/Title.tsx +2 -0
  231. package/src/shared/libs/CometChatCalendar/Hooks/useSurroundingTimeUnits.ts +3 -0
  232. package/src/shared/libs/CometChatCalendar/Locales/index.ts +1 -0
  233. package/src/shared/libs/CometChatCalendar/Utils/dateRange.ts +1 -0
  234. package/src/shared/libs/CometChatCalendar/Utils/getExtraDays.ts +1 -0
  235. package/src/shared/libs/CometChatCalendar/Utils/getSurroundingTimeUnits.ts +1 -0
  236. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +45 -42
  237. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +13 -11
  238. package/src/shared/libs/ImageZoom/types/index.ts +12 -12
  239. package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +1 -0
  240. package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +1 -0
  241. package/src/shared/libs/datePickerModal/Modal.js +1 -1
  242. package/src/shared/modals/CometChatDetailsOption.ts +2 -2
  243. package/src/shared/modals/CometChatMessageTemplate.ts +13 -12
  244. package/src/shared/modals/InteractiveData/InteractiveElements/DateTimeElement.ts +7 -7
  245. package/src/shared/modals/InteractiveData/InteractiveMessage/CardMessage.ts +1 -0
  246. package/src/shared/modals/InteractiveData/InteractiveMessage/CustomInteractiveMessage.ts +1 -0
  247. package/src/shared/modals/InteractiveData/InteractiveMessage/FormMessage.ts +1 -0
  248. package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +6 -7
  249. package/src/shared/modals/index.ts +37 -14
  250. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +5 -5
  251. package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
  252. package/src/shared/resources/CometChatTheme/Palette.ts +57 -55
  253. package/src/shared/resources/CometChatTheme/Typography.ts +30 -30
  254. package/src/shared/utils/CometChatLiveReactions/CometChatLiveReaction.tsx +17 -13
  255. package/src/shared/utils/CometChatLiveReactions/resources/index.ts +1 -0
  256. package/src/shared/utils/CometChatMessageHelper/index.ts +2 -2
  257. package/src/shared/utils/CometChatMessagePreview/{index.js → index.ts} +3 -0
  258. package/src/shared/utils/CometChatMessagePreview/resources/index.ts +1 -0
  259. package/src/shared/utils/CommonUtils.ts +76 -0
  260. package/src/shared/utils/DetailsUtils/DetailsUtils.tsx +3 -2
  261. package/src/shared/utils/DetailsUtils/resources/index.ts +7 -0
  262. package/src/shared/utils/InteractiveMessageUtils.ts +6 -5
  263. package/src/shared/utils/MessageUtils.tsx +103 -15
  264. package/src/shared/utils/NetworkUtils.tsx +1 -1
  265. package/src/shared/utils/PermissionUtil.ts +7 -6
  266. package/src/shared/utils/SchedulerUtils.ts +8 -6
  267. package/src/shared/utils/TypeUtils.ts +3 -0
  268. package/src/shared/utils/conversationUtils.ts +7 -5
  269. package/src/shared/utils/index.ts +2 -0
  270. package/src/shared/views/CometChatAICard/CometChatAICard.tsx +7 -6
  271. package/src/shared/views/CometChatAICard/resources/index.ts +2 -0
  272. package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +3 -0
  273. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +5 -5
  274. package/src/shared/views/CometChatActionSheet/hooks.ts +2 -2
  275. package/src/shared/views/CometChatActionSheet/index.ts +5 -3
  276. package/src/shared/views/CometChatActionSheet/resources/index.ts +2 -0
  277. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +6 -6
  278. package/src/shared/views/CometChatAudioBubble/index.ts +8 -12
  279. package/src/shared/views/CometChatAudioBubble/resources/index.ts +2 -0
  280. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +6 -5
  281. package/src/shared/views/CometChatAvatar/index.ts +7 -9
  282. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +3 -3
  283. package/src/shared/views/CometChatBadge/index.ts +7 -9
  284. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +51 -48
  285. package/src/shared/views/CometChatBottomSheet/index.ts +6 -2
  286. package/src/shared/views/CometChatButton/CometChatButton.tsx +5 -5
  287. package/src/shared/views/CometChatButton/index.ts +4 -14
  288. package/src/shared/views/CometChatCard/CometChatCard.tsx +3 -3
  289. package/src/shared/views/CometChatCard/index.ts +6 -7
  290. package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +11 -10
  291. package/src/shared/views/CometChatCardBubble/index.tsx +2 -1
  292. package/src/shared/views/CometChatCheckBox/CometChatCheckBox.tsx +6 -6
  293. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +9 -9
  294. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialogStyle.ts +1 -0
  295. package/src/shared/views/CometChatConfirmDialog/index.ts +9 -6
  296. package/src/shared/views/CometChatDate/CometChatDate.tsx +2 -2
  297. package/src/shared/views/CometChatDate/index.ts +12 -11
  298. package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +20 -17
  299. package/src/shared/views/CometChatDateTimePicker/index.ts +3 -5
  300. package/src/shared/views/CometChatDropDown/CometChatDropDown.tsx +8 -7
  301. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +24 -33
  302. package/src/shared/views/CometChatEmojiKeyboard/Emoji.ts +1 -1
  303. package/src/shared/views/CometChatEmojiKeyboard/EmojiCategory.ts +1 -1
  304. package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +2 -1
  305. package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +2 -1
  306. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -0
  307. package/src/shared/views/CometChatEmojiKeyboard/resources/index.ts +8 -0
  308. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  309. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +3 -3
  310. package/src/shared/views/CometChatFileBubble/FileBubbleStyle.ts +1 -1
  311. package/src/shared/views/CometChatFileBubble/index.ts +7 -8
  312. package/src/shared/views/CometChatFileBubble/resources/index.ts +2 -0
  313. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +33 -29
  314. package/src/shared/views/CometChatFormBubble/index.tsx +2 -1
  315. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +63 -17
  316. package/src/shared/views/CometChatImageBubble/ImageBubbleStyle.ts +1 -1
  317. package/src/shared/views/CometChatImageBubble/assets/default_image.png +0 -0
  318. package/src/shared/views/CometChatImageBubble/assets/index.ts +3 -0
  319. package/src/shared/views/CometChatImageBubble/index.ts +10 -8
  320. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +1 -1
  321. package/src/shared/views/CometChatImageViewerModal/resources/index.ts +1 -0
  322. package/src/shared/views/CometChatLabel/CometChatLabel.tsx +2 -2
  323. package/src/shared/views/CometChatList/CometChatList.tsx +46 -42
  324. package/src/shared/views/CometChatList/index.ts +3 -3
  325. package/src/shared/views/CometChatList/resources/index.ts +5 -0
  326. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +18 -13
  327. package/src/shared/views/CometChatListItem/ListItemConfiguration.tsx +1 -0
  328. package/src/shared/views/CometChatListItem/index.ts +8 -7
  329. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +34 -31
  330. package/src/shared/views/CometChatMediaRecorder/index.ts +8 -9
  331. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +19 -12
  332. package/src/shared/views/CometChatMessageBubble/index.ts +6 -5
  333. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +10 -9
  334. package/src/shared/views/CometChatMessageInput/index.ts +2 -1
  335. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +3 -3
  336. package/src/shared/views/CometChatPanel/resources/index.ts +1 -0
  337. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +4 -4
  338. package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +1 -0
  339. package/src/shared/views/CometChatQuickReactions/index.ts +3 -7
  340. package/src/shared/views/CometChatQuickReactions/resources/index.ts +1 -0
  341. package/src/shared/views/CometChatQuickView/CometChatQuickView.tsx +6 -6
  342. package/src/shared/views/CometChatRadioButton/CometChatRadioButton.tsx +4 -4
  343. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +29 -28
  344. package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +1 -0
  345. package/src/shared/views/CometChatReactionList/index.ts +3 -7
  346. package/src/shared/views/CometChatReactionList/resources/index.ts +1 -0
  347. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +14 -14
  348. package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +1 -0
  349. package/src/shared/views/CometChatReactions/index.ts +15 -11
  350. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +5 -5
  351. package/src/shared/views/CometChatReceipt/index.ts +10 -8
  352. package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +59 -53
  353. package/src/shared/views/CometChatSchedulerBubble/index.ts +3 -5
  354. package/src/shared/views/CometChatSchedulerBubble/styles.ts +1 -1
  355. package/src/shared/views/CometChatSingleSelect/CometChatSingleSelect.tsx +4 -4
  356. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -4
  357. package/src/shared/views/CometChatStatusIndicator/StatusIndicatorConfiguration.ts +2 -2
  358. package/src/shared/views/CometChatStatusIndicator/index.ts +21 -10
  359. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +1 -1
  360. package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +5 -5
  361. package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +3 -3
  362. package/src/shared/views/CometChatSuggestionList/index.ts +14 -10
  363. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +6 -5
  364. package/src/shared/views/CometChatTextBubble/index.ts +6 -7
  365. package/src/shared/views/CometChatTextInput/CometChatTextInput.tsx +2 -2
  366. package/src/shared/views/CometChatTimeSlotSelector/CometChatTimeSlotSelector.tsx +5 -5
  367. package/src/shared/views/CometChatTimeSlotSelector/index.ts +3 -5
  368. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +9 -8
  369. package/src/shared/views/CometChatVideoBubble/index.ts +10 -8
  370. package/src/shared/views/CometChatVideoBubble/resources/index.ts +2 -0
  371. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +1 -1
  372. package/src/shared/views/SwipeRow/SwipeRow.tsx +4 -3
  373. package/src/shared/views/index.ts +151 -86
  374. package/ios/CometchatUiKit.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  375. package/ios/CometchatUiKit.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  376. package/src/shared/libs/CometChatCalendar/Components/Arrow.test.tsx +0 -112
  377. package/src/shared/libs/CometChatCalendar/Components/Day.test.tsx +0 -396
  378. package/src/shared/libs/CometChatCalendar/Components/Days.test.tsx +0 -216
  379. package/src/shared/libs/CometChatCalendar/Components/Month.test.tsx +0 -160
  380. package/src/shared/libs/CometChatCalendar/Components/Months.test.tsx +0 -262
  381. package/src/shared/libs/CometChatCalendar/Components/Title.test.tsx +0 -111
  382. package/src/shared/libs/CometChatCalendar/Components/Weekdays.test.tsx +0 -69
  383. package/src/shared/libs/CometChatCalendar/Hooks/useSurroundingTimeUnits.test.ts +0 -44
  384. package/src/shared/libs/CometChatCalendar/Utils/addOpacity.test.ts +0 -49
  385. package/src/shared/libs/CometChatCalendar/Utils/clamp.test.ts +0 -39
  386. package/src/shared/libs/CometChatCalendar/Utils/dateRange.test.ts +0 -20
  387. package/src/shared/libs/CometChatCalendar/Utils/getExtraDays.test.ts +0 -48
  388. package/src/shared/libs/CometChatCalendar/Utils/getSurroundingTimeUnits.test.ts +0 -60
@@ -1,216 +0,0 @@
1
- import React from 'react';
2
- import dayjs from 'dayjs';
3
- import localizedFormat from 'dayjs/plugin/localizedFormat';
4
-
5
- import type { ReactTestInstance } from 'react-test-renderer';
6
- import { render, fireEvent } from '@testing-library/react-native';
7
-
8
- import { ThemeContext } from '../Contexts';
9
- import { DefaultTheme } from '../Themes';
10
- import type { Theme } from '../Entities';
11
-
12
- import Days, { Props } from './Days';
13
-
14
- dayjs.extend(localizedFormat);
15
-
16
- // import { DayComponentType } from '../Entities';
17
-
18
- const getDisabledDays = (day: ReactTestInstance): boolean =>
19
- day.props.accessibilityState.disabled;
20
- const getSelectedDays = (day: ReactTestInstance): boolean =>
21
- day.props.accessibilityState.selected;
22
- const getAccessibilityLabel = (day: ReactTestInstance): string =>
23
- day.props.accessibilityLabel;
24
-
25
- test('Days renders without error', () => {
26
- const days = new DaysPage({});
27
- expect(days.component).toBeTruthy();
28
- });
29
-
30
- describe('Renders the correct number of normal days', () => {
31
- test('works for months with 31 days', () => {
32
- // January 2020 had 31 days
33
- const days = new DaysPage({ visibleDate: dayjs('2020-01-01') });
34
- expect(days.normalDayArray.length).toBe(31);
35
- });
36
-
37
- test('works for months with 30 days', () => {
38
- // April 2020 had 30 days
39
- const days = new DaysPage({ visibleDate: dayjs('2020-04-01') });
40
- expect(days.normalDayArray.length).toBe(30);
41
- });
42
-
43
- test('works for leap-year Febuary', () => {
44
- // Febuary 2020 had 29 days
45
- const days = new DaysPage({ visibleDate: dayjs('2020-02-01') });
46
- expect(days.normalDayArray.length).toBe(29);
47
- });
48
-
49
- test('works for non-leap-year Febuary', () => {
50
- // February 2019 had 28 days
51
- const days = new DaysPage({ visibleDate: dayjs('2019-02-01') });
52
- expect(days.normalDayArray.length).toBe(28);
53
- });
54
- });
55
-
56
- describe('Renders correct number of extra days', () => {
57
- test('works with months that need an extra row', () => {
58
- // January 2020 needs a final padding row
59
- const days = new DaysPage({ visibleDate: dayjs('2020-01-01') });
60
- expect(days.extraDayArray.length).toBe(11);
61
- });
62
-
63
- test('works with months that do not need an extra row', () => {
64
- // May 2020 does not need a final padding row
65
- const days = new DaysPage({ visibleDate: dayjs('2020-05-01') });
66
- expect(days.extraDayArray.length).toBe(11);
67
- });
68
- });
69
-
70
- test('Component passes onPressDay callback to Day children', () => {
71
- const onPressDay = jest.fn();
72
- const days = new DaysPage({ onPressDay });
73
- days.randomDay && fireEvent.press(days.randomDay);
74
- expect(onPressDay).toHaveBeenCalledTimes(1);
75
- });
76
-
77
- describe('Selects the correct days', () => {
78
- test('none selected', () => {
79
- const days = new DaysPage({ dateProperties: {} });
80
- const selectedDays = days.normalDayArray.filter(getSelectedDays);
81
- expect(selectedDays.length).toBe(0);
82
- });
83
-
84
- test('date selection mode', () => {
85
- const visibleDate = dayjs('2020-01-01');
86
- const dateProperties = {
87
- '2019-01-01': { isSelected: true }, // same month of last year, is not rendered
88
- '2020-01-05': { isSelected: true },
89
- '2020-01-15': { isSelected: true },
90
- '2020-01-31': { isSelected: true },
91
- '2020-02-01': { isSelected: true }, // next month, is not rendered
92
- };
93
-
94
- const days = new DaysPage({ visibleDate, dateProperties });
95
- const selectedDays = days.normalDayArray.filter(getSelectedDays);
96
- const selectedDayLabels = selectedDays.map(getAccessibilityLabel);
97
-
98
- expect(selectedDays.length).toBe(3);
99
- expect(selectedDayLabels[0]).toBe('January 5, 2020');
100
- expect(selectedDayLabels[1]).toBe('January 15, 2020');
101
- expect(selectedDayLabels[2]).toBe('January 31, 2020');
102
- });
103
- });
104
-
105
- describe('Disables the correct days', () => {
106
- test('none disabled', () => {
107
- const days = new DaysPage({ dateProperties: {} });
108
- const disabledDays = days.normalDayArray.filter(getDisabledDays);
109
- expect(disabledDays.length).toBe(0);
110
- });
111
-
112
- test('some disabled', () => {
113
- const visibleDate = dayjs('2020-01-01');
114
- const dateProperties = {
115
- '2019-01-01': { isDisabled: true }, // same month of last year, is not rendered
116
- '2020-01-05': { isDisabled: true },
117
- '2020-01-15': { isDisabled: true },
118
- '2020-01-31': { isDisabled: true },
119
- '2020-02-01': { isDisabled: true }, // next month, is not rendered
120
- };
121
-
122
- const days = new DaysPage({ visibleDate, dateProperties });
123
- const disabledDays = days.normalDayArray.filter(getDisabledDays);
124
- const disabledDayLabels = disabledDays.map(getAccessibilityLabel);
125
-
126
- expect(disabledDays.length).toBe(3);
127
- expect(disabledDayLabels[0]).toBe('January 5, 2020');
128
- expect(disabledDayLabels[1]).toBe('January 15, 2020');
129
- expect(disabledDayLabels[2]).toBe('January 31, 2020');
130
- });
131
-
132
- test('Disables dates before min date', () => {
133
- const visibleDate = dayjs('2020-01-01');
134
- const minDate = '2020-01-04'; // 1-3 should be disabled
135
- const days = new DaysPage({ visibleDate, minDate });
136
- const disabledDays = days.normalDayArray.filter(getDisabledDays);
137
- const disabledDayLabels = disabledDays.map(getAccessibilityLabel);
138
-
139
- expect(disabledDays.length).toBe(3);
140
- expect(disabledDayLabels[0]).toBe('January 1, 2020');
141
- expect(disabledDayLabels[1]).toBe('January 2, 2020');
142
- expect(disabledDayLabels[2]).toBe('January 3, 2020');
143
- });
144
-
145
- test('Disables dates after max date', () => {
146
- const visibleDate = dayjs('2020-01-01');
147
- const maxDate = '2020-01-28'; // 29-31 should be disabled
148
- const days = new DaysPage({ visibleDate, maxDate });
149
- const disabledDays = days.normalDayArray.filter(getDisabledDays);
150
- const disabledDayLabels = disabledDays.map(getAccessibilityLabel);
151
-
152
- expect(disabledDays.length).toBe(3);
153
- expect(disabledDayLabels[0]).toBe('January 29, 2020');
154
- expect(disabledDayLabels[1]).toBe('January 30, 2020');
155
- expect(disabledDayLabels[2]).toBe('January 31, 2020');
156
- });
157
- });
158
-
159
- describe('Theme context', () => {
160
- test('Days container applies daysContainer theme', () => {
161
- const days = new DaysPage({ theme: testTheme });
162
- expect(days.component).toHaveStyle(testTheme.daysContainer);
163
- });
164
- });
165
-
166
- class DaysPage {
167
- component: ReactTestInstance;
168
- randomDay?: ReactTestInstance;
169
- randomCustomDay?: ReactTestInstance;
170
- normalDayArray: ReactTestInstance[];
171
- extraDayArray: ReactTestInstance[];
172
- customDayArray: ReactTestInstance[];
173
-
174
- constructor({
175
- visibleDate = dayjs('2020-01-01'),
176
- showExtraDates = false,
177
- onPressDay = () => {},
178
- dateProperties = {},
179
- theme = DefaultTheme,
180
- minDate,
181
- maxDate,
182
- DayComponent,
183
- }: Partial<Props> & { theme?: Theme }) {
184
- const { getByTestId, queryAllByTestId } = render(
185
- <ThemeContext.Provider value={theme}>
186
- <Days
187
- {...{
188
- minDate,
189
- maxDate,
190
- visibleDate,
191
- showExtraDates,
192
- onPressDay,
193
- dateProperties,
194
- DayComponent,
195
- }}
196
- />
197
- </ThemeContext.Provider>
198
- );
199
-
200
- this.component = getByTestId('days-container');
201
- this.normalDayArray = queryAllByTestId('day-container');
202
- this.extraDayArray = queryAllByTestId('extra-day-container');
203
- this.customDayArray = queryAllByTestId('custom-day');
204
-
205
- this.randomDay = this.normalDayArray.length ? this.normalDayArray[0] : undefined;
206
- this.randomCustomDay = this.customDayArray.length ? this.customDayArray[0] : undefined;
207
- }
208
- }
209
-
210
- const testTheme = {
211
- ...DefaultTheme,
212
- daysContainer: {
213
- marginTop: 10,
214
- backgroundColor: 'black',
215
- },
216
- };
@@ -1,160 +0,0 @@
1
- import React from 'react';
2
- import dayjs from 'dayjs';
3
- import LocaleData from 'dayjs/plugin/localeData';
4
- import type { ReactTestInstance } from 'react-test-renderer';
5
- import { render, fireEvent } from '@testing-library/react-native';
6
-
7
- import { ThemeContext } from '../Contexts';
8
- import { DefaultTheme } from '../Themes';
9
- import { DefaultLocale } from '../Locales';
10
-
11
- dayjs.extend(LocaleData);
12
-
13
- import Month, { Props } from './Month';
14
-
15
- test('Month renders without error', () => {
16
- const month = new MonthPage({});
17
- expect(month.component).toBeTruthy();
18
- });
19
-
20
- test('Component calls onPress callback when clicked', () => {
21
- const onPress = jest.fn();
22
- const month = new MonthPage({ onPress });
23
- fireEvent.press(month.component);
24
- expect(onPress).toHaveBeenCalledTimes(1);
25
- });
26
-
27
- describe('Enabling and disabling', () => {
28
- test('Disable clicking if prop ´isDisabled´ is true', () => {
29
- const month = new MonthPage({ isDisabled: true });
30
- expect(month.component).toBeDisabled();
31
- });
32
-
33
- test('Enable clicking if prop ´isDisabled´ is false', () => {
34
- const month = new MonthPage({ isDisabled: false });
35
- expect(month.component).toBeEnabled();
36
- });
37
- });
38
-
39
- describe('Theme context', () => {
40
- test('Container applies normal theme in enabled state', () => {
41
- const month = new MonthPage({ isDisabled: false, isSelected: false });
42
- expect(month.component).toHaveStyle(theme.normalMonthContainer);
43
- expect(month.component).not.toHaveStyle(theme.selectedMonthContainer);
44
- expect(month.component).not.toHaveStyle(theme.disabledMonthContainer);
45
- });
46
-
47
- test('Container applies disabled theme in disabled state', () => {
48
- const month = new MonthPage({ isDisabled: true });
49
- expect(month.component).toHaveStyle([
50
- theme.normalMonthContainer,
51
- theme.disabledMonthContainer,
52
- ]);
53
- expect(month.component).not.toHaveStyle(theme.selectedMonthContainer);
54
- });
55
-
56
- test('Container applies selected theme in selected state', () => {
57
- const month = new MonthPage({ isSelected: true });
58
- expect(month.component).toHaveStyle([
59
- theme.normalMonthContainer,
60
- theme.selectedMonthContainer,
61
- ]);
62
- expect(month.component).not.toHaveStyle(theme.disabledMonthContainer);
63
- });
64
-
65
- test('Container applies selected + disabled themes in selected + disabled state', () => {
66
- const month = new MonthPage({ isSelected: true, isDisabled: true });
67
- expect(month.component).toHaveStyle([
68
- theme.normalMonthContainer,
69
- theme.selectedMonthContainer,
70
- theme.disabledMonthContainer,
71
- ]);
72
- });
73
-
74
- test('Text applies normal theme in enabled state', () => {
75
- const month = new MonthPage({ isDisabled: false, isSelected: false });
76
- expect(month.text).toHaveStyle(theme.normalMonthText);
77
- expect(month.text).not.toHaveStyle(theme.selectedMonthText);
78
- expect(month.text).not.toHaveStyle(theme.disabledMonthText);
79
- });
80
-
81
- test('Text applies disabled theme in disabled state', () => {
82
- const month = new MonthPage({ isDisabled: true });
83
- expect(month.text).toHaveStyle([theme.normalMonthText, theme.disabledMonthText]);
84
- expect(month.text).not.toHaveStyle(theme.selectedMonthText);
85
- });
86
-
87
- test('Text applies selected theme in selected state', () => {
88
- const month = new MonthPage({ isSelected: true });
89
- expect(month.text).toHaveStyle([theme.normalMonthText, theme.selectedMonthText]);
90
- expect(month.text).not.toHaveStyle(theme.disabledMonthText);
91
- });
92
-
93
- test('Text applies selected + disabled themes in selected + disabled state', () => {
94
- const month = new MonthPage({ isSelected: true, isDisabled: true });
95
- expect(month.text).toHaveStyle([
96
- theme.normalMonthText,
97
- theme.selectedMonthText,
98
- theme.disabledMonthText,
99
- ]);
100
- });
101
- });
102
-
103
- class MonthPage {
104
- component: ReactTestInstance;
105
- text: ReactTestInstance;
106
-
107
- constructor({
108
- date = '2020-01-01',
109
- onPress = () => {},
110
- locale = DefaultLocale,
111
- isSelected = false,
112
- isDisabled = false,
113
- }: Partial<Props>) {
114
- const { getByLabelText, getByTestId } = render(
115
- <ThemeContext.Provider value={theme}>
116
- <Month {...{ locale, date, onPress, isSelected, isDisabled }} />
117
- </ThemeContext.Provider>
118
- );
119
-
120
- const months = dayjs(date).localeData().monthsShort();
121
- const index = dayjs(date).month();
122
-
123
- this.component = getByLabelText(months[index]);
124
- this.text = getByTestId('month-text');
125
- }
126
- }
127
-
128
- // Mix of properties which get overwritten and which don't
129
- const theme = {
130
- ...DefaultTheme,
131
- normalMonthContainer: {
132
- marginTop: 10,
133
- backgroundColor: 'black',
134
- },
135
- selectedMonthContainer: {
136
- marginBottom: 10,
137
- backgroundColor: 'green',
138
- },
139
- disabledMonthContainer: {
140
- marginLeft: 10,
141
- backgroundColor: 'gray',
142
- },
143
- normalMonthText: {
144
- marginTop: 10,
145
- color: 'black',
146
- },
147
- selectedMonthText: {
148
- marginBottom: 10,
149
- color: 'green',
150
- },
151
- disabledMonthText: {
152
- marginLeft: 10,
153
- color: 'gray',
154
- },
155
- };
156
-
157
- export const testLocale = {
158
- ...DefaultLocale,
159
- monthsShort: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'],
160
- };
@@ -1,262 +0,0 @@
1
- import React from 'react';
2
- import dayjs from 'dayjs';
3
- import { TouchableOpacity, Text } from 'react-native';
4
- import { fireEvent, render } from '@testing-library/react-native';
5
- import type { ReactTestInstance } from 'react-test-renderer';
6
-
7
- import { ThemeContext } from '../Contexts';
8
- import { DefaultTheme } from '../Themes';
9
- import type { Theme, MonthComponentType } from '../Entities';
10
-
11
- import Months, { Props } from './Months';
12
-
13
- const getDisabledMonths = (month: ReactTestInstance) =>
14
- month.props.accessibilityState.disabled;
15
- const getSelectedMonths = (month: ReactTestInstance) =>
16
- month.props.accessibilityState.selected;
17
-
18
- test('Months renders without error', () => {
19
- const months = new MonthsPage({});
20
- expect(months.component).toBeTruthy();
21
- });
22
-
23
- test('Renders the correct number of months', () => {
24
- const months = new MonthsPage({});
25
- expect(months.monthArray.length).toBe(12);
26
- });
27
-
28
- test('Component passes onPressMonth callback to Month children', () => {
29
- const onPressMonth = jest.fn();
30
- const months = new MonthsPage({ onPressMonth });
31
- months.firstMonth && fireEvent.press(months.firstMonth);
32
- expect(onPressMonth).toHaveBeenCalledTimes(1);
33
- });
34
-
35
- describe('Generates correct set of selected months', () => {
36
- test('None selected, undefined', () => {
37
- const months = new MonthsPage({ dateProperties: {} });
38
- const selectedMonths = months.monthArray.filter(getSelectedMonths);
39
- expect(selectedMonths.length).toBe(0);
40
- });
41
-
42
- test('None selected, false', () => {
43
- const months = new MonthsPage({
44
- dateProperties: {
45
- '2020-04-01': { isSelected: false },
46
- },
47
- });
48
- const selectedMonths = months.monthArray.filter(getSelectedMonths);
49
- expect(selectedMonths.length).toBe(0);
50
- });
51
-
52
- test('Date selection', () => {
53
- const dateProperties = {
54
- '2019-01-01': { isSelected: true },
55
- '2020-01-01': { isSelected: true },
56
- '2020-01-05': { isSelected: true },
57
- '2020-04-23': { isSelected: true },
58
- };
59
-
60
- const months = new MonthsPage({ dateProperties });
61
- const selectedMonths = months.monthArray.filter(getSelectedMonths);
62
- expect(selectedMonths.length).toBe(2);
63
- expect(selectedMonths[0]).toHaveTextContent('Jan');
64
- expect(selectedMonths[1]).toHaveTextContent('Apr');
65
- });
66
- });
67
-
68
- describe('Disables the correct months', () => {
69
- describe('due to min date', () => {
70
- test('works for start-of-year date', () => {
71
- const months = new MonthsPage({ minDate: '2020-01-01' });
72
- const disabledMonths = months.monthArray.filter(getDisabledMonths);
73
- expect(disabledMonths.length).toBe(0);
74
- });
75
-
76
- test('works for middle-of-the-year dates', () => {
77
- const months = new MonthsPage({ minDate: '2020-04-01' });
78
- const disabledMonths = months.monthArray.filter(getDisabledMonths);
79
- expect(disabledMonths.length).toBe(3);
80
- expect(disabledMonths[0]).toHaveTextContent('Jan');
81
- expect(disabledMonths[1]).toHaveTextContent('Feb');
82
- expect(disabledMonths[2]).toHaveTextContent('Mar');
83
- });
84
-
85
- test('works for end-of-year date', () => {
86
- const months = new MonthsPage({ minDate: '2020-12-31' });
87
- const disabledMonths = months.monthArray.filter(getDisabledMonths);
88
- expect(disabledMonths.length).toBe(11);
89
- });
90
- });
91
-
92
- describe('due to max date', () => {
93
- test('works for start-of-year date', () => {
94
- const months = new MonthsPage({ maxDate: '2020-01-01' });
95
- const disabledMonths = months.monthArray.filter(getDisabledMonths);
96
- expect(disabledMonths.length).toBe(11);
97
- });
98
-
99
- test('works for middle-of-the-year date', () => {
100
- const months = new MonthsPage({ maxDate: '2020-10-15' });
101
- const disabledMonths = months.monthArray.filter(getDisabledMonths);
102
- expect(disabledMonths.length).toBe(2);
103
- expect(disabledMonths[0]).toHaveTextContent('Nov');
104
- expect(disabledMonths[1]).toHaveTextContent('Dec');
105
- });
106
-
107
- test('works for end-of-year date', () => {
108
- const months = new MonthsPage({ maxDate: '2020-12-31' });
109
- const disabledMonths = months.monthArray.filter(getDisabledMonths);
110
- expect(disabledMonths.length).toBe(0);
111
- });
112
- });
113
- });
114
-
115
- describe('Theme context', () => {
116
- test('Months container applies monthsContainer theme', () => {
117
- const months = new MonthsPage({ theme: testTheme });
118
- expect(months.component).toHaveStyle(testTheme.monthsContainer);
119
- });
120
- });
121
-
122
- describe('Custom month component', () => {
123
- const MonthComponent: MonthComponentType = ({
124
- date,
125
- onPress,
126
- isSelected,
127
- isDisabled,
128
- }) => (
129
- <TouchableOpacity
130
- testID={'custom-month'}
131
- accessibilityState={{ disabled: isDisabled, selected: isSelected }}
132
- onPress={() => onPress(date)}>
133
- <Text>{dayjs(date).format('MMM')}</Text>
134
- </TouchableOpacity>
135
- );
136
-
137
- test('custom month receives onPress prop', () => {
138
- const onPressMonth = jest.fn();
139
- const months = new MonthsPage({ MonthComponent, onPressMonth });
140
- months.firstCustomMonth && fireEvent.press(months.firstCustomMonth);
141
- expect(onPressMonth).toHaveBeenCalledTimes(1);
142
- });
143
-
144
- describe('custom month receives isSelected prop', () => {
145
- test('None selected', () => {
146
- const months = new MonthsPage({ MonthComponent, dateProperties: {} });
147
- const selectedMonths = months.customMonthArray.filter(getSelectedMonths);
148
- expect(selectedMonths.length).toBe(0);
149
- });
150
-
151
- test('Date selection', () => {
152
- const dateProperties = {
153
- '2019-01-01': { isSelected: true },
154
- '2020-01-01': { isSelected: true },
155
- '2020-01-05': { isSelected: true },
156
- '2020-04-23': { isSelected: true },
157
- };
158
-
159
- const months = new MonthsPage({ MonthComponent, dateProperties });
160
- const selectedMonths = months.customMonthArray.filter(getSelectedMonths);
161
- expect(selectedMonths.length).toBe(2);
162
- });
163
- });
164
-
165
- describe('custom month component receives isDisabled prop', () => {
166
- describe('disable months due to min date', () => {
167
- test('works for start-of-year date', () => {
168
- const minDate = '2020-01-01';
169
- const months = new MonthsPage({ MonthComponent, minDate });
170
- const disabledMonths = months.customMonthArray.filter(getDisabledMonths);
171
- expect(disabledMonths.length).toBe(0);
172
- });
173
-
174
- test('works for middle-of-the-year dates', () => {
175
- const minDate = '2020-04-01';
176
- const months = new MonthsPage({ MonthComponent, minDate });
177
- const disabledMonths = months.customMonthArray.filter(getDisabledMonths);
178
- expect(disabledMonths.length).toBe(3);
179
- });
180
-
181
- test('works for end-of-year date', () => {
182
- const minDate = '2020-12-31';
183
- const months = new MonthsPage({ MonthComponent, minDate });
184
- const disabledMonths = months.customMonthArray.filter(getDisabledMonths);
185
- expect(disabledMonths.length).toBe(11);
186
- });
187
- });
188
-
189
- describe('disable months due to max date', () => {
190
- test('works for start-of-year date', () => {
191
- const maxDate = '2020-01-01';
192
- const months = new MonthsPage({ MonthComponent, maxDate });
193
- const disabledMonths = months.customMonthArray.filter(getDisabledMonths);
194
- expect(disabledMonths.length).toBe(11);
195
- });
196
-
197
- test('works for middle-of-the-year dates', () => {
198
- const maxDate = '2020-10-15';
199
- const months = new MonthsPage({ MonthComponent, maxDate });
200
- const disabledMonths = months.customMonthArray.filter(getDisabledMonths);
201
- expect(disabledMonths.length).toBe(2);
202
- });
203
-
204
- test('works for end-of-year date', () => {
205
- const maxDate = '2020-12-31';
206
- const months = new MonthsPage({ MonthComponent, maxDate });
207
- const disabledMonths = months.customMonthArray.filter(getDisabledMonths);
208
- expect(disabledMonths.length).toBe(0);
209
- });
210
- });
211
- });
212
- });
213
-
214
- export class MonthsPage {
215
- component: ReactTestInstance;
216
- firstMonth?: ReactTestInstance;
217
- firstCustomMonth?: ReactTestInstance;
218
- monthArray: ReactTestInstance[];
219
- customMonthArray: ReactTestInstance[];
220
-
221
- constructor({
222
- onPressMonth = () => {},
223
- dateProperties = {},
224
- visibleDate = dayjs('2020-05-01'),
225
- MonthComponent,
226
- minDate,
227
- maxDate,
228
- theme = DefaultTheme,
229
- }: Partial<Props> & { theme?: Theme }) {
230
- const { getAllByRole, getByTestId, getAllByTestId } = render(
231
- <ThemeContext.Provider value={theme}>
232
- <Months
233
- {...{
234
- MonthComponent,
235
- onPressMonth,
236
- dateProperties,
237
- visibleDate,
238
- minDate,
239
- maxDate,
240
- }}
241
- />
242
- </ThemeContext.Provider>
243
- );
244
-
245
- this.component = getByTestId('months-container');
246
- this.monthArray = !MonthComponent ? getAllByRole('button') : [];
247
- this.customMonthArray = MonthComponent ? getAllByTestId('custom-month') : [];
248
-
249
- this.firstMonth = this.monthArray.length ? this.monthArray[0] : undefined;
250
- this.firstCustomMonth = this.customMonthArray.length
251
- ? this.customMonthArray[0]
252
- : undefined;
253
- }
254
- }
255
-
256
- export const testTheme = {
257
- ...DefaultTheme,
258
- monthsContainer: {
259
- marginTop: 10,
260
- backgroundColor: 'black',
261
- },
262
- };