@atlaskit/reactions 21.5.1 → 21.6.0

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 (310) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/MockReactionsClient/package.json +7 -0
  3. package/dist/cjs/{client/MockReactionsClient.js → MockReactionsClient.js} +4 -6
  4. package/dist/cjs/analytics/analytics.js +141 -0
  5. package/dist/cjs/analytics/index.js +4 -134
  6. package/dist/cjs/client/ReactionServiceClient.js +29 -6
  7. package/dist/cjs/client/index.js +1 -33
  8. package/dist/cjs/components/{Counter.js → Counter/Counter.js} +32 -39
  9. package/dist/cjs/components/Counter/index.js +36 -0
  10. package/dist/cjs/components/Counter/styles.js +33 -0
  11. package/dist/cjs/components/EmojiButton/EmojiButton.js +58 -0
  12. package/dist/cjs/components/EmojiButton/index.js +19 -0
  13. package/dist/cjs/components/EmojiButton/styles.js +25 -0
  14. package/dist/cjs/components/FlashAnimation/FlashAnimation.js +42 -0
  15. package/dist/cjs/components/FlashAnimation/index.js +19 -0
  16. package/dist/cjs/components/{FlashAnimation.js → FlashAnimation/styles.js} +7 -26
  17. package/dist/cjs/components/Reaction/Reaction.js +163 -0
  18. package/dist/cjs/components/Reaction/index.js +19 -0
  19. package/dist/cjs/components/Reaction/styles.js +70 -0
  20. package/dist/cjs/components/ReactionPicker/ReactionPicker.js +272 -0
  21. package/dist/cjs/components/ReactionPicker/index.js +19 -0
  22. package/dist/cjs/components/ReactionPicker/styles.js +37 -0
  23. package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +71 -0
  24. package/dist/cjs/components/ReactionTooltip/index.js +19 -0
  25. package/dist/cjs/components/ReactionTooltip/styles.js +46 -0
  26. package/dist/cjs/components/Reactions/Reactions.js +200 -0
  27. package/dist/cjs/components/Reactions/index.js +25 -0
  28. package/dist/cjs/components/Reactions/styles.js +29 -0
  29. package/dist/cjs/components/Selector/Selector.js +132 -0
  30. package/dist/cjs/components/Selector/index.js +30 -0
  31. package/dist/cjs/components/Selector/styles.js +56 -0
  32. package/dist/cjs/components/ShowMore/ShowMore.js +71 -0
  33. package/dist/cjs/components/ShowMore/index.js +19 -0
  34. package/dist/cjs/components/ShowMore/styles.js +44 -0
  35. package/dist/cjs/components/Trigger/Trigger.js +59 -0
  36. package/dist/cjs/components/Trigger/index.js +13 -0
  37. package/dist/cjs/components/Trigger/styles.js +46 -0
  38. package/dist/cjs/components/{UfoErrorBoundary.js → UfoErrorBoundary/UfoErrorBoundary.js} +3 -0
  39. package/dist/cjs/components/UfoErrorBoundary/index.js +13 -0
  40. package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +62 -0
  41. package/dist/cjs/containers/ConnectedReactionPicker/index.js +13 -0
  42. package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +258 -0
  43. package/dist/cjs/containers/ConnectedReactionsView/index.js +13 -0
  44. package/dist/cjs/containers/index.js +23 -13
  45. package/dist/cjs/hooks/index.js +13 -0
  46. package/dist/cjs/hooks/useClickAway.js +35 -0
  47. package/dist/cjs/index.js +8 -0
  48. package/dist/cjs/shared/constants.js +39 -8
  49. package/dist/cjs/{components → shared}/i18n.js +1 -1
  50. package/dist/cjs/shared/index.js +11 -3
  51. package/dist/cjs/shared/utils.js +54 -0
  52. package/dist/cjs/store/{ReactionsStore.js → MemoryReactionsStore.js} +37 -18
  53. package/dist/cjs/store/ReactionConsumer.js +43 -15
  54. package/dist/cjs/store/index.js +8 -2
  55. package/dist/cjs/store/utils.js +4 -10
  56. package/dist/cjs/{client/ReactionClient.js → types/client.js} +0 -0
  57. package/dist/cjs/types/index.js +2 -2
  58. package/dist/cjs/types/reaction.js +43 -0
  59. package/dist/cjs/types/{DetailedReaction.js → store.js} +0 -0
  60. package/dist/cjs/version.json +1 -1
  61. package/dist/es2019/{client/MockReactionsClient.js → MockReactionsClient.js} +4 -5
  62. package/dist/es2019/analytics/analytics.js +64 -0
  63. package/dist/es2019/analytics/index.js +3 -65
  64. package/dist/es2019/analytics/ufo.js +0 -1
  65. package/dist/es2019/client/ReactionServiceClient.js +31 -6
  66. package/dist/es2019/client/index.js +1 -2
  67. package/dist/es2019/components/{Counter.js → Counter/Counter.js} +26 -31
  68. package/dist/es2019/components/Counter/index.js +3 -0
  69. package/dist/es2019/components/Counter/styles.js +20 -0
  70. package/dist/es2019/components/EmojiButton/EmojiButton.js +35 -0
  71. package/dist/es2019/components/EmojiButton/index.js +1 -0
  72. package/dist/es2019/components/EmojiButton/styles.js +16 -0
  73. package/dist/es2019/components/FlashAnimation/FlashAnimation.js +18 -0
  74. package/dist/es2019/components/FlashAnimation/index.js +1 -0
  75. package/dist/es2019/components/{FlashAnimation.js → FlashAnimation/styles.js} +6 -17
  76. package/dist/es2019/components/Reaction/Reaction.js +104 -0
  77. package/dist/es2019/components/Reaction/index.js +1 -0
  78. package/dist/es2019/components/Reaction/styles.js +55 -0
  79. package/dist/es2019/components/ReactionPicker/ReactionPicker.js +208 -0
  80. package/dist/es2019/components/ReactionPicker/index.js +1 -0
  81. package/dist/es2019/components/ReactionPicker/styles.js +23 -0
  82. package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +46 -0
  83. package/dist/es2019/components/ReactionTooltip/index.js +1 -0
  84. package/dist/es2019/components/ReactionTooltip/styles.js +32 -0
  85. package/dist/es2019/components/Reactions/Reactions.js +156 -0
  86. package/dist/es2019/components/Reactions/index.js +1 -0
  87. package/dist/es2019/components/Reactions/styles.js +19 -0
  88. package/dist/es2019/components/Selector/Selector.js +98 -0
  89. package/dist/es2019/components/Selector/index.js +3 -0
  90. package/dist/es2019/components/Selector/styles.js +39 -0
  91. package/dist/es2019/components/ShowMore/ShowMore.js +43 -0
  92. package/dist/es2019/components/ShowMore/index.js +1 -0
  93. package/dist/es2019/components/ShowMore/styles.js +30 -0
  94. package/dist/es2019/components/{Trigger.js → Trigger/Trigger.js} +15 -20
  95. package/dist/es2019/components/Trigger/index.js +1 -0
  96. package/dist/es2019/components/Trigger/styles.js +24 -0
  97. package/dist/es2019/components/{UfoErrorBoundary.js → UfoErrorBoundary/UfoErrorBoundary.js} +4 -0
  98. package/dist/es2019/components/UfoErrorBoundary/index.js +1 -0
  99. package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +27 -0
  100. package/dist/es2019/containers/ConnectedReactionPicker/index.js +1 -0
  101. package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +166 -0
  102. package/dist/es2019/containers/ConnectedReactionsView/index.js +1 -0
  103. package/dist/es2019/containers/index.js +2 -2
  104. package/dist/es2019/hooks/index.js +1 -0
  105. package/dist/es2019/hooks/useClickAway.js +27 -0
  106. package/dist/es2019/index.js +3 -1
  107. package/dist/es2019/shared/constants.js +32 -4
  108. package/dist/es2019/{components → shared}/i18n.js +1 -1
  109. package/dist/es2019/shared/index.js +6 -2
  110. package/dist/es2019/shared/utils.js +35 -0
  111. package/dist/es2019/store/{ReactionsStore.js → MemoryReactionsStore.js} +36 -17
  112. package/dist/es2019/store/ReactionConsumer.js +18 -12
  113. package/dist/es2019/store/index.js +1 -1
  114. package/dist/es2019/store/utils.js +8 -4
  115. package/dist/es2019/{client/ReactionClient.js → types/client.js} +0 -0
  116. package/dist/es2019/types/index.js +1 -1
  117. package/dist/es2019/types/reaction.js +34 -0
  118. package/dist/es2019/types/{DetailedReaction.js → store.js} +0 -0
  119. package/dist/es2019/version.json +1 -1
  120. package/dist/esm/{client/MockReactionsClient.js → MockReactionsClient.js} +4 -5
  121. package/dist/esm/analytics/analytics.js +99 -0
  122. package/dist/esm/analytics/index.js +3 -99
  123. package/dist/esm/analytics/ufo.js +0 -1
  124. package/dist/esm/client/ReactionServiceClient.js +30 -6
  125. package/dist/esm/client/index.js +1 -2
  126. package/dist/esm/components/{Counter.js → Counter/Counter.js} +26 -31
  127. package/dist/esm/components/Counter/index.js +3 -0
  128. package/dist/esm/components/Counter/styles.js +20 -0
  129. package/dist/esm/components/EmojiButton/EmojiButton.js +35 -0
  130. package/dist/esm/components/EmojiButton/index.js +1 -0
  131. package/dist/esm/components/EmojiButton/styles.js +16 -0
  132. package/dist/esm/components/FlashAnimation/FlashAnimation.js +20 -0
  133. package/dist/esm/components/FlashAnimation/index.js +1 -0
  134. package/dist/esm/components/{FlashAnimation.js → FlashAnimation/styles.js} +6 -19
  135. package/dist/esm/components/Reaction/Reaction.js +131 -0
  136. package/dist/esm/components/Reaction/index.js +1 -0
  137. package/dist/esm/components/Reaction/styles.js +55 -0
  138. package/dist/esm/components/ReactionPicker/ReactionPicker.js +243 -0
  139. package/dist/esm/components/ReactionPicker/index.js +1 -0
  140. package/dist/esm/components/ReactionPicker/styles.js +23 -0
  141. package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +46 -0
  142. package/dist/esm/components/ReactionTooltip/index.js +1 -0
  143. package/dist/esm/components/ReactionTooltip/styles.js +32 -0
  144. package/dist/esm/components/Reactions/Reactions.js +166 -0
  145. package/dist/esm/components/Reactions/index.js +1 -0
  146. package/dist/esm/components/Reactions/styles.js +19 -0
  147. package/dist/esm/components/Selector/Selector.js +107 -0
  148. package/dist/esm/components/Selector/index.js +3 -0
  149. package/dist/esm/components/Selector/styles.js +41 -0
  150. package/dist/esm/components/ShowMore/ShowMore.js +46 -0
  151. package/dist/esm/components/ShowMore/index.js +1 -0
  152. package/dist/esm/components/ShowMore/styles.js +30 -0
  153. package/dist/esm/components/{Trigger.js → Trigger/Trigger.js} +15 -20
  154. package/dist/esm/components/Trigger/index.js +1 -0
  155. package/dist/esm/components/Trigger/styles.js +31 -0
  156. package/dist/esm/components/{UfoErrorBoundary.js → UfoErrorBoundary/UfoErrorBoundary.js} +4 -0
  157. package/dist/esm/components/UfoErrorBoundary/index.js +1 -0
  158. package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +46 -0
  159. package/dist/esm/containers/ConnectedReactionPicker/index.js +1 -0
  160. package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +227 -0
  161. package/dist/esm/containers/ConnectedReactionsView/index.js +1 -0
  162. package/dist/esm/containers/index.js +2 -2
  163. package/dist/esm/hooks/index.js +1 -0
  164. package/dist/esm/hooks/useClickAway.js +28 -0
  165. package/dist/esm/index.js +3 -1
  166. package/dist/esm/shared/constants.js +34 -4
  167. package/dist/esm/{components → shared}/i18n.js +1 -1
  168. package/dist/esm/shared/index.js +6 -2
  169. package/dist/esm/shared/utils.js +41 -0
  170. package/dist/esm/store/{ReactionsStore.js → MemoryReactionsStore.js} +36 -20
  171. package/dist/esm/store/ReactionConsumer.js +42 -15
  172. package/dist/esm/store/index.js +1 -1
  173. package/dist/esm/store/utils.js +8 -4
  174. package/dist/{es2019/types/ReactionSource.js → esm/types/client.js} +0 -0
  175. package/dist/esm/types/index.js +1 -1
  176. package/dist/esm/types/reaction.js +34 -0
  177. package/dist/{es2019/types/ReactionSummary.js → esm/types/store.js} +0 -0
  178. package/dist/esm/version.json +1 -1
  179. package/dist/types/{client/MockReactionsClient.d.ts → MockReactionsClient.d.ts} +4 -5
  180. package/dist/types/analytics/analytics.d.ts +96 -0
  181. package/dist/types/analytics/index.d.ts +1 -96
  182. package/dist/types/client/ReactionServiceClient.d.ts +27 -10
  183. package/dist/types/client/index.d.ts +0 -2
  184. package/dist/types/components/{Counter.d.ts → Counter/Counter.d.ts} +15 -7
  185. package/dist/types/components/Counter/index.d.ts +3 -0
  186. package/dist/types/components/Counter/styles.d.ts +3 -0
  187. package/dist/types/components/EmojiButton/EmojiButton.d.ts +22 -0
  188. package/dist/types/components/EmojiButton/index.d.ts +2 -0
  189. package/dist/types/components/EmojiButton/styles.d.ts +1 -0
  190. package/dist/types/components/FlashAnimation/FlashAnimation.d.ts +20 -0
  191. package/dist/types/components/FlashAnimation/index.d.ts +2 -0
  192. package/dist/types/components/FlashAnimation/styles.d.ts +3 -0
  193. package/dist/types/components/Reaction/Reaction.d.ts +38 -0
  194. package/dist/types/components/Reaction/index.d.ts +2 -0
  195. package/dist/types/components/Reaction/styles.d.ts +10 -0
  196. package/dist/types/components/{ReactionPicker.d.ts → ReactionPicker/ReactionPicker.d.ts} +12 -33
  197. package/dist/types/components/ReactionPicker/index.d.ts +2 -0
  198. package/dist/types/components/ReactionPicker/styles.d.ts +3 -0
  199. package/dist/types/components/ReactionTooltip/ReactionTooltip.d.ts +22 -0
  200. package/dist/types/components/ReactionTooltip/index.d.ts +2 -0
  201. package/dist/types/components/ReactionTooltip/styles.d.ts +4 -0
  202. package/dist/types/components/Reactions/Reactions.d.ts +64 -0
  203. package/dist/types/components/Reactions/index.d.ts +2 -0
  204. package/dist/types/components/Reactions/styles.d.ts +2 -0
  205. package/dist/types/components/Selector/Selector.d.ts +34 -0
  206. package/dist/types/components/Selector/index.d.ts +3 -0
  207. package/dist/types/components/Selector/styles.d.ts +10 -0
  208. package/dist/types/components/{ShowMore.d.ts → ShowMore/ShowMore.d.ts} +14 -13
  209. package/dist/types/components/ShowMore/index.d.ts +2 -0
  210. package/dist/types/components/ShowMore/styles.d.ts +3 -0
  211. package/dist/types/components/Trigger/Trigger.d.ts +23 -0
  212. package/dist/types/components/Trigger/index.d.ts +2 -0
  213. package/dist/types/components/Trigger/styles.d.ts +5 -0
  214. package/dist/types/components/UfoErrorBoundary/UfoErrorBoundary.d.ts +16 -0
  215. package/dist/types/components/UfoErrorBoundary/index.d.ts +2 -0
  216. package/dist/types/components/index.d.ts +4 -1
  217. package/dist/types/containers/ConnectedReactionPicker/ConnectedReactionPicker.d.ts +27 -0
  218. package/dist/types/containers/ConnectedReactionPicker/index.d.ts +2 -0
  219. package/dist/types/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +52 -0
  220. package/dist/types/containers/ConnectedReactionsView/index.d.ts +2 -0
  221. package/dist/types/containers/index.d.ts +2 -2
  222. package/dist/types/hooks/index.d.ts +1 -0
  223. package/dist/types/hooks/useClickAway.d.ts +8 -0
  224. package/dist/types/index.d.ts +2 -2
  225. package/dist/types/shared/constants.d.ts +13 -3
  226. package/dist/types/{components → shared}/i18n.d.ts +0 -0
  227. package/dist/types/shared/index.d.ts +3 -1
  228. package/dist/types/shared/utils.d.ts +11 -0
  229. package/dist/types/store/{ReactionsStore.d.ts → MemoryReactionsStore.d.ts} +21 -61
  230. package/dist/types/store/ReactionConsumer.d.ts +47 -19
  231. package/dist/types/store/index.d.ts +2 -2
  232. package/dist/types/store/utils.d.ts +3 -7
  233. package/dist/types/types/Actions.d.ts +3 -0
  234. package/dist/types/types/User.d.ts +6 -0
  235. package/dist/types/types/client.d.ts +38 -0
  236. package/dist/types/types/index.d.ts +4 -6
  237. package/dist/types/types/reaction.d.ts +82 -0
  238. package/dist/types/types/store.d.ts +63 -0
  239. package/extract-react-type/ConnectedReactionPicker.ts +2 -4
  240. package/extract-react-type/ConnectedReactionsView.ts +3 -5
  241. package/extract-react-type/Reaction.ts +2 -4
  242. package/extract-react-type/Reactions.ts +2 -4
  243. package/extract-react-type/actions.ts +1 -3
  244. package/extract-react-type/reactionClient.ts +3 -5
  245. package/extract-react-type/reactionsStore.ts +3 -5
  246. package/package.json +21 -5
  247. package/dist/cjs/components/EmojiButton.js +0 -100
  248. package/dist/cjs/components/Reaction.js +0 -229
  249. package/dist/cjs/components/ReactionPicker.js +0 -297
  250. package/dist/cjs/components/ReactionTooltip.js +0 -82
  251. package/dist/cjs/components/Reactions.js +0 -194
  252. package/dist/cjs/components/Selector.js +0 -189
  253. package/dist/cjs/components/ShowMore.js +0 -119
  254. package/dist/cjs/components/Trigger.js +0 -58
  255. package/dist/cjs/components/utils.js +0 -28
  256. package/dist/cjs/containers/ConnectedReactionPicker.js +0 -53
  257. package/dist/cjs/containers/ConnectedReactionsView.js +0 -139
  258. package/dist/cjs/types/ReactionSource.js +0 -5
  259. package/dist/cjs/types/ReactionStatus.js +0 -19
  260. package/dist/cjs/types/ReactionSummary.js +0 -5
  261. package/dist/cjs/types/Reactions.js +0 -5
  262. package/dist/cjs/types/ReactionsState.js +0 -5
  263. package/dist/es2019/components/EmojiButton.js +0 -50
  264. package/dist/es2019/components/Reaction.js +0 -183
  265. package/dist/es2019/components/ReactionPicker.js +0 -247
  266. package/dist/es2019/components/ReactionTooltip.js +0 -66
  267. package/dist/es2019/components/Reactions.js +0 -150
  268. package/dist/es2019/components/Selector.js +0 -127
  269. package/dist/es2019/components/ShowMore.js +0 -71
  270. package/dist/es2019/components/utils.js +0 -13
  271. package/dist/es2019/containers/ConnectedReactionPicker.js +0 -36
  272. package/dist/es2019/containers/ConnectedReactionsView.js +0 -118
  273. package/dist/es2019/types/ReactionStatus.js +0 -11
  274. package/dist/es2019/types/Reactions.js +0 -1
  275. package/dist/es2019/types/ReactionsState.js +0 -1
  276. package/dist/esm/client/ReactionClient.js +0 -1
  277. package/dist/esm/components/EmojiButton.js +0 -77
  278. package/dist/esm/components/Reaction.js +0 -207
  279. package/dist/esm/components/ReactionPicker.js +0 -274
  280. package/dist/esm/components/ReactionTooltip.js +0 -63
  281. package/dist/esm/components/Reactions.js +0 -180
  282. package/dist/esm/components/Selector.js +0 -160
  283. package/dist/esm/components/ShowMore.js +0 -95
  284. package/dist/esm/components/utils.js +0 -15
  285. package/dist/esm/containers/ConnectedReactionPicker.js +0 -38
  286. package/dist/esm/containers/ConnectedReactionsView.js +0 -116
  287. package/dist/esm/types/DetailedReaction.js +0 -1
  288. package/dist/esm/types/ReactionSource.js +0 -1
  289. package/dist/esm/types/ReactionStatus.js +0 -11
  290. package/dist/esm/types/ReactionSummary.js +0 -1
  291. package/dist/esm/types/Reactions.js +0 -1
  292. package/dist/esm/types/ReactionsState.js +0 -1
  293. package/dist/types/client/ReactionClient.d.ts +0 -28
  294. package/dist/types/components/EmojiButton.d.ts +0 -21
  295. package/dist/types/components/FlashAnimation.d.ts +0 -18
  296. package/dist/types/components/Reaction.d.ts +0 -44
  297. package/dist/types/components/ReactionTooltip.d.ts +0 -14
  298. package/dist/types/components/Reactions.d.ts +0 -83
  299. package/dist/types/components/Selector.d.ts +0 -39
  300. package/dist/types/components/Trigger.d.ts +0 -16
  301. package/dist/types/components/UfoErrorBoundary.d.ts +0 -9
  302. package/dist/types/components/utils.d.ts +0 -4
  303. package/dist/types/containers/ConnectedReactionPicker.d.ts +0 -16
  304. package/dist/types/containers/ConnectedReactionsView.d.ts +0 -31
  305. package/dist/types/types/DetailedReaction.d.ts +0 -7
  306. package/dist/types/types/ReactionSource.d.ts +0 -4
  307. package/dist/types/types/ReactionStatus.d.ts +0 -9
  308. package/dist/types/types/ReactionSummary.d.ts +0 -10
  309. package/dist/types/types/Reactions.d.ts +0 -4
  310. package/dist/types/types/ReactionsState.d.ts +0 -20
@@ -0,0 +1,227 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
6
+ import { FabricElementsAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
7
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
8
+ import { Reactions, UfoErrorBoundary } from '../../components';
9
+ import { ufoExperiences } from '../../store';
10
+ import { ReactionStatus } from '../../types';
11
+
12
+ /**
13
+ * Export the mapper function outside the component so easier to do unit tests migration from Enzyme to React Testing Library
14
+ */
15
+ export var mapStateToPropsHelper = function mapStateToPropsHelper(containerAri, ari, state) {
16
+ var reactionsState = state && state.reactions["".concat(containerAri, "|").concat(ari)];
17
+
18
+ if (!state || !reactionsState) {
19
+ return {
20
+ status: ReactionStatus.notLoaded,
21
+ reactions: []
22
+ };
23
+ }
24
+
25
+ switch (reactionsState.status) {
26
+ case ReactionStatus.ready:
27
+ return {
28
+ reactions: reactionsState.reactions,
29
+ status: reactionsState.status,
30
+ flash: state.flash["".concat(containerAri, "|").concat(ari)]
31
+ };
32
+
33
+ case ReactionStatus.error:
34
+ return {
35
+ status: ReactionStatus.error,
36
+ reactions: []
37
+ };
38
+
39
+ default:
40
+ return {
41
+ status: ReactionStatus.loading,
42
+ reactions: []
43
+ };
44
+ }
45
+ };
46
+ /**
47
+ * Export the mapper function outside the component so easier to do unit tests migration from Enzyme to React Testing Library
48
+ */
49
+
50
+ export var mapDispatchToPropsHelper = function mapDispatchToPropsHelper(actions, containerAri, ari) {
51
+ return {
52
+ loadReaction: function loadReaction() {
53
+ actions.getReactions(containerAri, ari);
54
+ },
55
+ onReactionClick: function onReactionClick(emojiId) {
56
+ actions.toggleReaction(containerAri, ari, emojiId);
57
+ },
58
+ onReactionHover: function onReactionHover(emojiId) {
59
+ actions.getDetailedReaction(containerAri, ari, emojiId);
60
+ },
61
+ onSelection: function onSelection(emojiId) {
62
+ actions.addReaction(containerAri, ari, emojiId);
63
+ }
64
+ };
65
+ };
66
+ export var ConnectedReactionsView = function ConnectedReactionsView(props) {
67
+ var ari = props.ari,
68
+ containerAri = props.containerAri,
69
+ store = props.store;
70
+ /**
71
+ * Reference to the <Reactions /> component instance mandatory props
72
+ */
73
+
74
+ var _useState = useState(),
75
+ _useState2 = _slicedToArray(_useState, 2),
76
+ stateData = _useState2[0],
77
+ setStateData = _useState2[1];
78
+
79
+ var _useState3 = useState(),
80
+ _useState4 = _slicedToArray(_useState3, 2),
81
+ dispatchData = _useState4[0],
82
+ setDispatchData = _useState4[1]; // compose a UFO experience object
83
+
84
+
85
+ var experienceInstance = useRef();
86
+
87
+ var _useAnalyticsEvents = useAnalyticsEvents(),
88
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
89
+
90
+ useEffect(function () {
91
+ experienceInstance.current = ufoExperiences.render(ari);
92
+ }, [ari]); // abort when component gets unmounted
93
+
94
+ useEffect(function () {
95
+ return function cleanup() {
96
+ var _experienceInstance$c;
97
+
98
+ (_experienceInstance$c = experienceInstance.current) === null || _experienceInstance$c === void 0 ? void 0 : _experienceInstance$c.abort({
99
+ metadata: {
100
+ source: 'Connected-Reactions-View',
101
+ data: {
102
+ ari: ari,
103
+ containerAri: containerAri
104
+ },
105
+ reason: 'unmount'
106
+ }
107
+ });
108
+ };
109
+ }, [experienceInstance, containerAri, ari]);
110
+ /**
111
+ * Maps the store instance "reactions" data to the <Reactions /> component state data
112
+ * @param state store instance latest data
113
+ */
114
+
115
+ var mapStateToProps = useCallback(function (state) {
116
+ return mapStateToPropsHelper(containerAri, ari, state);
117
+ }, [containerAri, ari]);
118
+ /**
119
+ * Map the store instance "actions" methods to the <Reactions /> component actions methods
120
+ * @param actions list of actions in the store instance
121
+ */
122
+
123
+ var mapDispatchToProps = useCallback(function (actions) {
124
+ return mapDispatchToPropsHelper(actions, containerAri, ari);
125
+ }, [ari, containerAri]);
126
+ useEffect(function () {
127
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
128
+ var _store, state, dispatch;
129
+
130
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
131
+ while (1) {
132
+ switch (_context.prev = _context.next) {
133
+ case 0:
134
+ _context.next = 2;
135
+ return Promise.resolve(store);
136
+
137
+ case 2:
138
+ _store = _context.sent;
139
+
140
+ if (_store.setCreateAnalyticsEvent && createAnalyticsEvent) {
141
+ _store.setCreateAnalyticsEvent(createAnalyticsEvent);
142
+ }
143
+
144
+ state = mapStateToProps(_store.getState());
145
+ dispatch = mapDispatchToProps(_store);
146
+ setStateData(state);
147
+ setDispatchData(dispatch);
148
+
149
+ case 8:
150
+ case "end":
151
+ return _context.stop();
152
+ }
153
+ }
154
+ }, _callee);
155
+ }))();
156
+ }, [createAnalyticsEvent, store, ari, containerAri, mapStateToProps, mapDispatchToProps]);
157
+ /**
158
+ * Listen to changes on the store data.
159
+ * TODO: Needs to be refactored inside the MemoryReactionsStore to different pattern, currently it relies on internal callbacks variable to trigger changes to the store.
160
+ * The flow that each action method triggers a call to "setState" => "triggerOnChange" => calls the callback function registered by the onChange method and de-register by the "removeOnChangeListener" method
161
+ */
162
+
163
+ useEffect(function () {
164
+ var onChangeCallback = function onChangeCallback(state) {
165
+ var stateProps = mapStateToProps(state);
166
+ setStateData(stateProps);
167
+ };
168
+
169
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
170
+ var _store;
171
+
172
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
173
+ while (1) {
174
+ switch (_context2.prev = _context2.next) {
175
+ case 0:
176
+ _context2.next = 2;
177
+ return Promise.resolve(store);
178
+
179
+ case 2:
180
+ _store = _context2.sent;
181
+
182
+ _store.onChange(onChangeCallback);
183
+
184
+ case 4:
185
+ case "end":
186
+ return _context2.stop();
187
+ }
188
+ }
189
+ }, _callee2);
190
+ }))();
191
+
192
+ return function cleanup() {
193
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
194
+ var _store;
195
+
196
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
197
+ while (1) {
198
+ switch (_context3.prev = _context3.next) {
199
+ case 0:
200
+ _context3.next = 2;
201
+ return Promise.resolve(store);
202
+
203
+ case 2:
204
+ _store = _context3.sent;
205
+
206
+ _store.removeOnChangeListener(onChangeCallback);
207
+
208
+ case 4:
209
+ case "end":
210
+ return _context3.stop();
211
+ }
212
+ }
213
+ }, _callee3);
214
+ }))();
215
+ };
216
+ }, [mapStateToProps, store]);
217
+ return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
218
+ data: {
219
+ containerAri: containerAri,
220
+ ari: ari
221
+ }
222
+ }, /*#__PURE__*/React.createElement(UfoErrorBoundary, {
223
+ experiences: experienceInstance.current ? [experienceInstance.current] : []
224
+ }, stateData && dispatchData ? /*#__PURE__*/React.createElement(Reactions, _extends({
225
+ key: "".concat(props.containerAri, "|").concat(props.ari)
226
+ }, props, dispatchData, stateData)) : null));
227
+ };
@@ -0,0 +1 @@
1
+ export { ConnectedReactionsView } from './ConnectedReactionsView';
@@ -1,2 +1,2 @@
1
- export { ConnectedReactionPicker } from './ConnectedReactionPicker';
2
- export { ConnectedReactionsView } from './ConnectedReactionsView';
1
+ export * from './ConnectedReactionPicker';
2
+ export * from './ConnectedReactionsView';
@@ -0,0 +1 @@
1
+ export { useClickAway } from './useClickAway';
@@ -0,0 +1,28 @@
1
+ import { useEffect } from 'react';
2
+ /**
3
+ * Custom hook to detect when user action is outside given container ref
4
+ * @param ref ref object to an html element
5
+ * @param callback event callback when detected a click outside the ref object
6
+ * @param type (Optional) type of event to listen to. @default click
7
+ */
8
+
9
+ export function useClickAway(ref, callback) {
10
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'click';
11
+ useEffect(function () {
12
+ /**
13
+ * Alert if clicked on outside of element
14
+ */
15
+ function handleClickOutside(event) {
16
+ if (ref.current && event.target instanceof Node && !ref.current.contains(event.target)) {
17
+ callback();
18
+ }
19
+ } // Bind the event listener
20
+
21
+
22
+ document.addEventListener(type, handleClickOutside);
23
+ return function () {
24
+ // Unbind the event listener on clean up
25
+ document.removeEventListener(type, handleClickOutside);
26
+ };
27
+ }, [ref, callback, type]);
28
+ }
package/dist/esm/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  export { UFO } from './analytics';
2
- export { ReactionServiceClient } from './client';
2
+ export { ReactionServiceClient } from './client'; // TODO: Convert all calls for ReactionRequest to Request, RequestClient to Client and ReactionsStore to Store
3
+
4
+ export { constants } from './shared';
3
5
  export { Reaction, ReactionPicker, Reactions } from './components';
4
6
  export { ConnectedReactionPicker, ConnectedReactionsView } from './containers';
5
7
  export { MemoryReactionsStore, ReactionConsumer } from './store';
@@ -1,4 +1,34 @@
1
- // site id for jdog.jira-dev.com
2
- export var demoCloudId = "49d8b9d6-ee7d-4931-a0ca-7fcae7d1c3b5";
3
- export var AriPrefix = "ari:cloud:test:".concat(demoCloudId, ":item/");
4
- export var ContainerAriPrefix = "ari:cloud:test:".concat(demoCloudId, ":container/");
1
+ /**
2
+ * Initial list of emoji to pick from
3
+ */
4
+ export var DefaultReactions = [{
5
+ id: '1f44d',
6
+ shortName: ':thumbsup:'
7
+ }, {
8
+ id: '1f44f',
9
+ shortName: ':clap:'
10
+ }, {
11
+ id: '1f525',
12
+ shortName: ':fire:'
13
+ }, {
14
+ id: '2764',
15
+ shortName: ':heart:'
16
+ }, {
17
+ id: '1f632',
18
+ shortName: ':astonished:'
19
+ }, {
20
+ id: '1f914',
21
+ shortName: ':thinking:'
22
+ }];
23
+ /**
24
+ * ES6 Map object from default emoji reactions (with key => shortName, value => entire emoji item)
25
+ */
26
+
27
+ export var DefaultReactionsByShortName = new Map(DefaultReactions.map(function (reaction) {
28
+ return [reaction.shortName, reaction];
29
+ }));
30
+ /**
31
+ * Maximum number of users to show in the tooltip for an emoji reaction
32
+ */
33
+
34
+ export var TOOLTIP_USERS_LIMIT = 5;
@@ -12,7 +12,7 @@ export var messages = defineMessages({
12
12
  },
13
13
  unexpectedError: {
14
14
  id: 'fabric.reactions.error.unexpected',
15
- defaultMessage: 'Something went wrong',
15
+ defaultMessage: 'Reactions are temporarily unavailable',
16
16
  description: 'Unexpected error message'
17
17
  },
18
18
  otherUsers: {
@@ -1,2 +1,6 @@
1
- import * as _Constants from './constants';
2
- export { _Constants as Constants };
1
+ import * as _constants from './constants';
2
+ export { _constants as constants };
3
+ import * as _utils from './utils';
4
+ export { _utils as utils };
5
+ import * as _i18n from './i18n';
6
+ export { _i18n as i18n };
@@ -0,0 +1,41 @@
1
+ import { DefaultReactions } from './constants';
2
+ /**
3
+ * Is selected mouse event a left click
4
+ * @param event event data
5
+ */
6
+
7
+ export var isLeftClick = function isLeftClick(event) {
8
+ return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
9
+ };
10
+ /**
11
+ * Does provided item part of the default emoji ids
12
+ * @param item selected emoji item
13
+ */
14
+
15
+ export var isDefaultReaction = function isDefaultReaction(item) {
16
+ return DefaultReactions.some(function (otherEmojiId) {
17
+ return isEqualEmojiId(otherEmojiId, item);
18
+ });
19
+ };
20
+ /**
21
+ * compare 2 emoji items if they are same input
22
+ * @param a first emoji item
23
+ * @param b second emoji item
24
+ */
25
+
26
+ var isEqualEmojiId = function isEqualEmojiId(a, b) {
27
+ if (isEmojiId(a) && isEmojiId(b)) {
28
+ return a === b || a && b && a.id === b.id && a.shortName === b.shortName;
29
+ } else {
30
+ return a === b;
31
+ }
32
+ };
33
+ /**
34
+ * Type guard if provided object is a string id or an object info collection for the emoji
35
+ * @param item given item
36
+ */
37
+
38
+
39
+ var isEmojiId = function isEmojiId(item) {
40
+ return item.id !== undefined;
41
+ };
@@ -6,30 +6,27 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
 
7
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
- import * as Analytics from '../analytics';
9
+ import { Analytics, UFO } from '../analytics';
10
10
  import * as Types from '../types';
11
11
  import { batch, batchByKey } from './batched';
12
12
  import * as utils from './utils';
13
13
  import { isRealErrorFromService } from './utils';
14
14
  import { SAMPLING_RATE_REACTIONS_RENDERED_EXP } from '../analytics/constants';
15
15
  import { sampledReactionsRendered } from '../analytics/ufo';
16
- /**
17
- * store main structure
18
- */
19
-
20
16
  /**
21
17
  * Set of all available UFO experiences relating to reaction element
22
18
  */
19
+
23
20
  export var ufoExperiences = {
24
21
  /**
25
22
  * Experience when a reaction emoji gets added
26
23
  */
27
- add: Analytics.UFO.ReactionsAdd,
24
+ add: UFO.ReactionsAdd,
28
25
 
29
26
  /**
30
27
  * Experience when a reaction emoji gets removed/decrement
31
28
  */
32
- remove: Analytics.UFO.ReactionsRemove,
29
+ remove: UFO.ReactionsRemove,
33
30
 
34
31
  /**
35
32
  * Experience when the list of reactions gets rendered with sampling
@@ -41,26 +38,28 @@ export var ufoExperiences = {
41
38
  /**
42
39
  * Experience when a reaction details gets fetched
43
40
  */
44
- fetchDetails: Analytics.UFO.ReactionDetailsFetch
41
+ fetchDetails: UFO.ReactionDetailsFetch
45
42
  };
46
43
  /**
47
- * Collection of methods to manage internal state across the different Reaction container components ConnectedReactionPicker and ConnectedReactionsView
44
+ * Optional metadata information in the store used in sending the API client requests
48
45
  */
49
46
 
50
47
  export var MemoryReactionsStore = /*#__PURE__*/function () {
51
- function MemoryReactionsStore(client) {
48
+ /**
49
+ * default initial store data
50
+ */
51
+ function MemoryReactionsStore(client, state, metadata) {
52
52
  var _this = this;
53
53
 
54
- var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
55
- reactions: {},
56
- flash: {}
57
- };
58
- var metadata = arguments.length > 2 ? arguments[2] : undefined;
59
-
60
54
  _classCallCheck(this, MemoryReactionsStore);
61
55
 
62
56
  _defineProperty(this, "callbacks", []);
63
57
 
58
+ _defineProperty(this, "initialState", {
59
+ reactions: {},
60
+ flash: {}
61
+ });
62
+
64
63
  _defineProperty(this, "setState", function (newState) {
65
64
  _this.state = _objectSpread(_objectSpread({}, _this.state), newState);
66
65
 
@@ -160,7 +159,7 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
160
159
 
161
160
  exp.success();
162
161
  }).catch(function (error) {
163
- if (_this.createAnalyticsEvent && isRealErrorFromService(error.code)) {
162
+ if (isRealErrorFromService(error.code)) {
164
163
  _this.createAnalyticsEvent && Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'addReaction', error.code); // ufo add reaction failure
165
164
 
166
165
  exp.failure({
@@ -246,7 +245,7 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
246
245
  }).catch(function (error) {
247
246
  if (isRealErrorFromService(error.code)) {
248
247
  if (_this.createAnalyticsEvent) {
249
- Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'getReactions', error.code);
248
+ Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'getReactions');
250
249
  }
251
250
 
252
251
  sampledExp.failure({
@@ -260,8 +259,20 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
260
259
  reason: 'getReactions fetch failed'
261
260
  }
262
261
  });
263
- return Promise.reject(error);
264
262
  }
263
+
264
+ var reactionsState = arisArr.reduce(function (acc, ari) {
265
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, "".concat(containerAri, "|").concat(ari), {
266
+ reactions: [],
267
+ status: Types.ReactionStatus.error
268
+ }));
269
+ }, {});
270
+
271
+ _this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
272
+ reactions: _objectSpread(_objectSpread({}, _this.state.reactions), reactionsState)
273
+ }));
274
+
275
+ return Promise.reject(error);
265
276
  });
266
277
  }));
267
278
 
@@ -310,9 +321,14 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
310
321
  });
311
322
 
312
323
  this.client = client;
313
- this.state = state;
324
+ this.state = state !== null && state !== void 0 ? state : this.initialState;
314
325
  this.metadata = metadata;
315
326
  }
327
+ /**
328
+ * Update the store state data with a new data
329
+ * @param newState new store data
330
+ */
331
+
316
332
 
317
333
  _createClass(MemoryReactionsStore, [{
318
334
  key: "getReactionsState",
@@ -1,3 +1,4 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
@@ -5,12 +6,18 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
10
 
9
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
12
 
11
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
14
 
13
15
  import React from 'react';
16
+
17
+ /**
18
+ * A custom mapper class that takes the store instance and mapper functions "mapStateToProps" and "mapActionsToProps" to return the renderProps pattern as a child component
19
+ * @deprecated please avoid using this class as it will be removed in a future release
20
+ */
14
21
  export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
15
22
  _inherits(ReactionConsumer, _React$PureComponent);
16
23
 
@@ -24,11 +31,11 @@ export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
24
31
  _this = _super.call(this, props);
25
32
 
26
33
  _defineProperty(_assertThisInitialized(_this), "getPropsFromActions", function (actions) {
27
- var actionsMapper = _this.props.actionsMapper;
34
+ var mapActionsToProps = _this.props.mapActionsToProps;
28
35
 
29
- if (actionsMapper) {
36
+ if (mapActionsToProps) {
30
37
  if (!_this.previousActions || !_this.propsFromActions || _this.previousActions !== actions) {
31
- _this.propsFromActions = actionsMapper(actions);
38
+ _this.propsFromActions = mapActionsToProps(actions);
32
39
  }
33
40
  }
34
41
 
@@ -37,20 +44,17 @@ export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
37
44
  });
38
45
 
39
46
  _defineProperty(_assertThisInitialized(_this), "getPropsFromState", function (state) {
40
- var stateMapper = _this.props.stateMapper;
41
-
42
- if (stateMapper) {
43
- return stateMapper(state);
44
- }
45
-
46
- return undefined;
47
+ var mapStateToProps = _this.props.mapStateToProps;
48
+ return mapStateToProps ? mapStateToProps(state) : undefined;
47
49
  });
48
50
 
49
51
  _defineProperty(_assertThisInitialized(_this), "handleOnChange", function () {
50
52
  _this.forceUpdate();
51
53
  });
52
54
 
53
- _this.state = {};
55
+ _this.state = {
56
+ store: undefined
57
+ };
54
58
  return _this;
55
59
  }
56
60
 
@@ -69,11 +73,34 @@ export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
69
73
  }
70
74
  }, {
71
75
  key: "componentWillUnmount",
72
- value: function componentWillUnmount() {
73
- if (this.state.store) {
74
- this.state.store.removeOnChangeListener(this.handleOnChange);
76
+ value: function () {
77
+ var _componentWillUnmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
78
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
79
+ while (1) {
80
+ switch (_context.prev = _context.next) {
81
+ case 0:
82
+ if (this.state.store) {
83
+ this.state.store.removeOnChangeListener(this.handleOnChange);
84
+ }
85
+
86
+ case 1:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }
91
+ }, _callee, this);
92
+ }));
93
+
94
+ function componentWillUnmount() {
95
+ return _componentWillUnmount.apply(this, arguments);
75
96
  }
76
- }
97
+
98
+ return componentWillUnmount;
99
+ }()
100
+ /**
101
+ * Get the actions the child component might need to dispatch from its props
102
+ */
103
+
77
104
  }, {
78
105
  key: "render",
79
106
  value: function render() {
@@ -1,2 +1,2 @@
1
1
  export { ReactionConsumer } from './ReactionConsumer';
2
- export { MemoryReactionsStore } from './ReactionsStore';
2
+ export { MemoryReactionsStore, ufoExperiences } from './MemoryReactionsStore';
@@ -4,11 +4,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
- import { ReactionStatus } from '../types/ReactionStatus';
8
- export var compareEmojiId = function compareEmojiId(l, r) {
7
+ import { ReactionStatus } from '../types';
8
+
9
+ var compareEmojiId = function compareEmojiId(l, r) {
9
10
  return l.localeCompare(r);
10
11
  };
11
- export var sortByRelevance = function sortByRelevance(a, b) {
12
+
13
+ var sortByRelevance = function sortByRelevance(a, b) {
12
14
  if (a.count > b.count) {
13
15
  return -1;
14
16
  } else if (a.count < b.count) {
@@ -17,7 +19,8 @@ export var sortByRelevance = function sortByRelevance(a, b) {
17
19
  return compareEmojiId(a.emojiId, b.emojiId);
18
20
  }
19
21
  };
20
- export var sortByPreviousPosition = function sortByPreviousPosition(reactions) {
22
+
23
+ var sortByPreviousPosition = function sortByPreviousPosition(reactions) {
21
24
  var indexes = reactions.reduce(function (map, reaction, index) {
22
25
  map[reaction.emojiId] = index;
23
26
  return map;
@@ -32,6 +35,7 @@ export var sortByPreviousPosition = function sortByPreviousPosition(reactions) {
32
35
  return getPosition(a) - getPosition(b);
33
36
  };
34
37
  };
38
+
35
39
  export var readyState = function readyState(reactions) {
36
40
  return {
37
41
  status: ReactionStatus.ready,
@@ -1 +1 @@
1
- export { ReactionStatus } from './ReactionStatus';
1
+ export { ReactionStatus } from './reaction';