@atlaskit/reactions 21.4.0 → 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 (319) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/MockReactionsClient/package.json +7 -0
  3. package/dist/cjs/MockReactionsClient.js +276 -0
  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/components/{Counter.js → Counter/Counter.js} +32 -39
  8. package/dist/cjs/components/Counter/index.js +36 -0
  9. package/dist/cjs/components/Counter/styles.js +33 -0
  10. package/dist/cjs/components/EmojiButton/EmojiButton.js +58 -0
  11. package/dist/cjs/components/EmojiButton/index.js +19 -0
  12. package/dist/cjs/components/EmojiButton/styles.js +25 -0
  13. package/dist/cjs/components/FlashAnimation/FlashAnimation.js +42 -0
  14. package/dist/cjs/components/FlashAnimation/index.js +19 -0
  15. package/dist/cjs/components/{FlashAnimation.js → FlashAnimation/styles.js} +7 -26
  16. package/dist/cjs/components/Reaction/Reaction.js +163 -0
  17. package/dist/cjs/components/Reaction/index.js +19 -0
  18. package/dist/cjs/components/Reaction/styles.js +70 -0
  19. package/dist/cjs/components/ReactionPicker/ReactionPicker.js +272 -0
  20. package/dist/cjs/components/ReactionPicker/index.js +19 -0
  21. package/dist/cjs/components/ReactionPicker/styles.js +37 -0
  22. package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +71 -0
  23. package/dist/cjs/components/ReactionTooltip/index.js +19 -0
  24. package/dist/cjs/components/ReactionTooltip/styles.js +46 -0
  25. package/dist/cjs/components/Reactions/Reactions.js +200 -0
  26. package/dist/cjs/components/Reactions/index.js +25 -0
  27. package/dist/cjs/components/Reactions/styles.js +29 -0
  28. package/dist/cjs/components/Selector/Selector.js +132 -0
  29. package/dist/cjs/components/Selector/index.js +30 -0
  30. package/dist/cjs/components/Selector/styles.js +56 -0
  31. package/dist/cjs/components/ShowMore/ShowMore.js +71 -0
  32. package/dist/cjs/components/ShowMore/index.js +19 -0
  33. package/dist/cjs/components/ShowMore/styles.js +44 -0
  34. package/dist/cjs/components/Trigger/Trigger.js +59 -0
  35. package/dist/cjs/components/Trigger/index.js +13 -0
  36. package/dist/cjs/components/Trigger/styles.js +46 -0
  37. package/dist/cjs/components/{UfoErrorBoundary.js → UfoErrorBoundary/UfoErrorBoundary.js} +3 -0
  38. package/dist/cjs/components/UfoErrorBoundary/index.js +13 -0
  39. package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +62 -0
  40. package/dist/cjs/containers/ConnectedReactionPicker/index.js +13 -0
  41. package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +258 -0
  42. package/dist/cjs/containers/ConnectedReactionsView/index.js +13 -0
  43. package/dist/cjs/containers/index.js +23 -13
  44. package/dist/cjs/hooks/index.js +13 -0
  45. package/dist/cjs/hooks/useClickAway.js +35 -0
  46. package/dist/cjs/index.js +8 -0
  47. package/dist/cjs/shared/constants.js +44 -0
  48. package/dist/cjs/{components → shared}/i18n.js +1 -1
  49. package/dist/cjs/shared/index.js +24 -0
  50. package/dist/cjs/shared/utils.js +54 -0
  51. package/dist/cjs/store/{ReactionsStore.js → MemoryReactionsStore.js} +41 -18
  52. package/dist/cjs/store/ReactionConsumer.js +43 -15
  53. package/dist/cjs/store/index.js +8 -2
  54. package/dist/cjs/store/utils.js +4 -10
  55. package/dist/cjs/{client/ReactionClient.js → types/client.js} +0 -0
  56. package/dist/cjs/types/index.js +2 -2
  57. package/dist/cjs/types/reaction.js +43 -0
  58. package/dist/cjs/types/{DetailedReaction.js → store.js} +0 -0
  59. package/dist/cjs/version.json +1 -1
  60. package/dist/es2019/MockReactionsClient.js +126 -0
  61. package/dist/es2019/analytics/analytics.js +64 -0
  62. package/dist/es2019/analytics/index.js +3 -65
  63. package/dist/es2019/analytics/ufo.js +0 -1
  64. package/dist/es2019/client/ReactionServiceClient.js +31 -6
  65. package/dist/es2019/components/{Counter.js → Counter/Counter.js} +26 -31
  66. package/dist/es2019/components/Counter/index.js +3 -0
  67. package/dist/es2019/components/Counter/styles.js +20 -0
  68. package/dist/es2019/components/EmojiButton/EmojiButton.js +35 -0
  69. package/dist/es2019/components/EmojiButton/index.js +1 -0
  70. package/dist/es2019/components/EmojiButton/styles.js +16 -0
  71. package/dist/es2019/components/FlashAnimation/FlashAnimation.js +18 -0
  72. package/dist/es2019/components/FlashAnimation/index.js +1 -0
  73. package/dist/es2019/components/{FlashAnimation.js → FlashAnimation/styles.js} +6 -17
  74. package/dist/es2019/components/Reaction/Reaction.js +104 -0
  75. package/dist/es2019/components/Reaction/index.js +1 -0
  76. package/dist/es2019/components/Reaction/styles.js +55 -0
  77. package/dist/es2019/components/ReactionPicker/ReactionPicker.js +208 -0
  78. package/dist/es2019/components/ReactionPicker/index.js +1 -0
  79. package/dist/es2019/components/ReactionPicker/styles.js +23 -0
  80. package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +46 -0
  81. package/dist/es2019/components/ReactionTooltip/index.js +1 -0
  82. package/dist/es2019/components/ReactionTooltip/styles.js +32 -0
  83. package/dist/es2019/components/Reactions/Reactions.js +156 -0
  84. package/dist/es2019/components/Reactions/index.js +1 -0
  85. package/dist/es2019/components/Reactions/styles.js +19 -0
  86. package/dist/es2019/components/Selector/Selector.js +98 -0
  87. package/dist/es2019/components/Selector/index.js +3 -0
  88. package/dist/es2019/components/Selector/styles.js +39 -0
  89. package/dist/es2019/components/ShowMore/ShowMore.js +43 -0
  90. package/dist/es2019/components/ShowMore/index.js +1 -0
  91. package/dist/es2019/components/ShowMore/styles.js +30 -0
  92. package/dist/es2019/components/{Trigger.js → Trigger/Trigger.js} +15 -20
  93. package/dist/es2019/components/Trigger/index.js +1 -0
  94. package/dist/es2019/components/Trigger/styles.js +24 -0
  95. package/dist/es2019/components/{UfoErrorBoundary.js → UfoErrorBoundary/UfoErrorBoundary.js} +4 -0
  96. package/dist/es2019/components/UfoErrorBoundary/index.js +1 -0
  97. package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +27 -0
  98. package/dist/es2019/containers/ConnectedReactionPicker/index.js +1 -0
  99. package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +166 -0
  100. package/dist/es2019/containers/ConnectedReactionsView/index.js +1 -0
  101. package/dist/es2019/containers/index.js +2 -2
  102. package/dist/es2019/hooks/index.js +1 -0
  103. package/dist/es2019/hooks/useClickAway.js +27 -0
  104. package/dist/es2019/index.js +3 -1
  105. package/dist/es2019/shared/constants.js +32 -0
  106. package/dist/es2019/{components → shared}/i18n.js +1 -1
  107. package/dist/es2019/shared/index.js +6 -0
  108. package/dist/es2019/shared/utils.js +35 -0
  109. package/dist/es2019/store/{ReactionsStore.js → MemoryReactionsStore.js} +40 -14
  110. package/dist/es2019/store/ReactionConsumer.js +18 -12
  111. package/dist/es2019/store/index.js +1 -1
  112. package/dist/es2019/store/utils.js +8 -4
  113. package/dist/es2019/{client/ReactionClient.js → types/client.js} +0 -0
  114. package/dist/es2019/types/index.js +1 -1
  115. package/dist/es2019/types/reaction.js +34 -0
  116. package/dist/es2019/types/{DetailedReaction.js → store.js} +0 -0
  117. package/dist/es2019/version.json +1 -1
  118. package/dist/esm/MockReactionsClient.js +257 -0
  119. package/dist/esm/analytics/analytics.js +99 -0
  120. package/dist/esm/analytics/index.js +3 -99
  121. package/dist/esm/analytics/ufo.js +0 -1
  122. package/dist/esm/client/ReactionServiceClient.js +30 -6
  123. package/dist/esm/components/{Counter.js → Counter/Counter.js} +26 -31
  124. package/dist/esm/components/Counter/index.js +3 -0
  125. package/dist/esm/components/Counter/styles.js +20 -0
  126. package/dist/esm/components/EmojiButton/EmojiButton.js +35 -0
  127. package/dist/esm/components/EmojiButton/index.js +1 -0
  128. package/dist/esm/components/EmojiButton/styles.js +16 -0
  129. package/dist/esm/components/FlashAnimation/FlashAnimation.js +20 -0
  130. package/dist/esm/components/FlashAnimation/index.js +1 -0
  131. package/dist/esm/components/{FlashAnimation.js → FlashAnimation/styles.js} +6 -19
  132. package/dist/esm/components/Reaction/Reaction.js +131 -0
  133. package/dist/esm/components/Reaction/index.js +1 -0
  134. package/dist/esm/components/Reaction/styles.js +55 -0
  135. package/dist/esm/components/ReactionPicker/ReactionPicker.js +243 -0
  136. package/dist/esm/components/ReactionPicker/index.js +1 -0
  137. package/dist/esm/components/ReactionPicker/styles.js +23 -0
  138. package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +46 -0
  139. package/dist/esm/components/ReactionTooltip/index.js +1 -0
  140. package/dist/esm/components/ReactionTooltip/styles.js +32 -0
  141. package/dist/esm/components/Reactions/Reactions.js +166 -0
  142. package/dist/esm/components/Reactions/index.js +1 -0
  143. package/dist/esm/components/Reactions/styles.js +19 -0
  144. package/dist/esm/components/Selector/Selector.js +107 -0
  145. package/dist/esm/components/Selector/index.js +3 -0
  146. package/dist/esm/components/Selector/styles.js +41 -0
  147. package/dist/esm/components/ShowMore/ShowMore.js +46 -0
  148. package/dist/esm/components/ShowMore/index.js +1 -0
  149. package/dist/esm/components/ShowMore/styles.js +30 -0
  150. package/dist/esm/components/{Trigger.js → Trigger/Trigger.js} +15 -20
  151. package/dist/esm/components/Trigger/index.js +1 -0
  152. package/dist/esm/components/Trigger/styles.js +31 -0
  153. package/dist/esm/components/{UfoErrorBoundary.js → UfoErrorBoundary/UfoErrorBoundary.js} +4 -0
  154. package/dist/esm/components/UfoErrorBoundary/index.js +1 -0
  155. package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +46 -0
  156. package/dist/esm/containers/ConnectedReactionPicker/index.js +1 -0
  157. package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +227 -0
  158. package/dist/esm/containers/ConnectedReactionsView/index.js +1 -0
  159. package/dist/esm/containers/index.js +2 -2
  160. package/dist/esm/hooks/index.js +1 -0
  161. package/dist/esm/hooks/useClickAway.js +28 -0
  162. package/dist/esm/index.js +3 -1
  163. package/dist/esm/shared/constants.js +34 -0
  164. package/dist/esm/{components → shared}/i18n.js +1 -1
  165. package/dist/esm/shared/index.js +6 -0
  166. package/dist/esm/shared/utils.js +41 -0
  167. package/dist/esm/store/{ReactionsStore.js → MemoryReactionsStore.js} +40 -17
  168. package/dist/esm/store/ReactionConsumer.js +42 -15
  169. package/dist/esm/store/index.js +1 -1
  170. package/dist/esm/store/utils.js +8 -4
  171. package/dist/{es2019/types/ReactionSource.js → esm/types/client.js} +0 -0
  172. package/dist/esm/types/index.js +1 -1
  173. package/dist/esm/types/reaction.js +34 -0
  174. package/dist/{es2019/types/ReactionSummary.js → esm/types/store.js} +0 -0
  175. package/dist/esm/version.json +1 -1
  176. package/dist/types/MockReactionsClient.d.ts +20 -0
  177. package/dist/types/analytics/analytics.d.ts +96 -0
  178. package/dist/types/analytics/index.d.ts +1 -96
  179. package/dist/types/client/ReactionServiceClient.d.ts +27 -10
  180. package/dist/types/client/index.d.ts +0 -1
  181. package/dist/types/components/Counter/Counter.d.ts +40 -0
  182. package/dist/types/components/Counter/index.d.ts +3 -0
  183. package/dist/types/components/Counter/styles.d.ts +3 -0
  184. package/dist/types/components/EmojiButton/EmojiButton.d.ts +22 -0
  185. package/dist/types/components/EmojiButton/index.d.ts +2 -0
  186. package/dist/types/components/EmojiButton/styles.d.ts +1 -0
  187. package/dist/types/components/FlashAnimation/FlashAnimation.d.ts +20 -0
  188. package/dist/types/components/FlashAnimation/index.d.ts +2 -0
  189. package/dist/types/components/FlashAnimation/styles.d.ts +3 -0
  190. package/dist/types/components/Reaction/Reaction.d.ts +38 -0
  191. package/dist/types/components/Reaction/index.d.ts +2 -0
  192. package/dist/types/components/Reaction/styles.d.ts +10 -0
  193. package/dist/types/components/ReactionPicker/ReactionPicker.d.ts +53 -0
  194. package/dist/types/components/ReactionPicker/index.d.ts +2 -0
  195. package/dist/types/components/ReactionPicker/styles.d.ts +3 -0
  196. package/dist/types/components/ReactionTooltip/ReactionTooltip.d.ts +22 -0
  197. package/dist/types/components/ReactionTooltip/index.d.ts +2 -0
  198. package/dist/types/components/ReactionTooltip/styles.d.ts +4 -0
  199. package/dist/types/components/Reactions/Reactions.d.ts +64 -0
  200. package/dist/types/components/Reactions/index.d.ts +2 -0
  201. package/dist/types/components/Reactions/styles.d.ts +2 -0
  202. package/dist/types/components/Selector/Selector.d.ts +34 -0
  203. package/dist/types/components/Selector/index.d.ts +3 -0
  204. package/dist/types/components/Selector/styles.d.ts +10 -0
  205. package/dist/types/components/ShowMore/ShowMore.d.ts +34 -0
  206. package/dist/types/components/ShowMore/index.d.ts +2 -0
  207. package/dist/types/components/ShowMore/styles.d.ts +3 -0
  208. package/dist/types/components/Trigger/Trigger.d.ts +23 -0
  209. package/dist/types/components/Trigger/index.d.ts +2 -0
  210. package/dist/types/components/Trigger/styles.d.ts +5 -0
  211. package/dist/types/components/UfoErrorBoundary/UfoErrorBoundary.d.ts +16 -0
  212. package/dist/types/components/UfoErrorBoundary/index.d.ts +2 -0
  213. package/dist/types/components/index.d.ts +4 -1
  214. package/dist/types/containers/ConnectedReactionPicker/ConnectedReactionPicker.d.ts +27 -0
  215. package/dist/types/containers/ConnectedReactionPicker/index.d.ts +2 -0
  216. package/dist/types/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +52 -0
  217. package/dist/types/containers/ConnectedReactionsView/index.d.ts +2 -0
  218. package/dist/types/containers/index.d.ts +2 -2
  219. package/dist/types/hooks/index.d.ts +1 -0
  220. package/dist/types/hooks/useClickAway.d.ts +8 -0
  221. package/dist/types/index.d.ts +2 -2
  222. package/dist/types/shared/constants.d.ts +13 -0
  223. package/dist/types/{components → shared}/i18n.d.ts +0 -0
  224. package/dist/types/shared/index.d.ts +3 -0
  225. package/dist/types/shared/utils.d.ts +11 -0
  226. package/dist/types/store/{ReactionsStore.d.ts → MemoryReactionsStore.d.ts} +23 -26
  227. package/dist/types/store/ReactionConsumer.d.ts +47 -19
  228. package/dist/types/store/index.d.ts +2 -2
  229. package/dist/types/store/utils.d.ts +3 -7
  230. package/dist/types/types/Actions.d.ts +20 -4
  231. package/dist/types/types/User.d.ts +6 -0
  232. package/dist/types/types/client.d.ts +38 -0
  233. package/dist/types/types/index.d.ts +5 -7
  234. package/dist/types/types/reaction.d.ts +82 -0
  235. package/dist/types/types/store.d.ts +63 -0
  236. package/docs/0-intro.tsx +118 -27
  237. package/docs/1-connected-reaction-picker.tsx +133 -0
  238. package/docs/2-connected-reactions-view.tsx +130 -0
  239. package/docs/3-reactions-store.tsx +71 -0
  240. package/docs/4-reaction-service-client.tsx +42 -0
  241. package/extract-react-type/ConnectedReactionPicker.ts +6 -0
  242. package/extract-react-type/ConnectedReactionsView.ts +6 -0
  243. package/extract-react-type/Reaction.ts +6 -0
  244. package/extract-react-type/Reactions.ts +6 -0
  245. package/extract-react-type/actions.ts +6 -0
  246. package/extract-react-type/reactionClient.ts +6 -0
  247. package/extract-react-type/reactionsStore.ts +6 -0
  248. package/package.json +24 -7
  249. package/dist/cjs/client/MockReactionsClient.js +0 -183
  250. package/dist/cjs/components/EmojiButton.js +0 -100
  251. package/dist/cjs/components/Reaction.js +0 -226
  252. package/dist/cjs/components/ReactionPicker.js +0 -289
  253. package/dist/cjs/components/ReactionTooltip.js +0 -82
  254. package/dist/cjs/components/Reactions.js +0 -194
  255. package/dist/cjs/components/Selector.js +0 -189
  256. package/dist/cjs/components/ShowMore.js +0 -119
  257. package/dist/cjs/components/Trigger.js +0 -58
  258. package/dist/cjs/components/utils.js +0 -28
  259. package/dist/cjs/containers/ConnectedReactionPicker.js +0 -44
  260. package/dist/cjs/containers/ConnectedReactionsView.js +0 -139
  261. package/dist/cjs/types/ReactionSource.js +0 -5
  262. package/dist/cjs/types/ReactionStatus.js +0 -15
  263. package/dist/cjs/types/ReactionSummary.js +0 -5
  264. package/dist/cjs/types/Reactions.js +0 -5
  265. package/dist/cjs/types/ReactionsState.js +0 -5
  266. package/dist/es2019/client/MockReactionsClient.js +0 -123
  267. package/dist/es2019/components/EmojiButton.js +0 -50
  268. package/dist/es2019/components/Reaction.js +0 -180
  269. package/dist/es2019/components/ReactionPicker.js +0 -239
  270. package/dist/es2019/components/ReactionTooltip.js +0 -66
  271. package/dist/es2019/components/Reactions.js +0 -150
  272. package/dist/es2019/components/Selector.js +0 -127
  273. package/dist/es2019/components/ShowMore.js +0 -71
  274. package/dist/es2019/components/utils.js +0 -13
  275. package/dist/es2019/containers/ConnectedReactionPicker.js +0 -27
  276. package/dist/es2019/containers/ConnectedReactionsView.js +0 -118
  277. package/dist/es2019/types/ReactionStatus.js +0 -8
  278. package/dist/es2019/types/Reactions.js +0 -1
  279. package/dist/es2019/types/ReactionsState.js +0 -1
  280. package/dist/esm/client/MockReactionsClient.js +0 -164
  281. package/dist/esm/client/ReactionClient.js +0 -1
  282. package/dist/esm/components/EmojiButton.js +0 -77
  283. package/dist/esm/components/Reaction.js +0 -204
  284. package/dist/esm/components/ReactionPicker.js +0 -266
  285. package/dist/esm/components/ReactionTooltip.js +0 -63
  286. package/dist/esm/components/Reactions.js +0 -180
  287. package/dist/esm/components/Selector.js +0 -160
  288. package/dist/esm/components/ShowMore.js +0 -95
  289. package/dist/esm/components/utils.js +0 -15
  290. package/dist/esm/containers/ConnectedReactionPicker.js +0 -29
  291. package/dist/esm/containers/ConnectedReactionsView.js +0 -116
  292. package/dist/esm/types/DetailedReaction.js +0 -1
  293. package/dist/esm/types/ReactionSource.js +0 -1
  294. package/dist/esm/types/ReactionStatus.js +0 -8
  295. package/dist/esm/types/ReactionSummary.js +0 -1
  296. package/dist/esm/types/Reactions.js +0 -1
  297. package/dist/esm/types/ReactionsState.js +0 -1
  298. package/dist/types/client/MockReactionsClient.d.ts +0 -28
  299. package/dist/types/client/ReactionClient.d.ts +0 -25
  300. package/dist/types/components/Counter.d.ts +0 -14
  301. package/dist/types/components/EmojiButton.d.ts +0 -12
  302. package/dist/types/components/FlashAnimation.d.ts +0 -13
  303. package/dist/types/components/Reaction.d.ts +0 -25
  304. package/dist/types/components/ReactionPicker.d.ts +0 -39
  305. package/dist/types/components/ReactionTooltip.d.ts +0 -9
  306. package/dist/types/components/Reactions.d.ts +0 -49
  307. package/dist/types/components/Selector.d.ts +0 -27
  308. package/dist/types/components/ShowMore.d.ts +0 -21
  309. package/dist/types/components/Trigger.d.ts +0 -7
  310. package/dist/types/components/UfoErrorBoundary.d.ts +0 -9
  311. package/dist/types/components/utils.d.ts +0 -4
  312. package/dist/types/containers/ConnectedReactionPicker.d.ts +0 -10
  313. package/dist/types/containers/ConnectedReactionsView.d.ts +0 -19
  314. package/dist/types/types/DetailedReaction.d.ts +0 -7
  315. package/dist/types/types/ReactionSource.d.ts +0 -1
  316. package/dist/types/types/ReactionStatus.d.ts +0 -6
  317. package/dist/types/types/ReactionSummary.d.ts +0 -10
  318. package/dist/types/types/Reactions.d.ts +0 -4
  319. package/dist/types/types/ReactionsState.d.ts +0 -17
@@ -0,0 +1,82 @@
1
+ /// <reference types="react" />
2
+ import { User } from './User';
3
+ /**
4
+ * Collection of reactions as object (key is unique id from containerAri and ari combined)
5
+ */
6
+ export declare type Reactions = Record<string, ReactionSummary[]>;
7
+ /**
8
+ * MetaData for Reaction object
9
+ */
10
+ export interface ReactionSummary {
11
+ /**
12
+ * Reaction Asset id in the container
13
+ */
14
+ ari: string;
15
+ /**
16
+ * the container for reactions/ari in the page
17
+ */
18
+ containerAri: string;
19
+ /**
20
+ * unique Atlassian identifier for an emoji
21
+ */
22
+ emojiId: string;
23
+ /**
24
+ * Number of selected count for the emoji
25
+ */
26
+ count: number;
27
+ /**
28
+ * Has the current user selected the emoji or not
29
+ */
30
+ reacted: boolean;
31
+ /**
32
+ * Users collection
33
+ */
34
+ users?: User[];
35
+ /**
36
+ * @deprecated Legacy content Not in use anymore
37
+ */
38
+ optimisticallyUpdated?: boolean;
39
+ }
40
+ /**
41
+ * Event handler for when the user clicks on the reaction
42
+ * @param id give id for the emoji
43
+ * @param event selected mouse event proerties
44
+ */
45
+ export declare type ReactionClick = (id: string, event: React.MouseEvent<HTMLButtonElement>) => void;
46
+ /**
47
+ * Event handler for when the user hovers with the mouse on the reaction
48
+ * @param reaction reaction object
49
+ * @param event (Optional) custom DOM event handler callback
50
+ */
51
+ export declare type ReactionMouseEnter = (reaction: ReactionSummary, event?: React.MouseEvent<any>) => void;
52
+ /**
53
+ * Condition of the reaction when gets loaded from the store
54
+ */
55
+ export declare enum ReactionStatus {
56
+ ready = "READY",
57
+ loading = "LOADING",
58
+ error = "ERROR",
59
+ notLoaded = "NOT_LOADED"
60
+ }
61
+ /**
62
+ * state in which the reaction is at
63
+ */
64
+ export declare type ReactionsState = ReactionsNotLoaded | ReactionsLoading | ReactionsReadyState | ReactionsError;
65
+ export declare type ReactionsReadyState = {
66
+ readonly status: ReactionStatus.ready;
67
+ readonly reactions: ReactionSummary[];
68
+ };
69
+ export declare type ReactionsLoading = {
70
+ readonly status: ReactionStatus.loading;
71
+ };
72
+ export declare type ReactionsError = {
73
+ readonly status: ReactionStatus.error;
74
+ readonly message: string;
75
+ };
76
+ export declare type ReactionsNotLoaded = {
77
+ readonly status: ReactionStatus.notLoaded;
78
+ };
79
+ /**
80
+ * Source where the emoji selected from ("quickSelector" -> default list, "emojiPicker" -> custom emoji list)
81
+ */
82
+ export declare type ReactionSource = 'quickSelector' | 'emojiPicker';
@@ -0,0 +1,63 @@
1
+ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import { Actions } from './Actions';
3
+ import { ReactionsState } from './reaction';
4
+ /**
5
+ * Callback event when changes apply to the main store
6
+ * @param state latest store state
7
+ */
8
+ export declare type OnChangeCallback = (state: State) => void;
9
+ /**
10
+ * Map of state props
11
+ */
12
+ export interface StoreProps {
13
+ /**
14
+ * Get current state of the stor
15
+ */
16
+ getState: () => State;
17
+ /**
18
+ * Register a callbsack event on change to the store instance state data
19
+ * @param callback event to register
20
+ * @deprecated initially implemented by the MemoryReactionsStore class and kept. This will be removed in a future release
21
+ */
22
+ onChange: (callback: OnChangeCallback) => void;
23
+ /**
24
+ * Deregister any callback event on changes to the store instance state data
25
+ * @param callback event to de-register
26
+ * @deprecated initially implemented by the MemoryReactionsStore class and kept. This will be removed in a future release
27
+ */
28
+ removeOnChangeListener: (callback: OnChangeCallback) => void;
29
+ /**
30
+ * Add Atlaskit analytics events to different operations in the store
31
+ * @param createAnalyticsEvent analytics event trigger
32
+ * @deprecated initially implemented by the MemoryReactionsStore class and kept. This will be removed in a future release
33
+ */
34
+ setCreateAnalyticsEvent?: (createAnalyticsEvent: CreateUIAnalyticsEvent) => void;
35
+ }
36
+ /**
37
+ * General Interface for a reaction store
38
+ */
39
+ export interface Store extends Actions, StoreProps {
40
+ }
41
+ /**
42
+ * the "store" prop option to the connected view and picker components
43
+ */
44
+ export declare type StorePropInput = Store | Promise<Store>;
45
+ /**
46
+ * store main structure
47
+ */
48
+ export declare type State = {
49
+ /**
50
+ * collection of the different reactions (key => unique reaction id , value => state of the reaction)
51
+ */
52
+ reactions: {
53
+ [key: string]: ReactionsState;
54
+ };
55
+ /**
56
+ * custom animation for given emojis as true|false (key => unique reaction id, value => collection of emojiIds and true|false to apply custom animation)
57
+ */
58
+ flash: {
59
+ [key: string]: {
60
+ [emojiId: string]: boolean;
61
+ };
62
+ };
63
+ };
package/docs/0-intro.tsx CHANGED
@@ -6,27 +6,53 @@ import {
6
6
  code,
7
7
  AtlassianInternalWarning,
8
8
  } from '@atlaskit/docs';
9
+ import SectionMessage from '@atlaskit/section-message';
9
10
 
10
- import ReactionsExample from '../examples/00-picker-and-reactions';
11
-
12
- const ReactionsSource = require('!!raw-loader!../examples/00-picker-and-reactions');
13
-
14
- const ReactionsProps = require('!!extract-react-types-loader!../examples/examples-utils/ReactionsExampleWrapper');
11
+ import ReactionsExample from '../examples/01-connected-reactions-view';
15
12
 
16
13
  export default md`
17
14
  ${(<AtlassianInternalWarning />)}
18
15
 
19
16
  The main purpose of the Reactions component is to provide users the ability to react to pieces of content.
17
+ It includes support for adding/view/remove a reaction from a specified emoji provider object.
18
+
19
+ The key components to use are:
20
+ 1. [connectedReactionPicker](/packages/elements/reactions/docs/connected-reaction-picker)
21
+ 1. [connectedReactionsView](/packages/elements/reactions/docs/connected-reactions-view)
22
+
23
+ The key types to use are:
24
+ 1. [ReactionsStore](/packages/elements/reactions/docs/reactions-store)
25
+ 1. [ReactionServiceClient](/packages/elements/reactions/docs/reaction-service-client)
26
+ 1. [EmojiResource](https://atlaskit.atlassian.com/packages/elements/emoji/docs/resourced-emoji)
20
27
 
21
28
  ## Usage
22
29
 
23
- Import the component in your React app as follows:
30
+ For each of these components, first import the following in your React app as follows:
24
31
 
25
32
  ${code`
26
- import { ReactionStore, ConnectedReactionsView } from '@atlaskit/reactions';
27
- import { EmojiResource } from '@atlaskit/emoji/resource';
28
-
29
- const emojiProvider = new EmojiResource({
33
+ import { ReactionStore, ConnectedReactionsView, State, MemoryReactionsStore, ReactionServiceClient } from '@atlaskit/reactions';
34
+ import { EmojiResource, EmojiResourceConfig } from '@atlaskit/emoji/resource';
35
+
36
+ // Config object for the emoji resource
37
+ const config: EmojiResourceConfig = {
38
+ singleEmojiApi: {
39
+ getUrl: (emojiId: string) => 'https://emoji-example/emoji/site-id/emojiId',
40
+ securityProvider: () => ({
41
+ headers: {
42
+ 'User-Context': '{{token}}',
43
+ Authorization: 'Bearer {{token}}',
44
+ },
45
+ })
46
+ },
47
+ optimisticImageApi: {
48
+ getUrl: (emojiId: string) => 'https://emoji-example/emoji/site-id/emojiId/path',
49
+ securityProvider: () => ({
50
+ headers: {
51
+ 'User-Context': '{{token}}',
52
+ Authorization: 'Bearer {{token}}',
53
+ },
54
+ })
55
+ },
30
56
  providers: [
31
57
  {
32
58
  url: 'https://emoji-example/emoji/standard',
@@ -35,46 +61,111 @@ export default md`
35
61
  url: 'https://emoji-example/emoji/site-id/site',
36
62
  securityProvider: () => ({
37
63
  headers: {
38
- Authorization: 'Bearer token',
64
+ Authorization: 'Bearer {{token}}',
39
65
  },
40
66
  }),
41
67
  },
42
- ],
68
+ ]
69
+ };
70
+
71
+ const apiConfig = {
72
+ baseUrl: 'http://www.example.org',
73
+ // optional, generate token from asap, check \`pf-emoji-service\` for more info
74
+ authHeader: 'Bearer token',
75
+ };
76
+
77
+ // Create a client object fetching the reactions data from the specified url
78
+ const client = new ReactionServiceClient(apiConfig.baseUrl, apiConfig.authHeader);
79
+
80
+ // Define the initial state object
81
+ const intialState: State = {
82
+ reactions: {},
83
+ flash: {}
84
+ };
85
+
86
+ // Define the store object that will handle all the reactions data (get/set/remove) and the API calls to the server
87
+ const store = new MemoryReactionsStore(client, intialState, {
88
+ subproduct: 'atlaskit',
43
89
  });
44
90
 
45
- const demoAri = 'ari:cloud:owner:demo-cloud-id:item/1';
91
+ // Define an emoji resource object instance that will be passed as prop to the ConnectedReactionsView component
92
+ const emojiResource = new EmojiResource(config); //See warning below
93
+
94
+ /**
95
+ * fetch from all the providers in the config object and cache the results (see EmojiResource for more info).
96
+ * Note: this is a one time fetch, so if you want to fetch from the same providers again, you need to create a new EmojiResource instance. Furhermore, you'll need to handle for a failed fetch and retry requests if your app logic requires this.
97
+ */
98
+ emojiResource.fetchEmojiProvider();
99
+
100
+ // Retrieve your ari and containerAri values from the server
101
+ const ari = 'ari:cloud:owner:demo-cloud-id:item/1';
46
102
  const containerAri = 'ari:cloud:owner:demo-cloud-id:container/1';
47
103
 
104
+
105
+ // Render the component in your React app
48
106
  ReactDOM.render(
49
- <ReactionStore url="https://reactions-service">
50
- <ConnectedReactionsView
51
- containerAri={containerAri}
52
- ari={demoAri}
53
- emojiProvider={Promise.resolve(emojiProvider)}
54
- />
55
- </ReactionStore>,
107
+ <ConnectedReactionsView
108
+ store={store}
109
+ containerAri={containerAri}
110
+ ari={demoAri}
111
+ emojiProvider={Promise.resolve(emojiResource)}
112
+ />
56
113
  container,
57
- );
58
114
  };`}
59
115
 
116
+ ${(
117
+ <>
118
+ <br />
119
+ <SectionMessage
120
+ appearance="warning"
121
+ title="There should be only one instance of EmojiResource in your application"
122
+ >
123
+ <p>
124
+ Make sure EmojiResource is initialised only once to avoid performance
125
+ issues using useMemo.
126
+ </p>
127
+ </SectionMessage>
128
+ <br />
129
+ <SectionMessage appearance="information">
130
+ <p>EmojiResource object implements the EmojiProvider interface.</p>
131
+ <a
132
+ href="https://atlaskit.atlassian.com/packages/elements/emoji/docs/emoji-provider"
133
+ target="_blank"
134
+ rel="noopener noreferrer"
135
+ >
136
+ See here for information on EmojiProvider.
137
+ </a>
138
+ </SectionMessage>
139
+ </>
140
+ )}
141
+
60
142
  ### Note:
61
143
 
62
144
  Don't forget to add polyfills for fetch, ES6 & ES7 to your product build if you want to target older browsers.
63
145
  We recommend the use of [babel-preset-env](https://babeljs.io/docs/plugins/preset-env/) & [babel-polyfill](https://babeljs.io/docs/usage/polyfill/)
64
146
 
65
- Key navigation can be bound to \`selectNext\` (e.g. down arrow),
66
- \`selectPrevious\` (e.g. up arrow), and \`chooseCurrentSelection\`
67
- (e.g. enter and tab).
147
+ ### Example:
68
148
 
69
149
  ${(
70
150
  <Example
71
151
  packageName="@atlaskit/reactions"
72
152
  Component={ReactionsExample}
73
153
  title="Picker and Reactions"
74
- source={ReactionsSource}
154
+ source={require('!!raw-loader!../examples/01-connected-reactions-view')}
155
+ />
156
+ )}
157
+
158
+ ${(
159
+ <Props
160
+ heading="Reactions Props"
161
+ props={require('!!extract-react-types-loader!../extract-react-type/Reactions')}
75
162
  />
76
163
  )}
77
164
 
78
- ${(<Props props={ReactionsProps} />)}
79
165
 
80
- `;
166
+ ${(
167
+ <Props
168
+ heading="Reaction Props"
169
+ props={require('!!extract-react-types-loader!../extract-react-type/Reaction')}
170
+ />
171
+ )}`;
@@ -0,0 +1,133 @@
1
+ import React from 'react';
2
+ import { md, Example, code, Props } from '@atlaskit/docs';
3
+ import SectionMessage from '@atlaskit/section-message';
4
+
5
+ import ConnectedReactionPickerExample from '../examples/00-connected-reaction-picker';
6
+
7
+ export default md`
8
+
9
+ The ConnectedReactionPicker component renders the Reaction picker custom selector to add a new reaction to the content displayed.
10
+
11
+ ## Usage
12
+
13
+ Import the component in your React app as follows:
14
+
15
+ ${code`
16
+ import { ReactionStore, ConnectedReactionPicker, State, MemoryReactionsStore, ReactionServiceClient } from '@atlaskit/reactions';
17
+ import { EmojiResource, EmojiResourceConfig } from '@atlaskit/emoji/resource';
18
+
19
+ // Config object for the emoji resource
20
+ const config: EmojiResourceConfig = {
21
+ singleEmojiApi: {
22
+ getUrl: (emojiId: string) => 'https://emoji-example/emoji/site-id/emojiId',
23
+ securityProvider: () => ({
24
+ headers: {
25
+ 'User-Context': '{{token}}',
26
+ Authorization: 'Bearer {{token}}',
27
+ },
28
+ })
29
+ },
30
+ optimisticImageApi: {
31
+ getUrl: (emojiId: string) => 'https://emoji-example/emoji/site-id/emojiId/path',
32
+ securityProvider: () => ({
33
+ headers: {
34
+ 'User-Context': '{{token}}',
35
+ Authorization: 'Bearer {{token}}',
36
+ },
37
+ })
38
+ },
39
+ providers: [
40
+ {
41
+ url: 'https://emoji-example/emoji/standard',
42
+ },
43
+ {
44
+ url: 'https://emoji-example/emoji/site-id/site',
45
+ securityProvider: () => ({
46
+ headers: {
47
+ Authorization: 'Bearer {{token}}',
48
+ },
49
+ }),
50
+ },
51
+ ]
52
+ };
53
+
54
+ const apiConfig = {
55
+ baseUrl: 'http://www.example.org',
56
+ // optional, generate token from asap, check \`pf-emoji-service\` for more info
57
+ authHeader: 'Bearer token',
58
+ };
59
+
60
+ // Create a client object fetching the reactions data from the specified url
61
+ const client = new ReactionServiceClient(apiConfig.baseUrl, apiConfig.authHeader);
62
+
63
+ // Define the initial state object
64
+ const intialState: State = {
65
+ reactions: {},
66
+ flash: {}
67
+ };
68
+
69
+ // Define the store object that will handle all the reactions data (get/set/remove) and the API calls to the server
70
+ const store = new MemoryReactionsStore(client, intialState, {
71
+ subproduct: 'atlaskit',
72
+ });
73
+
74
+
75
+ // Define an emoji resource object instance (EmojiResource implements the EmojiProvider interface) that will be passed as prop to the ConnectedReactionPicker component
76
+ const emojiResource = new EmojiResource(config); //See warning below
77
+
78
+ /**
79
+ * fetch from all the providers in the config object and cache the results (see EmojiResource for more info).
80
+ * Note: this is a one time fetch, so if you want to fetch from the same providers again, you need to create a new EmojiResource instance. Furhermore, you'll need to handle for a failed fetch and retry requests if your app logic requires this.
81
+ */
82
+ emojiResource.fetchEmojiProvider();
83
+
84
+ // Retrieve your ari and containerAri values from the server
85
+ const ari = 'ari:cloud:owner:demo-cloud-id:item/1';
86
+ const containerAri = 'ari:cloud:owner:demo-cloud-id:container/1';
87
+
88
+ const emojiProvider = new EmojiResource(config);
89
+ const emojiId = { shortName: ':grimacing:', id: '1f603' };
90
+
91
+
92
+ ReactDOM.render(
93
+ <ConnectedReactionPicker
94
+ store={store}
95
+ containerAri={containerAri}
96
+ ari={demoAri}
97
+ emojiProvider={Promise.resolve(emojiResource)}
98
+ />
99
+ );`}
100
+
101
+ ${(
102
+ <>
103
+ <br />
104
+ <SectionMessage
105
+ appearance="warning"
106
+ title="There should be only one instance of EmojiResource in your application"
107
+ >
108
+ <p>
109
+ Make sure EmojiResource is initialised only once to avoid performance
110
+ issues using useMemo.
111
+ </p>
112
+ </SectionMessage>
113
+ </>
114
+ )}
115
+
116
+ ### Example:
117
+
118
+ ${(
119
+ <Example
120
+ packageName="@atlaskit/reactions"
121
+ Component={ConnectedReactionPickerExample}
122
+ title="Connected Reactions Picker"
123
+ source={require('!!raw-loader!../examples/00-connected-reaction-picker')}
124
+ />
125
+ )}
126
+
127
+ ${(
128
+ <Props
129
+ heading="ConnectedReactionPicker Props"
130
+ props={require('!!extract-react-types-loader!../extract-react-type/ConnectedReactionPicker')}
131
+ />
132
+ )}
133
+ `;
@@ -0,0 +1,130 @@
1
+ import React from 'react';
2
+ import { md, Example, code, Props } from '@atlaskit/docs';
3
+ import SectionMessage from '@atlaskit/section-message';
4
+
5
+ import ConnectedReactionsViewExample from '../examples/01-connected-reactions-view';
6
+
7
+ export default md`
8
+
9
+ The ConnectedReactionsView component renders all existing reactions for given post/comment/etc.. as well as the [ConnectedReactionPicker](/packages/elements/reactions/docs/connected-reaction-picker) to add more reactions.
10
+
11
+ ## Usage
12
+
13
+ Import the component in your React app as follows:
14
+
15
+ ${code`
16
+ import { ReactionStore, ConnectedReactionsView, State, MemoryReactionsStore, ReactionServiceClient } from '@atlaskit/reactions';
17
+ import { EmojiResource, EmojiResourceConfig } from '@atlaskit/emoji/resource';
18
+
19
+ // Config object for the emoji resource
20
+ const config: EmojiResourceConfig = {
21
+ singleEmojiApi: {
22
+ getUrl: (emojiId: string) => 'https://emoji-example/emoji/site-id/emojiId',
23
+ securityProvider: () => ({
24
+ headers: {
25
+ 'User-Context': '{{token}}',
26
+ Authorization: 'Bearer {{token}}',
27
+ },
28
+ })
29
+ },
30
+ optimisticImageApi: {
31
+ getUrl: (emojiId: string) => 'https://emoji-example/emoji/site-id/emojiId/path',
32
+ securityProvider: () => ({
33
+ headers: {
34
+ 'User-Context': '{{token}}',
35
+ Authorization: 'Bearer {{token}}',
36
+ },
37
+ })
38
+ },
39
+ providers: [
40
+ {
41
+ url: 'https://emoji-example/emoji/standard',
42
+ },
43
+ {
44
+ url: 'https://emoji-example/emoji/site-id/site',
45
+ securityProvider: () => ({
46
+ headers: {
47
+ Authorization: 'Bearer {{token}}',
48
+ },
49
+ }),
50
+ },
51
+ ]
52
+ };
53
+
54
+ const apiConfig = {
55
+ baseUrl: 'http://www.example.org',
56
+ // optional, generate token from asap, check \`pf-emoji-service\` for more info
57
+ authHeader: 'Bearer token',
58
+ };
59
+
60
+ // Create a client object fetching the reactions data from the specified url
61
+ const client = new ReactionServiceClient(apiConfig.baseUrl, apiConfig.authHeader);
62
+
63
+ // Define the initial state object
64
+ const intialState: State = {
65
+ reactions: {},
66
+ flash: {}
67
+ };
68
+
69
+ // Define the store object that will handle all the reactions data (get/set/remove) and the API calls to the server
70
+ const store = new MemoryReactionsStore(client, intialState, {
71
+ subproduct: 'atlaskit',
72
+ });
73
+
74
+ // Define an emoji resource object instance (EmojiResource implements the EmojiProvider interface) that will be passed as prop to the ConnectedReactionsView component
75
+ const emojiResource = new EmojiResource(config); //See warning below
76
+
77
+ /**
78
+ * fetch from all the providers in the config object and cache the results (see EmojiResource for more info).
79
+ * Note: this is a one time fetch, so if you want to fetch from the same providers again, you need to create a new EmojiResource instance. Furhermore, you'll need to handle for a failed fetch and retry requests if your app logic requires this.
80
+ */
81
+ emojiResource.fetchEmojiProvider();
82
+
83
+ // Retrieve your ari and containerAri values from the server
84
+ const ari = 'ari:cloud:owner:demo-cloud-id:item/1';
85
+ const containerAri = 'ari:cloud:owner:demo-cloud-id:container/1';
86
+
87
+ const emojiProvider = new EmojiResource(config);
88
+
89
+ // Render the component in your React app
90
+ ReactDOM.render(
91
+ <ConnectedReactionsView
92
+ store={store}
93
+ containerAri={containerAri}
94
+ ari={demoAri}
95
+ emojiProvider={Promise.resolve(emojiResource)}
96
+ />
97
+ container,
98
+ };`}
99
+
100
+ ${(
101
+ <>
102
+ <br />
103
+ <SectionMessage
104
+ appearance="warning"
105
+ title="There should be only one instance of EmojiResource in your application"
106
+ >
107
+ <p>
108
+ Make sure EmojiResource is initialised only once to avoid performance
109
+ issues using useMemo.
110
+ </p>
111
+ </SectionMessage>
112
+ </>
113
+ )}
114
+
115
+ ${(
116
+ <Example
117
+ packageName="@atlaskit/reactions"
118
+ Component={ConnectedReactionsViewExample}
119
+ title="Connected Reactions View"
120
+ source={require('!!raw-loader!../examples/01-connected-reactions-view')}
121
+ />
122
+ )}
123
+
124
+ ${(
125
+ <Props
126
+ heading="ConnectedReactionsView type"
127
+ props={require('!!extract-react-types-loader!../extract-react-type/ConnectedReactionsView')}
128
+ />
129
+ )}
130
+ `;
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import { md, code, Props } from '@atlaskit/docs';
3
+ import SectionMessage from '@atlaskit/section-message';
4
+
5
+ export default md`
6
+
7
+ The ReactionsStore is one of the key interfaces that encapsulates all logic needed to maintain internal state of the reaction elements (get latest state and onChange callback events), including different types of Actions required to perform on the store (getReactions, toggleReaction on/off, adding a new reaciton, getting detailed reaction upon hovering the emoji icon).
8
+ It serves as one of the key props passed to the connected HoC used in Reactions: (\`ConnectedReactionPicker\` and \`ConnectedReactions\`).
9
+
10
+ ${(
11
+ <>
12
+ <br />
13
+ <SectionMessage appearance="information" title="">
14
+ You can instantiate an instance of the ReactionsStore object using the
15
+ built in <strong>MemoryReactionsStore</strong> class object that
16
+ contains all logic required to communicate with the store. It provides
17
+ all the methods to interact with the store and the API calls to the
18
+ server, including logging
19
+ <a
20
+ target="_blank"
21
+ rel="noopener noreferrer"
22
+ href="https://developer.atlassian.com/platform/ufo/"
23
+ >
24
+ UFO
25
+ </a>
26
+ .
27
+ <br />
28
+ </SectionMessage>
29
+ </>
30
+ )}
31
+
32
+ ## Usage
33
+
34
+ ${code`
35
+ import { MemoryReactionsStore, State, ReactionServiceClient } from '@atlaskit/reactions';
36
+
37
+ const apiConfig = {
38
+ baseUrl: 'http://www.example.org',
39
+ // optional, generate token from asap, check \`pf-emoji-service\` for more info
40
+ authHeader: 'Bearer token',
41
+ };
42
+
43
+ // Create a client object fetching the reactions data from the specified url
44
+ const client = new ReactionServiceClient(apiConfig.baseUrl, apiConfig.authHeader);
45
+
46
+ // Define the initial state object
47
+ const intialState: State = {
48
+ reactions: {},
49
+ flash: {}
50
+ };
51
+
52
+ // Define the store object that will handle all the reactions data (get/set/remove) and the API calls to the server
53
+ const store = new MemoryReactionsStore(client, intialState, {
54
+ subproduct: 'atlaskit',
55
+ });
56
+ `}
57
+
58
+ ${(
59
+ <Props
60
+ heading="Store Type"
61
+ props={require('!!extract-react-types-loader!../extract-react-type/reactionsStore')}
62
+ />
63
+ )}
64
+
65
+ ${(
66
+ <Props
67
+ heading="Actions type"
68
+ props={require('!!extract-react-types-loader!../extract-react-type/actions')}
69
+ />
70
+ )}
71
+ `;