@atlaskit/reactions 22.2.0 → 22.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/MockReactionsClient.js +1 -49
  3. package/dist/cjs/analytics/analytics.js +1 -40
  4. package/dist/cjs/analytics/index.js +0 -7
  5. package/dist/cjs/analytics/ufo.js +8 -20
  6. package/dist/cjs/client/ReactionServiceClient.js +2 -16
  7. package/dist/cjs/client/index.js +0 -1
  8. package/dist/cjs/components/Counter/Counter.js +10 -24
  9. package/dist/cjs/components/Counter/index.js +0 -6
  10. package/dist/cjs/components/Counter/styles.js +1 -3
  11. package/dist/cjs/components/EmojiButton/EmojiButton.js +3 -18
  12. package/dist/cjs/components/EmojiButton/index.js +0 -1
  13. package/dist/cjs/components/EmojiButton/styles.js +1 -2
  14. package/dist/cjs/components/FlashAnimation/FlashAnimation.js +1 -11
  15. package/dist/cjs/components/FlashAnimation/index.js +0 -1
  16. package/dist/cjs/components/FlashAnimation/styles.js +1 -3
  17. package/dist/cjs/components/Reaction/Reaction.js +23 -62
  18. package/dist/cjs/components/Reaction/index.js +0 -1
  19. package/dist/cjs/components/Reaction/styles.js +1 -4
  20. package/dist/cjs/components/ReactionDialog/ReactionView.js +6 -29
  21. package/dist/cjs/components/ReactionDialog/ReactionsDialog.js +19 -48
  22. package/dist/cjs/components/ReactionDialog/ReactionsList.js +18 -34
  23. package/dist/cjs/components/ReactionDialog/index.js +0 -1
  24. package/dist/cjs/components/ReactionDialog/styles.js +3 -13
  25. package/dist/cjs/components/ReactionPicker/ReactionPicker.js +41 -71
  26. package/dist/cjs/components/ReactionPicker/index.js +0 -1
  27. package/dist/cjs/components/ReactionPicker/styles.js +1 -4
  28. package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +13 -28
  29. package/dist/cjs/components/ReactionTooltip/index.js +0 -1
  30. package/dist/cjs/components/ReactionTooltip/styles.js +1 -3
  31. package/dist/cjs/components/Reactions/Reactions.js +48 -86
  32. package/dist/cjs/components/Reactions/index.js +0 -1
  33. package/dist/cjs/components/Reactions/styles.js +1 -2
  34. package/dist/cjs/components/Selector/Selector.js +12 -34
  35. package/dist/cjs/components/Selector/index.js +0 -6
  36. package/dist/cjs/components/Selector/styles.js +2 -5
  37. package/dist/cjs/components/ShowMore/ShowMore.js +5 -19
  38. package/dist/cjs/components/ShowMore/index.js +0 -1
  39. package/dist/cjs/components/ShowMore/styles.js +1 -4
  40. package/dist/cjs/components/Trigger/Trigger.js +6 -22
  41. package/dist/cjs/components/Trigger/index.js +0 -1
  42. package/dist/cjs/components/Trigger/styles.js +3 -13
  43. package/dist/cjs/components/UfoErrorBoundary/UfoErrorBoundary.js +1 -19
  44. package/dist/cjs/components/UfoErrorBoundary/index.js +0 -1
  45. package/dist/cjs/components/index.js +0 -5
  46. package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +2 -17
  47. package/dist/cjs/containers/ConnectedReactionPicker/index.js +0 -1
  48. package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +17 -62
  49. package/dist/cjs/containers/ConnectedReactionsView/index.js +0 -1
  50. package/dist/cjs/containers/index.js +0 -4
  51. package/dist/cjs/hooks/index.js +0 -1
  52. package/dist/cjs/hooks/useClickAway.js +2 -5
  53. package/dist/cjs/i18n/cs.js +0 -1
  54. package/dist/cjs/i18n/da.js +0 -1
  55. package/dist/cjs/i18n/de.js +0 -1
  56. package/dist/cjs/i18n/en.js +0 -1
  57. package/dist/cjs/i18n/en_GB.js +0 -1
  58. package/dist/cjs/i18n/en_ZZ.js +0 -1
  59. package/dist/cjs/i18n/es.js +0 -1
  60. package/dist/cjs/i18n/et.js +0 -1
  61. package/dist/cjs/i18n/fi.js +0 -1
  62. package/dist/cjs/i18n/fr.js +0 -1
  63. package/dist/cjs/i18n/hu.js +0 -1
  64. package/dist/cjs/i18n/index.js +0 -30
  65. package/dist/cjs/i18n/it.js +0 -1
  66. package/dist/cjs/i18n/ja.js +0 -1
  67. package/dist/cjs/i18n/ko.js +0 -1
  68. package/dist/cjs/i18n/nb.js +0 -1
  69. package/dist/cjs/i18n/nl.js +0 -1
  70. package/dist/cjs/i18n/pl.js +0 -1
  71. package/dist/cjs/i18n/pt_BR.js +0 -1
  72. package/dist/cjs/i18n/pt_PT.js +0 -1
  73. package/dist/cjs/i18n/ru.js +0 -1
  74. package/dist/cjs/i18n/sk.js +0 -1
  75. package/dist/cjs/i18n/sv.js +0 -1
  76. package/dist/cjs/i18n/th.js +0 -1
  77. package/dist/cjs/i18n/tr.js +0 -1
  78. package/dist/cjs/i18n/uk.js +0 -1
  79. package/dist/cjs/i18n/vi.js +0 -1
  80. package/dist/cjs/i18n/zh.js +0 -1
  81. package/dist/cjs/i18n/zh_TW.js +0 -1
  82. package/dist/cjs/index.js +0 -6
  83. package/dist/cjs/shared/constants.js +5 -6
  84. package/dist/cjs/shared/i18n.js +0 -2
  85. package/dist/cjs/shared/index.js +0 -9
  86. package/dist/cjs/shared/utils.js +6 -25
  87. package/dist/cjs/store/MemoryReactionsStore.js +21 -74
  88. package/dist/cjs/store/ReactionConsumer.js +0 -28
  89. package/dist/cjs/store/batched.js +0 -6
  90. package/dist/cjs/store/index.js +0 -2
  91. package/dist/cjs/store/utils.js +0 -25
  92. package/dist/cjs/types/index.js +0 -1
  93. package/dist/cjs/types/reaction.js +0 -10
  94. package/dist/cjs/version.json +1 -1
  95. package/dist/es2019/MockReactionsClient.js +7 -21
  96. package/dist/es2019/analytics/analytics.js +3 -9
  97. package/dist/es2019/analytics/ufo.js +11 -13
  98. package/dist/es2019/client/ReactionServiceClient.js +4 -13
  99. package/dist/es2019/components/Counter/Counter.js +5 -7
  100. package/dist/es2019/components/EmojiButton/EmojiButton.js +0 -3
  101. package/dist/es2019/components/FlashAnimation/FlashAnimation.js +1 -2
  102. package/dist/es2019/components/Reaction/Reaction.js +3 -12
  103. package/dist/es2019/components/Reaction/styles.js +1 -1
  104. package/dist/es2019/components/ReactionDialog/ReactionView.js +0 -4
  105. package/dist/es2019/components/ReactionDialog/ReactionsDialog.js +6 -15
  106. package/dist/es2019/components/ReactionDialog/ReactionsList.js +4 -3
  107. package/dist/es2019/components/ReactionDialog/styles.js +2 -5
  108. package/dist/es2019/components/ReactionPicker/ReactionPicker.js +14 -19
  109. package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +1 -2
  110. package/dist/es2019/components/Reactions/Reactions.js +16 -25
  111. package/dist/es2019/components/Selector/Selector.js +5 -11
  112. package/dist/es2019/components/Selector/styles.js +1 -1
  113. package/dist/es2019/components/ShowMore/ShowMore.js +1 -2
  114. package/dist/es2019/components/Trigger/Trigger.js +1 -5
  115. package/dist/es2019/components/UfoErrorBoundary/UfoErrorBoundary.js +0 -3
  116. package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +0 -4
  117. package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +8 -20
  118. package/dist/es2019/hooks/useClickAway.js +3 -4
  119. package/dist/es2019/index.js +2 -1
  120. package/dist/es2019/shared/constants.js +5 -5
  121. package/dist/es2019/shared/utils.js +7 -15
  122. package/dist/es2019/store/MemoryReactionsStore.js +36 -61
  123. package/dist/es2019/store/ReactionConsumer.js +1 -12
  124. package/dist/es2019/store/batched.js +0 -2
  125. package/dist/es2019/store/utils.js +4 -8
  126. package/dist/es2019/types/reaction.js +1 -1
  127. package/dist/es2019/version.json +1 -1
  128. package/dist/esm/MockReactionsClient.js +1 -42
  129. package/dist/esm/analytics/analytics.js +1 -12
  130. package/dist/esm/analytics/ufo.js +11 -13
  131. package/dist/esm/client/ReactionServiceClient.js +2 -14
  132. package/dist/esm/components/Counter/Counter.js +12 -15
  133. package/dist/esm/components/EmojiButton/EmojiButton.js +2 -6
  134. package/dist/esm/components/FlashAnimation/FlashAnimation.js +1 -2
  135. package/dist/esm/components/Reaction/Reaction.js +23 -40
  136. package/dist/esm/components/Reaction/styles.js +1 -1
  137. package/dist/esm/components/ReactionDialog/ReactionView.js +5 -14
  138. package/dist/esm/components/ReactionDialog/ReactionsDialog.js +20 -35
  139. package/dist/esm/components/ReactionDialog/ReactionsList.js +17 -20
  140. package/dist/esm/components/ReactionDialog/styles.js +2 -5
  141. package/dist/esm/components/ReactionPicker/ReactionPicker.js +42 -52
  142. package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +14 -16
  143. package/dist/esm/components/Reactions/Reactions.js +49 -62
  144. package/dist/esm/components/Selector/Selector.js +13 -22
  145. package/dist/esm/components/Selector/styles.js +1 -1
  146. package/dist/esm/components/ShowMore/ShowMore.js +6 -7
  147. package/dist/esm/components/Trigger/Trigger.js +7 -11
  148. package/dist/esm/components/Trigger/styles.js +3 -6
  149. package/dist/esm/components/UfoErrorBoundary/UfoErrorBoundary.js +1 -14
  150. package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +2 -9
  151. package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +17 -43
  152. package/dist/esm/hooks/useClickAway.js +3 -4
  153. package/dist/esm/index.js +2 -1
  154. package/dist/esm/shared/constants.js +5 -5
  155. package/dist/esm/shared/utils.js +7 -17
  156. package/dist/esm/store/MemoryReactionsStore.js +22 -78
  157. package/dist/esm/store/ReactionConsumer.js +0 -23
  158. package/dist/esm/store/batched.js +0 -4
  159. package/dist/esm/store/utils.js +0 -9
  160. package/dist/esm/types/reaction.js +1 -1
  161. package/dist/esm/version.json +1 -1
  162. package/dist/types/components/ReactionDialog/styles.d.ts +1 -2
  163. package/package.json +6 -4
@@ -19,11 +19,9 @@ export const getUser = (id, displayName) => ({
19
19
  path: 'https://pbs.twimg.com/profile_images/803832195970433027/aaoG6PJI_400x400.jpg'
20
20
  }
21
21
  });
22
-
23
22
  const getReactionKey = (containerAri, ari) => {
24
23
  return `${containerAri}|${ari}`;
25
24
  };
26
-
27
25
  const defaultUsers = [getUser('oscar', 'Oscar Wallhult'), getUser('julien', 'Julien Michel Hoarau'), getUser('craig', 'Craig Petchell'), getUser('jerome', 'Jerome Touffe-Blin'), getUser('esoares', 'Eduardo Soares'), getUser('lpereira', 'Luiz Pereira'), getUser('pcurren', 'Paul Curren'), getUser('ttjandra', 'Tara Tjandra'), getUser('severington', 'Ste Everington'), getUser('sguillope', 'Sylvain Guillope'), getUser('alunnon', 'Alex Lunnon'), getUser('bsmith', 'Bob Smith'), getUser('jdoe', 'Jane Doe'), getUser('mhomes', 'Mary Homes'), getUser('ckent', 'Clark Kent')];
28
26
  export const simpleMockData = {
29
27
  [getReactionKey(containerAri, ari)]: [getReactionSummary(':fire:', 1, true), getReactionSummary(':thumbsup:', 999, false), getReactionSummary(':astonished:', 9, false), getReactionSummary(':heart:', 99, false)]
@@ -31,18 +29,16 @@ export const simpleMockData = {
31
29
  const extendedMockData = {
32
30
  [getReactionKey(containerAri, ari)]: [getReactionSummary(':fire:', 1, true, true), getReactionSummary(':thumbsup:', 999, false, true), getReactionSummary(':astonished:', 9, false, true), getReactionSummary(':heart:', 99, false, true), getReactionSummary(':thinking:', 10, false, true), getReactionSummary(':clap:', 99, false, true), getReactionSummary(':thumbsdown:', 2, false, true), getReactionSummary(':bulb:', 16, false, true), getReactionSummary(':star:', 9999, false, true), getReactionSummary(':green_heart:', 9, false, true), getReactionSummary(':blue_heart:', 8392, false, true), getReactionSummary(':broken_heart:', 1, false, true), getReactionSummary(':grinning:', 10601, false, true), getReactionSummary(':slight_smile:', 99, false, true)]
33
31
  };
32
+
34
33
  /**
35
34
  * Mocked version of the client to fetch user information
36
35
  */
37
-
38
36
  export class MockReactionsClient {
39
37
  constructor(delay = 0, showExtendedReactions = false) {
40
38
  _defineProperty(this, "delayPromise", () => new Promise(resolve => window.setTimeout(resolve, this.delay)));
41
-
42
39
  this.delay = delay;
43
40
  this.mockData = showExtendedReactions ? extendedMockData : simpleMockData;
44
41
  }
45
-
46
42
  async getReactions(containerAri, aris) {
47
43
  await this.delayPromise();
48
44
  return aris.reduce((results, ari) => {
@@ -51,23 +47,20 @@ export class MockReactionsClient {
51
47
  return results;
52
48
  }, {});
53
49
  }
54
-
55
50
  async getDetailedReaction(containerAri, ari, emojiId) {
56
51
  await this.delayPromise();
57
52
  const reactionKey = `${containerAri}|${ari}`;
58
53
  const reactionsMockData = this.mockData[reactionKey];
59
-
60
54
  if (reactionsMockData) {
61
55
  const reaction = reactionsMockData.find(reaction_1 => reaction_1.emojiId === emojiId);
62
-
63
56
  if (reaction) {
64
57
  const users = [...defaultUsers].slice(Math.floor(Math.random() * 4), Math.floor(Math.random() * 9) + 4).slice(0, reaction.count);
65
- return { ...reaction,
58
+ return {
59
+ ...reaction,
66
60
  users
67
61
  };
68
62
  }
69
63
  }
70
-
71
64
  return {
72
65
  containerAri,
73
66
  ari,
@@ -77,27 +70,24 @@ export class MockReactionsClient {
77
70
  users: []
78
71
  };
79
72
  }
80
-
81
73
  async addReaction(containerAri, ari, emojiId) {
82
74
  await this.delayPromise();
83
75
  const reactionKey = getReactionKey(containerAri, ari);
84
76
  let found = false;
85
77
  const reactionsMockData = this.mockData[reactionKey];
86
-
87
78
  if (reactionsMockData) {
88
79
  this.mockData[reactionKey] = reactionsMockData.map(reaction => {
89
80
  if (reaction.emojiId === emojiId) {
90
81
  found = true;
91
- return { ...reaction,
82
+ return {
83
+ ...reaction,
92
84
  count: reaction.count + 1,
93
85
  reacted: true
94
86
  };
95
87
  }
96
-
97
88
  return reaction;
98
89
  });
99
90
  }
100
-
101
91
  if (!found) {
102
92
  this.mockData[reactionKey] = [...(reactionsMockData ? reactionsMockData : []), {
103
93
  containerAri,
@@ -107,10 +97,8 @@ export class MockReactionsClient {
107
97
  reacted: true
108
98
  }];
109
99
  }
110
-
111
100
  return this.mockData[reactionKey];
112
101
  }
113
-
114
102
  async deleteReaction(containerAri, ari, emojiId) {
115
103
  await this.delayPromise();
116
104
  const reactionKey = getReactionKey(containerAri, ari);
@@ -119,16 +107,14 @@ export class MockReactionsClient {
119
107
  if (reaction.count === 1) {
120
108
  return undefined;
121
109
  }
122
-
123
- return { ...reaction,
110
+ return {
111
+ ...reaction,
124
112
  count: reaction.count - 1,
125
113
  reacted: false
126
114
  };
127
115
  }
128
-
129
116
  return reaction;
130
117
  }).filter(reaction_1 => !!reaction_1);
131
118
  return this.mockData[reactionKey];
132
119
  }
133
-
134
120
  }
@@ -7,32 +7,27 @@ export const createAndFireSafe = (createAnalyticsEvent, creator, ...args) => {
7
7
  createAndFireEventInElementsChannel(creator(...args))(createAnalyticsEvent);
8
8
  }
9
9
  };
10
-
11
10
  const createPayload = (action, actionSubject, eventType, actionSubjectId) => (attributes = {}) => ({
12
11
  action,
13
12
  actionSubject,
14
13
  eventType,
15
14
  actionSubjectId,
16
- attributes: { ...attributes,
15
+ attributes: {
16
+ ...attributes,
17
17
  packageName,
18
18
  packageVersion
19
19
  }
20
20
  });
21
-
22
21
  const calculateDuration = startTime => startTime ? Date.now() - startTime : undefined;
23
-
24
22
  const getPreviousState = reaction => {
25
23
  if (reaction) {
26
24
  if (reaction.reacted) {
27
25
  return 'existingReacted';
28
26
  }
29
-
30
27
  return 'existingNotReacted';
31
28
  }
32
-
33
29
  return 'new';
34
30
  };
35
-
36
31
  export const createRestSucceededEvent = actionSubject => createPayload('succeeded', actionSubject, OPERATIONAL_EVENT_TYPE)();
37
32
  export const createRestFailedEvent = (actionSubject, errorCode) => createPayload('failed', actionSubject, OPERATIONAL_EVENT_TYPE)({
38
33
  errorCode
@@ -65,12 +60,12 @@ export const createReactionClickedEvent = (added, emojiId) => createPayload('cli
65
60
  added,
66
61
  emojiId
67
62
  });
63
+
68
64
  /**
69
65
  * Used for store failure metadata for analytics
70
66
  * @param error The error could be a service error with {code, reason} or an Error
71
67
  * @returns any
72
68
  */
73
-
74
69
  export const extractErrorInfo = error => {
75
70
  if (error instanceof Error) {
76
71
  return {
@@ -78,6 +73,5 @@ export const extractErrorInfo = error => {
78
73
  message: error.message
79
74
  };
80
75
  }
81
-
82
76
  return error;
83
77
  };
@@ -1,5 +1,6 @@
1
1
  import { ConcurrentExperience, UFOExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
2
2
  import { withSampling } from '@atlaskit/emoji';
3
+
3
4
  /**
4
5
  * Initial experience config object (deferred from @atlaskit/ufo inner types)
5
6
  */
@@ -17,16 +18,15 @@ const createExperienceConfig = (componentName, type, performanceType) => {
17
18
  performanceType
18
19
  };
19
20
  };
21
+
20
22
  /**
21
23
  * Types of experiences
22
24
  */
23
-
24
-
25
25
  export let ExperienceName;
26
+
26
27
  /**
27
28
  * UFO types of components been instrumented
28
29
  */
29
-
30
30
  (function (ExperienceName) {
31
31
  ExperienceName["REACTIONS_RENDERED"] = "reactions-rendered";
32
32
  ExperienceName["PICKER_OPENED"] = "reactions-picker-opened";
@@ -37,53 +37,51 @@ export let ExperienceName;
37
37
  ExperienceName["REACTION_DIALOG_CLOSED"] = "reaction-dialog-closed";
38
38
  ExperienceName["REACTION_DIALOG_SELECTED_REACTION_CHANGED"] = "reaction-dialog-selected-reaction-changed";
39
39
  })(ExperienceName || (ExperienceName = {}));
40
-
41
40
  export let ComponentName;
41
+
42
42
  /**
43
43
  * Experience when the emoji picker is opened
44
44
  */
45
-
46
45
  (function (ComponentName) {
47
46
  ComponentName["PICKER_RENDERED"] = "reactions-picker";
48
47
  ComponentName["REACTIONS"] = "reactions-list";
49
48
  ComponentName["REACTION_ITEM"] = "reaction-item";
50
49
  ComponentName["REACTION_DIALOG"] = "reaction-dialog";
51
50
  })(ComponentName || (ComponentName = {}));
52
-
53
51
  export const PickerRender = new UFOExperience(ExperienceName.PICKER_OPENED, createExperienceConfig(ComponentName.PICKER_RENDERED, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
52
+
54
53
  /**
55
54
  * Experience when the list of reactions gets rendered
56
55
  */
57
-
58
56
  export const ReactionsRendered = new ConcurrentExperience(ExperienceName.REACTIONS_RENDERED, createExperienceConfig(ComponentName.REACTIONS, ExperienceTypes.Load, ExperiencePerformanceTypes.PageSegmentLoad));
57
+
59
58
  /**
60
59
  * Experience when a reaction emoji gets added
61
60
  */
62
-
63
61
  export const ReactionsAdd = new ConcurrentExperience(ExperienceName.REACTION_ADDED, createExperienceConfig(ComponentName.REACTIONS, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
62
+
64
63
  /**
65
64
  * Expeirence when a reaction dialog is opened
66
65
  */
67
-
68
66
  export const ReactionDialogOpened = new UFOExperience(ExperienceName.REACTION_DIALOG_OPENED, createExperienceConfig(ComponentName.REACTION_DIALOG, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
67
+
69
68
  /**
70
69
  * Experience when a reaction dialog is closed
71
70
  */
72
-
73
71
  export const ReactionDialogClosed = new UFOExperience(ExperienceName.REACTION_DIALOG_CLOSED, createExperienceConfig(ComponentName.REACTION_DIALOG, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
72
+
74
73
  /**
75
74
  * Experience when a reaction changed/fetched from inside the modal dialog
76
75
  */
77
-
78
76
  export const ReactionDialogSelectedReactionChanged = new UFOExperience(ExperienceName.REACTION_DIALOG_SELECTED_REACTION_CHANGED, createExperienceConfig(ComponentName.REACTION_DIALOG, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
77
+
79
78
  /**
80
79
  * Experience when a reaction details gets fetched
81
80
  */
82
-
83
81
  export const ReactionDetailsFetch = new ConcurrentExperience(ExperienceName.REACTION_DETAILS_FETCHED, createExperienceConfig(ComponentName.REACTION_ITEM, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
82
+
84
83
  /**
85
84
  * Experience when a reaction emoji gets removed/decrement
86
85
  */
87
-
88
86
  export const ReactionsRemove = new ConcurrentExperience(ExperienceName.REACTION_REMOVED, createExperienceConfig(ComponentName.REACTIONS, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
89
87
  export const sampledReactionsRendered = instanceId => withSampling(ReactionsRendered.getInstance(instanceId));
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { utils } from '@atlaskit/util-service-support';
3
-
4
3
  /**
5
4
  * Utility class to retrieve/modify all actions on reactions collection
6
5
  */
@@ -19,44 +18,40 @@ export class ReactionServiceClient {
19
18
  * @param sessionToken oAuth token for reactions emoji services
20
19
  */
21
20
  constructor(baseUrl, sessionToken) {
22
- _defineProperty(this, "requestService", (path, options) => utils.requestService(this.serviceConfig, { ...options,
21
+ _defineProperty(this, "requestService", (path, options) => utils.requestService(this.serviceConfig, {
22
+ ...options,
23
23
  path
24
24
  }));
25
-
26
25
  this.serviceConfig = {
27
26
  url: baseUrl
28
27
  };
29
28
  this.sessionToken = sessionToken;
30
29
  }
30
+
31
31
  /**
32
32
  * Get http headers for the "fetch" request
33
33
  * @param hasBody
34
34
  */
35
-
36
-
37
35
  getHeaders() {
38
36
  const headers = {};
39
37
  headers['Accept'] = 'application/json';
40
38
  headers['Content-Type'] = 'application/json';
41
-
42
39
  if (this.sessionToken) {
43
40
  headers['Authorization'] = this.sessionToken;
44
41
  }
45
-
46
42
  return headers;
47
43
  }
44
+
48
45
  /**
49
46
  * Send a request to remote service
50
47
  * @param path endpoint api url
51
48
  * @param options Optional custom params
52
49
  */
53
50
 
54
-
55
51
  getReactions(containerAri, aris) {
56
52
  if (aris.length === 0) {
57
53
  return Promise.resolve({});
58
54
  }
59
-
60
55
  return this.requestService('reactions/view', {
61
56
  requestInit: {
62
57
  method: 'POST',
@@ -68,7 +63,6 @@ export class ReactionServiceClient {
68
63
  }
69
64
  });
70
65
  }
71
-
72
66
  getDetailedReaction(containerAri, ari, emojiId) {
73
67
  const reactionId = `${containerAri}|${ari}|${emojiId}`;
74
68
  const headers = this.getHeaders();
@@ -83,7 +77,6 @@ export class ReactionServiceClient {
83
77
  }
84
78
  });
85
79
  }
86
-
87
80
  addReaction(containerAri, ari, emojiId, metadata) {
88
81
  return this.requestService('reactions', {
89
82
  requestInit: {
@@ -103,7 +96,6 @@ export class ReactionServiceClient {
103
96
  reactions
104
97
  }) => reactions);
105
98
  }
106
-
107
99
  deleteReaction(containerAri, ari, emojiId, metadata) {
108
100
  return this.requestService('reactions', {
109
101
  queryParams: {
@@ -123,5 +115,4 @@ export class ReactionServiceClient {
123
115
  reactions
124
116
  }) => reactions);
125
117
  }
126
-
127
118
  }
@@ -1,27 +1,26 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
3
  import { jsx, css } from '@emotion/react';
4
- import { SlideIn, ExitingPersistence, mediumDurationMs } from '@atlaskit/motion'; // eslint-disable-next-line @atlaskit/design-system/no-banned-imports
5
-
4
+ import { SlideIn, ExitingPersistence, mediumDurationMs } from '@atlaskit/motion';
5
+ // eslint-disable-next-line @atlaskit/design-system/no-banned-imports
6
6
  import usePreviousValue from '@atlaskit/ds-lib/use-previous-value';
7
7
  import { utils } from '../../shared';
8
8
  import * as styles from './styles';
9
+
9
10
  /**
10
11
  * Test id for component top level div
11
12
  */
12
-
13
13
  export const RENDER_COMPONENT_WRAPPER = 'counter-wrapper';
14
+
14
15
  /**
15
16
  * Test id for wrapper div of the counter inside the slider
16
17
  */
17
-
18
18
  export const RENDER_COUNTER_TESTID = 'counter-container';
19
+
19
20
  /**
20
21
  * Counter label value wrapper div
21
22
  */
22
-
23
23
  export const RENDER_LABEL_TESTID = 'counter_label_wrapper';
24
-
25
24
  /**
26
25
  * Display reaction count next to the emoji button
27
26
  */
@@ -43,7 +42,6 @@ export const Counter = ({
43
42
  return utils.formatLargeNumber(value);
44
43
  }
45
44
  };
46
-
47
45
  const previousValue = usePreviousValue(value);
48
46
  const label = getLabel(value);
49
47
  const increase = previousValue ? previousValue < value : false;
@@ -6,7 +6,6 @@ import { ResourcedEmoji } from '@atlaskit/emoji';
6
6
  import { i18n, utils } from '../../shared';
7
7
  import * as styles from './styles';
8
8
  export const RENDER_BUTTON_TESTID = 'button-emoji-id';
9
-
10
9
  /**
11
10
  * custom button to render the custom emoji selector inside the reaction picker
12
11
  */
@@ -17,12 +16,10 @@ export const EmojiButton = ({
17
16
  }) => {
18
17
  const onButtonClick = event => {
19
18
  event.preventDefault();
20
-
21
19
  if (onClick && utils.isLeftClick(event)) {
22
20
  onClick(emojiId, undefined, event);
23
21
  }
24
22
  };
25
-
26
23
  const intl = useIntl();
27
24
  return jsx("button", {
28
25
  "data-testid": RENDER_BUTTON_TESTID,
@@ -2,15 +2,14 @@
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import * as styles from './styles';
5
-
6
5
  /**
7
6
  * Test id for wrapper FlashAnimation div
8
7
  */
9
8
  export const RENDER_FLASHANIMATION_TESTID = 'flash-animation';
9
+
10
10
  /**
11
11
  * Flash animation background component. See Reaction component for usage.
12
12
  */
13
-
14
13
  export const FlashAnimation = props => jsx("div", {
15
14
  className: props.className,
16
15
  css: [styles.containerStyle, props.flash && styles.flashStyle],
@@ -10,12 +10,10 @@ import { FlashAnimation } from '../FlashAnimation';
10
10
  import { ReactionTooltip } from '../ReactionTooltip';
11
11
  import { i18n, utils } from '../../shared';
12
12
  import * as styles from './styles';
13
-
14
13
  /**
15
14
  * Test id for Reaction item wrapper div
16
15
  */
17
16
  export const RENDER_REACTION_TESTID = 'render_reaction_wrapper';
18
-
19
17
  /**
20
18
  * Render an emoji reaction button
21
19
  */
@@ -41,14 +39,14 @@ export const Reaction = ({
41
39
  const emojiId = {
42
40
  id: reaction.emojiId,
43
41
  shortName: ''
44
- }; // TODO: Extract the flow to a custom hook to retrieve emoji detailed description from an id using a custom hook. This will benefit a better optimization instead of the emojiProvider resolving everytime.
45
- // Also optimize in future version to fetch in batch several emojiIds
42
+ };
46
43
 
44
+ // TODO: Extract the flow to a custom hook to retrieve emoji detailed description from an id using a custom hook. This will benefit a better optimization instead of the emojiProvider resolving everytime.
45
+ // Also optimize in future version to fetch in batch several emojiIds
47
46
  useEffect(() => {
48
47
  (async () => {
49
48
  const emojiResource = await Promise.resolve(emojiProvider);
50
49
  const foundEmoji = await emojiResource.findById(reaction.emojiId);
51
-
52
50
  if (foundEmoji) {
53
51
  setEmojiName(foundEmoji.name);
54
52
  }
@@ -56,7 +54,6 @@ export const Reaction = ({
56
54
  }, [emojiProvider, reaction.emojiId]);
57
55
  const handleClick = useCallback(event => {
58
56
  event.preventDefault();
59
-
60
57
  if (utils.isLeftClick(event)) {
61
58
  const {
62
59
  reacted,
@@ -69,31 +66,25 @@ export const Reaction = ({
69
66
  const handleMouseEnter = useCallback(event => {
70
67
  event.preventDefault();
71
68
  setIsTooltipEnabled(true);
72
-
73
69
  if (!reaction.users || !reaction.users.length) {
74
70
  focusStart.current = Date.now();
75
71
  }
76
-
77
72
  Analytics.createAndFireSafe(createAnalyticsEvent, Analytics.createReactionHoveredEvent, focusStart.current);
78
73
  onMouseEnter(reaction.emojiId, event);
79
74
  }, [createAnalyticsEvent, reaction, onMouseEnter]);
80
75
  const handleFocused = useCallback(event => {
81
76
  event.preventDefault();
82
77
  setIsTooltipEnabled(true);
83
-
84
78
  if (!reaction.users || !reaction.users.length) {
85
79
  hoverStart.current = Date.now();
86
80
  }
87
-
88
81
  Analytics.createAndFireSafe(createAnalyticsEvent, Analytics.createReactionFocusedEvent, hoverStart.current);
89
82
  onFocused(reaction.emojiId, event);
90
83
  }, [createAnalyticsEvent, reaction, onFocused]);
91
-
92
84
  const handleOpenReactionsDialog = emojiId => {
93
85
  handleUserListClick(emojiId);
94
86
  setIsTooltipEnabled(false);
95
87
  };
96
-
97
88
  return jsx(ReactionTooltip, {
98
89
  emojiName: emojiName,
99
90
  reaction: reaction,
@@ -1,11 +1,11 @@
1
1
  /** @jsx jsx */
2
2
  import { css } from '@emotion/react';
3
3
  import { B50, B75, B300, N20, N40, N400, B100 } from '@atlaskit/theme/colors';
4
-
5
4
  /**
6
5
  * Default styling px height for an emoji reaction
7
6
  */
8
7
  const akHeight = 24;
8
+
9
9
  /**
10
10
  * Styling Note:
11
11
  * Padding and line height are set within the child components
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { useEffect, useState, useMemo } from 'react';
5
4
  import { useIntl } from 'react-intl-next';
@@ -24,7 +23,6 @@ export const ReactionView = ({
24
23
  shortName: '',
25
24
  id: selectedEmojiId
26
25
  });
27
-
28
26
  if (emoji && emoji.name) {
29
27
  setEmojiName(emoji.name);
30
28
  }
@@ -32,7 +30,6 @@ export const ReactionView = ({
32
30
  }, [emojiProvider, selectedEmojiId]);
33
31
  const alphabeticalNames = useMemo(() => {
34
32
  var _reactionObj$users;
35
-
36
33
  const reactionObj = reaction;
37
34
  return ((_reactionObj$users = reactionObj.users) === null || _reactionObj$users === void 0 ? void 0 : _reactionObj$users.sort((a, b) => a.displayName.localeCompare(b.displayName))) || [];
38
35
  }, [reaction]);
@@ -56,7 +53,6 @@ export const ReactionView = ({
56
53
  css: userListStyle
57
54
  }, alphabeticalNames.map(user => {
58
55
  var _user$profilePicture;
59
-
60
56
  const profile = (_user$profilePicture = user.profilePicture) === null || _user$profilePicture === void 0 ? void 0 : _user$profilePicture.path;
61
57
  return jsx("li", {
62
58
  css: userStyle,
@@ -7,12 +7,11 @@ import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaski
7
7
  import { constants, i18n } from '../../shared';
8
8
  import { ReactionsList } from './ReactionsList';
9
9
  import { containerStyle, titleStyle } from './styles';
10
+
10
11
  /**
11
12
  * Test id for the Reactions modal dialog
12
13
  */
13
-
14
14
  export const RENDER_MODAL_TESTID = 'render-reactions-modal';
15
-
16
15
  const getDimensions = container => {
17
16
  return {
18
17
  clientWidth: container === null || container === void 0 ? void 0 : container.clientWidth,
@@ -20,7 +19,6 @@ const getDimensions = container => {
20
19
  scrollLeft: container === null || container === void 0 ? void 0 : container.scrollLeft
21
20
  };
22
21
  };
23
-
24
22
  export const ReactionsDialog = ({
25
23
  reactions = [],
26
24
  handleCloseReactionsDialog = () => {},
@@ -42,25 +40,22 @@ export const ReactionsDialog = ({
42
40
  const sortedReactions = useMemo(() => {
43
41
  return reactions.sort((a, b) => (b === null || b === void 0 ? void 0 : b.count) - (a === null || a === void 0 ? void 0 : a.count));
44
42
  }, [reactions]);
45
- /* set Reactions Border Width , 9 Number of reactions to display*/
46
43
 
44
+ /* set Reactions Border Width , 9 Number of reactions to display*/
47
45
  const reactionsBorderWidth = useMemo(() => {
48
46
  return Math.ceil(reactions.length / constants.NUMBER_OF_REACTIONS_TO_DISPLAY) * 100;
49
47
  }, [reactions]);
50
- /* Callback from IntersectionObserver to set/unset classNames based on visibility to toggle styles*/
51
48
 
49
+ /* Callback from IntersectionObserver to set/unset classNames based on visibility to toggle styles*/
52
50
  const handleNavigation = useCallback(entries => {
53
51
  entries.forEach((entry, index) => {
54
52
  var _dataset;
55
-
56
53
  const element = entry.target;
57
54
  const emojiElement = element === null || element === void 0 ? void 0 : element.querySelector('[data-emoji-id]');
58
55
  const emojiId = emojiElement === null || emojiElement === void 0 ? void 0 : (_dataset = emojiElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.emojiId;
59
-
60
56
  if (entry.intersectionRatio < 1) {
61
57
  element.classList.add('disabled');
62
58
  /*Check if selectedEmoji (passed as props based on what user selects) is out of viewport */
63
-
64
59
  if (emojiId === selectedEmojiId && !isSelectedEmojiViewed.current) {
65
60
  setElementToScroll(emojiElement !== null && emojiElement !== void 0 ? emojiElement : undefined);
66
61
  }
@@ -68,7 +63,6 @@ export const ReactionsDialog = ({
68
63
  if (emojiId === selectedEmojiId && !isSelectedEmojiViewed.current) {
69
64
  isSelectedEmojiViewed.current = true;
70
65
  }
71
-
72
66
  element.classList.remove('disabled');
73
67
  }
74
68
  });
@@ -83,15 +77,14 @@ export const ReactionsDialog = ({
83
77
  } = getDimensions(reactionsList);
84
78
  const offsetLeft = parentElement === null || parentElement === void 0 ? void 0 : parentElement.offsetLeft;
85
79
  /* which means emoji is not in viewport so scroll to it*/
86
-
87
80
  if (reactionsList && offsetLeft > clientWidth) {
88
81
  const scrollBy = Math.trunc(offsetLeft / clientWidth) * clientWidth;
89
82
  reactionsList.scrollLeft += scrollBy;
90
83
  }
91
84
  }
92
85
  }, [elementToScroll, reactionsContainerRef]);
93
- /* Set up InterSectionObserver to observer reaction elements on navigating*/
94
86
 
87
+ /* Set up InterSectionObserver to observer reaction elements on navigating*/
95
88
  useEffect(() => {
96
89
  if (reactionsContainerRef) {
97
90
  const options = {
@@ -103,11 +96,9 @@ export const ReactionsDialog = ({
103
96
  reactionElementsRef.current = reactionsContainerRef.querySelectorAll('.reaction-elements');
104
97
  reactionElementsRef.current && reactionElementsRef.current.length > 0 && reactionElementsRef.current.forEach(child => {
105
98
  var _observerRef$current;
106
-
107
99
  observerRef === null || observerRef === void 0 ? void 0 : (_observerRef$current = observerRef.current) === null || _observerRef$current === void 0 ? void 0 : _observerRef$current.observe(child);
108
100
  });
109
101
  }
110
-
111
102
  return () => {
112
103
  if (observerRef.current) {
113
104
  observerRef.current.disconnect();
@@ -118,8 +109,8 @@ export const ReactionsDialog = ({
118
109
  const setRef = useCallback(node => {
119
110
  if (!reactionsContainerRef) {
120
111
  setReactionsContainerRef(node);
121
- } // eslint-disable-next-line react-hooks/exhaustive-deps
122
-
112
+ }
113
+ // eslint-disable-next-line react-hooks/exhaustive-deps
123
114
  }, []);
124
115
  return jsx(Modal, {
125
116
  onClose: handleCloseReactionsDialog,
@@ -20,12 +20,13 @@ export const ReactionsList = ({
20
20
  id: initialEmojiId
21
21
  };
22
22
  });
23
- const theme = useThemeObserver();
23
+ const {
24
+ colorMode
25
+ } = useThemeObserver();
24
26
  const onTabChange = useCallback((index, analyticsEvent) => {
25
27
  if (index === selectedEmoji.index) {
26
28
  return;
27
29
  }
28
-
29
30
  const emojiId = reactions[index].emojiId;
30
31
  setSelectedEmoji({
31
32
  index,
@@ -46,7 +47,7 @@ export const ReactionsList = ({
46
47
  shortName: ''
47
48
  };
48
49
  return jsx("div", {
49
- css: customTabWrapper((emojiId === null || emojiId === void 0 ? void 0 : emojiId.id) === selectedEmoji.id, selectedEmoji.id, theme),
50
+ css: customTabWrapper((emojiId === null || emojiId === void 0 ? void 0 : emojiId.id) === selectedEmoji.id, selectedEmoji.id, colorMode),
50
51
  className: "reaction-elements",
51
52
  key: reaction.emojiId,
52
53
  "data-testid": emojiId === null || emojiId === void 0 ? void 0 : emojiId.id