@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
@@ -10,20 +10,17 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
10
10
  import { Reactions, UfoErrorBoundary } from '../../components';
11
11
  import { ufoExperiences } from '../../store';
12
12
  import { ReactionStatus } from '../../types';
13
-
14
13
  /**
15
14
  * Export the mapper function outside the component so easier to do unit tests
16
15
  */
17
16
  export var mapStateToPropsHelper = function mapStateToPropsHelper(containerAri, ari, state) {
18
17
  var reactionsState = state && state.reactions["".concat(containerAri, "|").concat(ari)];
19
-
20
18
  if (!state || !reactionsState) {
21
19
  return {
22
20
  status: ReactionStatus.notLoaded,
23
21
  reactions: []
24
22
  };
25
23
  }
26
-
27
24
  switch (reactionsState.status) {
28
25
  case ReactionStatus.ready:
29
26
  return {
@@ -31,13 +28,11 @@ export var mapStateToPropsHelper = function mapStateToPropsHelper(containerAri,
31
28
  status: reactionsState.status,
32
29
  flash: state.flash["".concat(containerAri, "|").concat(ari)]
33
30
  };
34
-
35
31
  case ReactionStatus.error:
36
32
  return {
37
33
  status: ReactionStatus.error,
38
34
  reactions: []
39
35
  };
40
-
41
36
  default:
42
37
  return {
43
38
  status: ReactionStatus.loading,
@@ -45,10 +40,10 @@ export var mapStateToPropsHelper = function mapStateToPropsHelper(containerAri,
45
40
  };
46
41
  }
47
42
  };
43
+
48
44
  /**
49
45
  * Export the mapper function outside the component so easier to do unit tests
50
46
  */
51
-
52
47
  export var mapDispatchToPropsHelper = function mapDispatchToPropsHelper(actions, containerAri, ari) {
53
48
  return {
54
49
  loadReaction: function loadReaction() {
@@ -67,38 +62,32 @@ export var mapDispatchToPropsHelper = function mapDispatchToPropsHelper(actions,
67
62
  };
68
63
  export var ConnectedReactionsView = function ConnectedReactionsView(props) {
69
64
  var ari = props.ari,
70
- containerAri = props.containerAri,
71
- store = props.store,
72
- rest = _objectWithoutProperties(props, _excluded);
65
+ containerAri = props.containerAri,
66
+ store = props.store,
67
+ rest = _objectWithoutProperties(props, _excluded);
73
68
  /**
74
69
  * Reference to the <Reactions /> component instance mandatory props
75
70
  */
76
-
77
-
78
71
  var _useState = useState(),
79
- _useState2 = _slicedToArray(_useState, 2),
80
- stateData = _useState2[0],
81
- setStateData = _useState2[1];
82
-
72
+ _useState2 = _slicedToArray(_useState, 2),
73
+ stateData = _useState2[0],
74
+ setStateData = _useState2[1];
83
75
  var _useState3 = useState(),
84
- _useState4 = _slicedToArray(_useState3, 2),
85
- dispatchData = _useState4[0],
86
- setDispatchData = _useState4[1]; // compose a UFO experience object
87
-
88
-
76
+ _useState4 = _slicedToArray(_useState3, 2),
77
+ dispatchData = _useState4[0],
78
+ setDispatchData = _useState4[1];
79
+ // compose a UFO experience object
89
80
  var experienceInstance = useRef();
90
-
91
81
  var _useAnalyticsEvents = useAnalyticsEvents(),
92
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
93
-
82
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
94
83
  useEffect(function () {
95
84
  experienceInstance.current = ufoExperiences.render(ari);
96
- }, [ari]); // abort when component gets unmounted
85
+ }, [ari]);
97
86
 
87
+ // abort when component gets unmounted
98
88
  useEffect(function () {
99
89
  return function cleanup() {
100
90
  var _experienceInstance$c;
101
-
102
91
  (_experienceInstance$c = experienceInstance.current) === null || _experienceInstance$c === void 0 ? void 0 : _experienceInstance$c.abort({
103
92
  metadata: {
104
93
  source: 'ConnectedReactionsView',
@@ -109,45 +98,40 @@ export var ConnectedReactionsView = function ConnectedReactionsView(props) {
109
98
  });
110
99
  };
111
100
  }, [experienceInstance, containerAri, ari]);
101
+
112
102
  /**
113
103
  * Maps the store instance "reactions" data to the <Reactions /> component state data
114
104
  * @param state store instance latest data
115
105
  */
116
-
117
106
  var mapStateToProps = useCallback(function (state) {
118
107
  return mapStateToPropsHelper(containerAri, ari, state);
119
108
  }, [containerAri, ari]);
109
+
120
110
  /**
121
111
  * Map the store instance "actions" methods to the <Reactions /> component actions methods
122
112
  * @param actions list of actions in the store instance
123
113
  */
124
-
125
114
  var mapDispatchToProps = useCallback(function (actions) {
126
115
  return mapDispatchToPropsHelper(actions, containerAri, ari);
127
116
  }, [ari, containerAri]);
128
117
  useEffect(function () {
129
118
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
130
119
  var _store, state, dispatch;
131
-
132
120
  return _regeneratorRuntime.wrap(function _callee$(_context) {
133
121
  while (1) {
134
122
  switch (_context.prev = _context.next) {
135
123
  case 0:
136
124
  _context.next = 2;
137
125
  return Promise.resolve(store);
138
-
139
126
  case 2:
140
127
  _store = _context.sent;
141
-
142
128
  if (_store.setCreateAnalyticsEvent && createAnalyticsEvent) {
143
129
  _store.setCreateAnalyticsEvent(createAnalyticsEvent);
144
130
  }
145
-
146
131
  state = mapStateToProps(_store.getState());
147
132
  dispatch = mapDispatchToProps(_store);
148
133
  setStateData(state);
149
134
  setDispatchData(dispatch);
150
-
151
135
  case 8:
152
136
  case "end":
153
137
  return _context.stop();
@@ -156,33 +140,28 @@ export var ConnectedReactionsView = function ConnectedReactionsView(props) {
156
140
  }, _callee);
157
141
  }))();
158
142
  }, [createAnalyticsEvent, store, ari, containerAri, mapStateToProps, mapDispatchToProps]);
143
+
159
144
  /**
160
145
  * Listen to changes on the store data.
161
146
  * TODO: Needs to be refactored inside the MemoryReactionsStore to different pattern, currently it relies on internal callbacks variable to trigger changes to the store.
162
147
  * 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
163
148
  */
164
-
165
149
  useEffect(function () {
166
150
  var onChangeCallback = function onChangeCallback(state) {
167
151
  var stateProps = mapStateToProps(state);
168
152
  setStateData(stateProps);
169
153
  };
170
-
171
154
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
172
155
  var _store;
173
-
174
156
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
175
157
  while (1) {
176
158
  switch (_context2.prev = _context2.next) {
177
159
  case 0:
178
160
  _context2.next = 2;
179
161
  return Promise.resolve(store);
180
-
181
162
  case 2:
182
163
  _store = _context2.sent;
183
-
184
164
  _store.onChange(onChangeCallback);
185
-
186
165
  case 4:
187
166
  case "end":
188
167
  return _context2.stop();
@@ -190,23 +169,18 @@ export var ConnectedReactionsView = function ConnectedReactionsView(props) {
190
169
  }
191
170
  }, _callee2);
192
171
  }))();
193
-
194
172
  return function cleanup() {
195
173
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
196
174
  var _store;
197
-
198
175
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
199
176
  while (1) {
200
177
  switch (_context3.prev = _context3.next) {
201
178
  case 0:
202
179
  _context3.next = 2;
203
180
  return Promise.resolve(store);
204
-
205
181
  case 2:
206
182
  _store = _context3.sent;
207
-
208
183
  _store.removeOnChangeListener(onChangeCallback);
209
-
210
184
  case 4:
211
185
  case "end":
212
186
  return _context3.stop();
@@ -1,4 +1,5 @@
1
1
  import { useEffect } from 'react';
2
+
2
3
  /**
3
4
  * Custom hook to detect when user action is outside given container ref
4
5
  * @param ref ref object to an html element
@@ -7,7 +8,6 @@ import { useEffect } from 'react';
7
8
  * @param useCapture (Optional) use capture phase of event. @default false
8
9
  * @param enabled (Optional) enable/disable the outside click handler. @default true
9
10
  */
10
-
11
11
  export function useClickAway(ref, callback) {
12
12
  var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'click';
13
13
  var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -20,9 +20,8 @@ export function useClickAway(ref, callback) {
20
20
  if (ref.current && event.target instanceof Node && !ref.current.contains(event.target) && enabled) {
21
21
  callback();
22
22
  }
23
- } // Bind the event listener
24
-
25
-
23
+ }
24
+ // Bind the event listener
26
25
  document.addEventListener(type, handleClickOutside, useCapture);
27
26
  return function () {
28
27
  // Unbind the event listener on clean up
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { UFO } from './analytics';
2
- export { ReactionServiceClient } from './client'; // TODO: Convert all calls for ReactionRequest to Request, RequestClient to Client and ReactionsStore to Store
2
+ export { ReactionServiceClient } from './client';
3
+ // TODO: Convert all calls for ReactionRequest to Request, RequestClient to Client and ReactionsStore to Store
3
4
 
4
5
  export { constants } from './shared';
5
6
  export { Reaction, ReactionPicker, Reactions } from './components';
@@ -20,10 +20,10 @@ export var DefaultReactions = [{
20
20
  id: '1f914',
21
21
  shortName: ':thinking:'
22
22
  }];
23
+
23
24
  /**
24
25
  * Extended list of reactions used only for examples
25
26
  */
26
-
27
27
  export var ExtendedReactions = [{
28
28
  id: '1f44d',
29
29
  shortName: ':thumbsup:'
@@ -67,29 +67,29 @@ export var ExtendedReactions = [{
67
67
  id: '1f642',
68
68
  shortName: ':slight_smile:'
69
69
  }];
70
+
70
71
  /**
71
72
  * ES6 Map object from default emoji reactions (with key => shortName, value => entire emoji item)
72
73
  */
73
-
74
74
  export var DefaultReactionsByShortName = new Map(DefaultReactions.map(function (reaction) {
75
75
  return [reaction.shortName, reaction];
76
76
  }));
77
+
77
78
  /**
78
79
  * ES6 Map object from default emoji reactions (with key => shortName, value => entire emoji item)
79
80
  * Only for use in extended reaction examples
80
81
  */
81
-
82
82
  export var ExtendedReactionsByShortName = new Map(ExtendedReactions.map(function (reaction) {
83
83
  return [reaction.shortName, reaction];
84
84
  }));
85
+
85
86
  /**
86
87
  * Maximum number of users to show in the tooltip for an emoji reaction
87
88
  */
88
-
89
89
  export var TOOLTIP_USERS_LIMIT = 5;
90
+
90
91
  /**
91
92
  * Maximum number of reactions that will fit in the horizontal scroll of
92
93
  * reactions dialog
93
94
  */
94
-
95
95
  export var NUMBER_OF_REACTIONS_TO_DISPLAY = 9;
@@ -1,28 +1,28 @@
1
1
  import { DefaultReactions } from './constants';
2
+
2
3
  /**
3
4
  * Is selected mouse event a left click
4
5
  * @param event event data
5
6
  */
6
-
7
7
  export var isLeftClick = function isLeftClick(event) {
8
8
  return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
9
9
  };
10
+
10
11
  /**
11
12
  * Does provided item part of the default emoji ids
12
13
  * @param item selected emoji item
13
14
  */
14
-
15
15
  export var isDefaultReaction = function isDefaultReaction(item) {
16
16
  return DefaultReactions.some(function (otherEmojiId) {
17
17
  return isEqualEmojiId(otherEmojiId, item);
18
18
  });
19
19
  };
20
+
20
21
  /**
21
22
  * compare 2 emoji items if they are same input
22
23
  * @param a first emoji item
23
24
  * @param b second emoji item
24
25
  */
25
-
26
26
  var isEqualEmojiId = function isEqualEmojiId(a, b) {
27
27
  if (isEmojiId(a) && isEmojiId(b)) {
28
28
  return a === b || a && b && a.id === b.id && a.shortName === b.shortName;
@@ -30,37 +30,32 @@ var isEqualEmojiId = function isEqualEmojiId(a, b) {
30
30
  return a === b;
31
31
  }
32
32
  };
33
+
33
34
  /**
34
35
  * Type guard if provided object is a string id or an object info collection for the emoji
35
36
  * @param item given item
36
37
  */
37
-
38
-
39
38
  var isEmojiId = function isEmojiId(item) {
40
39
  return item.id !== undefined;
41
40
  };
42
-
43
41
  export var formatStringWithDecimal = function formatStringWithDecimal(value, decimalPlaces) {
44
42
  var decimalIndex = value.indexOf('.');
45
-
46
43
  if (decimalIndex === -1) {
47
44
  // Integers with trailing 0s will have no decimal (Ex. 18000, 7700000, 500)
48
45
  return value.substring(0, value.length);
49
46
  }
50
-
51
47
  if (decimalPlaces === 0) {
52
48
  // Return an integer value
53
49
  return value.substring(0, decimalIndex);
54
50
  }
55
-
56
51
  return value.substring(0, decimalIndex + decimalPlaces + 1);
57
52
  };
53
+
58
54
  /**
59
55
  * Truncates numbers >= 1000 to shorthand representations with a maximum of one decimal point.
60
56
  * If the first decimal number is a zero then it's also truncated.
61
57
  * (Ex: 9085 will return 9K, 787555 will return 787.5M)
62
58
  */
63
-
64
59
  export var formatLargeNumber = function formatLargeNumber(value) {
65
60
  // 999M+
66
61
  var maxLimit = 999999999;
@@ -68,11 +63,9 @@ export var formatLargeNumber = function formatLargeNumber(value) {
68
63
  var millionSeparator = 1000 * 1000;
69
64
  var valueInK = value / thounsandSeparator;
70
65
  var valueInM = value / millionSeparator;
71
-
72
66
  if (value > maxLimit) {
73
67
  return '999.9M+';
74
68
  }
75
-
76
69
  if (value >= 1000000) {
77
70
  // determine the decimal breakpoints by length and check its value
78
71
  // 1234567 -> 1.234567 and decimal value is 2
@@ -80,15 +73,12 @@ export var formatLargeNumber = function formatLargeNumber(value) {
80
73
  var decimalIndexValue = valueInM.toString().charAt(numDigits - 5);
81
74
  return decimalIndexValue === '0' ? formatStringWithDecimal(valueInM.toString(), 0) + 'M' : formatStringWithDecimal(valueInM.toString(), 1) + 'M';
82
75
  }
83
-
84
76
  if (value >= 1000) {
85
77
  var _numDigits = value.toString().length;
86
-
87
78
  var _decimalIndexValue = valueInK.toString().charAt(_numDigits - 2);
88
-
89
79
  return _decimalIndexValue === '0' ? formatStringWithDecimal(valueInK.toString(), 0) + 'K' : formatStringWithDecimal(valueInK.toString(), 1) + 'K';
90
- } // <999
91
-
80
+ }
92
81
 
82
+ // <999
93
83
  return value.toString();
94
84
  };