@atlaskit/emoji 67.0.7 → 67.2.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 (238) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/cjs/api/EmojiResource.js +41 -25
  3. package/dist/cjs/api/media/TokenManager.js +4 -4
  4. package/dist/cjs/components/common/CachingEmoji.js +14 -6
  5. package/dist/cjs/components/common/Emoji.js +48 -12
  6. package/dist/cjs/components/common/EmojiActions.js +62 -26
  7. package/dist/cjs/components/common/EmojiErrorMessage.js +12 -7
  8. package/dist/cjs/components/common/EmojiPlaceholder.js +1 -0
  9. package/dist/cjs/components/common/{EmojiButton.js → EmojiRadioButton.js} +28 -19
  10. package/dist/cjs/components/common/EmojiUploadPicker.js +80 -37
  11. package/dist/cjs/components/common/EmojiUploadPreview.js +11 -2
  12. package/dist/cjs/components/common/FileChooser.js +2 -2
  13. package/dist/cjs/components/common/ResourcedEmojiComponent.js +4 -0
  14. package/dist/cjs/components/common/RetryableButton.js +7 -3
  15. package/dist/cjs/components/common/TonePreviewButton.js +44 -0
  16. package/dist/cjs/components/common/ToneSelector.js +53 -25
  17. package/dist/cjs/components/common/styles.js +45 -16
  18. package/dist/cjs/components/i18n.js +44 -4
  19. package/dist/cjs/components/picker/CategorySelector.js +112 -90
  20. package/dist/cjs/components/picker/CategoryTracker.js +0 -28
  21. package/dist/cjs/components/picker/EmojiPickerCategoryHeading.js +2 -1
  22. package/dist/cjs/components/picker/EmojiPickerComponent.js +33 -44
  23. package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +32 -4
  24. package/dist/cjs/components/picker/EmojiPickerList.js +154 -88
  25. package/dist/cjs/components/picker/EmojiPickerListSearch.js +66 -117
  26. package/dist/cjs/components/picker/EmojiPickerVirtualItems.js +5 -2
  27. package/dist/cjs/components/picker/VirtualList.js +273 -171
  28. package/dist/cjs/components/picker/styles.js +43 -51
  29. package/dist/cjs/components/typeahead/EmojiTypeAheadComponent.js +0 -10
  30. package/dist/cjs/context/EmojiPickerListContext.js +33 -0
  31. package/dist/cjs/hooks/useEmojiPickerListContext.js +12 -0
  32. package/dist/cjs/hooks/useIsMounted.js +17 -0
  33. package/dist/cjs/i18n/cs.js +35 -34
  34. package/dist/cjs/i18n/da.js +35 -34
  35. package/dist/cjs/i18n/de.js +35 -34
  36. package/dist/cjs/i18n/en.js +35 -34
  37. package/dist/cjs/i18n/en_GB.js +35 -34
  38. package/dist/cjs/i18n/es.js +35 -34
  39. package/dist/cjs/i18n/fi.js +35 -34
  40. package/dist/cjs/i18n/fr.js +35 -34
  41. package/dist/cjs/i18n/hu.js +35 -34
  42. package/dist/cjs/i18n/it.js +35 -34
  43. package/dist/cjs/i18n/ja.js +35 -34
  44. package/dist/cjs/i18n/ko.js +35 -34
  45. package/dist/cjs/i18n/nb.js +35 -34
  46. package/dist/cjs/i18n/nl.js +35 -34
  47. package/dist/cjs/i18n/pl.js +35 -34
  48. package/dist/cjs/i18n/pt_BR.js +35 -34
  49. package/dist/cjs/i18n/ru.js +35 -34
  50. package/dist/cjs/i18n/sv.js +35 -34
  51. package/dist/cjs/i18n/th.js +35 -34
  52. package/dist/cjs/i18n/tr.js +35 -34
  53. package/dist/cjs/i18n/uk.js +35 -34
  54. package/dist/cjs/i18n/vi.js +35 -34
  55. package/dist/cjs/i18n/zh.js +35 -34
  56. package/dist/cjs/i18n/zh_TW.js +35 -34
  57. package/dist/cjs/types.js +7 -1
  58. package/dist/cjs/util/constants.js +43 -2
  59. package/dist/cjs/util/shared-styles.js +3 -4
  60. package/dist/cjs/version.json +1 -1
  61. package/dist/es2019/api/EmojiResource.js +42 -26
  62. package/dist/es2019/api/media/TokenManager.js +4 -4
  63. package/dist/es2019/components/common/CachingEmoji.js +10 -3
  64. package/dist/es2019/components/common/Emoji.js +44 -11
  65. package/dist/es2019/components/common/EmojiActions.js +55 -24
  66. package/dist/es2019/components/common/EmojiErrorMessage.js +7 -3
  67. package/dist/es2019/components/common/EmojiPlaceholder.js +1 -0
  68. package/dist/es2019/components/common/EmojiRadioButton.js +54 -0
  69. package/dist/es2019/components/common/EmojiUploadPicker.js +75 -36
  70. package/dist/es2019/components/common/EmojiUploadPreview.js +11 -2
  71. package/dist/es2019/components/common/FileChooser.js +1 -1
  72. package/dist/es2019/components/common/ResourcedEmojiComponent.js +4 -0
  73. package/dist/es2019/components/common/RetryableButton.js +7 -3
  74. package/dist/es2019/components/common/TonePreviewButton.js +34 -0
  75. package/dist/es2019/components/common/ToneSelector.js +55 -21
  76. package/dist/es2019/components/common/styles.js +41 -10
  77. package/dist/es2019/components/i18n.js +44 -4
  78. package/dist/es2019/components/picker/CategorySelector.js +114 -89
  79. package/dist/es2019/components/picker/CategoryTracker.js +0 -24
  80. package/dist/es2019/components/picker/EmojiPickerCategoryHeading.js +2 -2
  81. package/dist/es2019/components/picker/EmojiPickerComponent.js +36 -46
  82. package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +51 -21
  83. package/dist/es2019/components/picker/EmojiPickerList.js +113 -55
  84. package/dist/es2019/components/picker/EmojiPickerListSearch.js +61 -98
  85. package/dist/es2019/components/picker/EmojiPickerVirtualItems.js +4 -1
  86. package/dist/es2019/components/picker/VirtualList.js +247 -108
  87. package/dist/es2019/components/picker/styles.js +20 -28
  88. package/dist/es2019/components/typeahead/EmojiTypeAheadComponent.js +0 -10
  89. package/dist/es2019/context/EmojiPickerListContext.js +17 -0
  90. package/dist/es2019/hooks/useEmojiPickerListContext.js +3 -0
  91. package/dist/es2019/hooks/useIsMounted.js +11 -0
  92. package/dist/es2019/i18n/cs.js +35 -34
  93. package/dist/es2019/i18n/da.js +35 -34
  94. package/dist/es2019/i18n/de.js +35 -34
  95. package/dist/es2019/i18n/en.js +35 -34
  96. package/dist/es2019/i18n/en_GB.js +35 -34
  97. package/dist/es2019/i18n/es.js +35 -34
  98. package/dist/es2019/i18n/fi.js +35 -34
  99. package/dist/es2019/i18n/fr.js +35 -34
  100. package/dist/es2019/i18n/hu.js +35 -34
  101. package/dist/es2019/i18n/it.js +35 -34
  102. package/dist/es2019/i18n/ja.js +35 -34
  103. package/dist/es2019/i18n/ko.js +35 -34
  104. package/dist/es2019/i18n/nb.js +35 -34
  105. package/dist/es2019/i18n/nl.js +35 -34
  106. package/dist/es2019/i18n/pl.js +35 -34
  107. package/dist/es2019/i18n/pt_BR.js +35 -34
  108. package/dist/es2019/i18n/ru.js +35 -34
  109. package/dist/es2019/i18n/sv.js +35 -34
  110. package/dist/es2019/i18n/th.js +35 -34
  111. package/dist/es2019/i18n/tr.js +35 -34
  112. package/dist/es2019/i18n/uk.js +35 -34
  113. package/dist/es2019/i18n/vi.js +35 -34
  114. package/dist/es2019/i18n/zh.js +35 -34
  115. package/dist/es2019/i18n/zh_TW.js +35 -34
  116. package/dist/es2019/types.js +5 -0
  117. package/dist/es2019/util/constants.js +32 -0
  118. package/dist/es2019/util/shared-styles.js +1 -2
  119. package/dist/es2019/version.json +1 -1
  120. package/dist/esm/api/EmojiResource.js +42 -26
  121. package/dist/esm/api/media/TokenManager.js +4 -4
  122. package/dist/esm/components/common/CachingEmoji.js +14 -6
  123. package/dist/esm/components/common/Emoji.js +48 -12
  124. package/dist/esm/components/common/EmojiActions.js +62 -26
  125. package/dist/esm/components/common/EmojiErrorMessage.js +7 -3
  126. package/dist/esm/components/common/EmojiPlaceholder.js +1 -0
  127. package/dist/esm/components/common/EmojiRadioButton.js +52 -0
  128. package/dist/esm/components/common/EmojiUploadPicker.js +77 -36
  129. package/dist/esm/components/common/EmojiUploadPreview.js +11 -2
  130. package/dist/esm/components/common/FileChooser.js +1 -1
  131. package/dist/esm/components/common/ResourcedEmojiComponent.js +4 -0
  132. package/dist/esm/components/common/RetryableButton.js +7 -3
  133. package/dist/esm/components/common/TonePreviewButton.js +33 -0
  134. package/dist/esm/components/common/ToneSelector.js +49 -18
  135. package/dist/esm/components/common/styles.js +40 -12
  136. package/dist/esm/components/i18n.js +44 -4
  137. package/dist/esm/components/picker/CategorySelector.js +114 -95
  138. package/dist/esm/components/picker/CategoryTracker.js +0 -28
  139. package/dist/esm/components/picker/EmojiPickerCategoryHeading.js +2 -2
  140. package/dist/esm/components/picker/EmojiPickerComponent.js +35 -46
  141. package/dist/esm/components/picker/EmojiPickerEmojiRow.js +32 -4
  142. package/dist/esm/components/picker/EmojiPickerList.js +156 -86
  143. package/dist/esm/components/picker/EmojiPickerListSearch.js +64 -117
  144. package/dist/esm/components/picker/EmojiPickerVirtualItems.js +5 -2
  145. package/dist/esm/components/picker/VirtualList.js +274 -172
  146. package/dist/esm/components/picker/styles.js +37 -45
  147. package/dist/esm/components/typeahead/EmojiTypeAheadComponent.js +0 -10
  148. package/dist/esm/context/EmojiPickerListContext.js +21 -0
  149. package/dist/esm/hooks/useEmojiPickerListContext.js +5 -0
  150. package/dist/esm/hooks/useIsMounted.js +11 -0
  151. package/dist/esm/i18n/cs.js +35 -34
  152. package/dist/esm/i18n/da.js +35 -34
  153. package/dist/esm/i18n/de.js +35 -34
  154. package/dist/esm/i18n/en.js +35 -34
  155. package/dist/esm/i18n/en_GB.js +35 -34
  156. package/dist/esm/i18n/es.js +35 -34
  157. package/dist/esm/i18n/fi.js +35 -34
  158. package/dist/esm/i18n/fr.js +35 -34
  159. package/dist/esm/i18n/hu.js +35 -34
  160. package/dist/esm/i18n/it.js +35 -34
  161. package/dist/esm/i18n/ja.js +35 -34
  162. package/dist/esm/i18n/ko.js +35 -34
  163. package/dist/esm/i18n/nb.js +35 -34
  164. package/dist/esm/i18n/nl.js +35 -34
  165. package/dist/esm/i18n/pl.js +35 -34
  166. package/dist/esm/i18n/pt_BR.js +35 -34
  167. package/dist/esm/i18n/ru.js +35 -34
  168. package/dist/esm/i18n/sv.js +35 -34
  169. package/dist/esm/i18n/th.js +35 -34
  170. package/dist/esm/i18n/tr.js +35 -34
  171. package/dist/esm/i18n/uk.js +35 -34
  172. package/dist/esm/i18n/vi.js +35 -34
  173. package/dist/esm/i18n/zh.js +35 -34
  174. package/dist/esm/i18n/zh_TW.js +35 -34
  175. package/dist/esm/types.js +5 -0
  176. package/dist/esm/util/constants.js +32 -0
  177. package/dist/esm/util/shared-styles.js +1 -2
  178. package/dist/esm/version.json +1 -1
  179. package/dist/types/api/EmojiResource.d.ts +2 -0
  180. package/dist/types/components/common/Emoji.d.ts +7 -1
  181. package/dist/types/components/common/EmojiActions.d.ts +4 -3
  182. package/dist/types/components/common/{EmojiButton.d.ts → EmojiRadioButton.d.ts} +3 -4
  183. package/dist/types/components/common/EmojiUploadPicker.d.ts +6 -4
  184. package/dist/types/components/common/RetryableButton.d.ts +1 -0
  185. package/dist/types/components/common/TonePreviewButton.d.ts +14 -0
  186. package/dist/types/components/common/ToneSelector.d.ts +8 -5
  187. package/dist/types/components/common/internal-types.d.ts +9 -0
  188. package/dist/types/components/common/styles.d.ts +2 -1
  189. package/dist/types/components/i18n.d.ts +40 -0
  190. package/dist/types/components/picker/CategorySelector.d.ts +3 -10
  191. package/dist/types/components/picker/CategoryTracker.d.ts +0 -2
  192. package/dist/types/components/picker/EmojiPickerCategoryHeading.d.ts +2 -1
  193. package/dist/types/components/picker/EmojiPickerEmojiRow.d.ts +5 -0
  194. package/dist/types/components/picker/EmojiPickerList.d.ts +14 -7
  195. package/dist/types/components/picker/EmojiPickerListSearch.d.ts +4 -8
  196. package/dist/types/components/picker/EmojiPickerVirtualItems.d.ts +1 -1
  197. package/dist/types/components/picker/VirtualList.d.ts +7 -24
  198. package/dist/types/components/picker/styles.d.ts +1 -1
  199. package/dist/types/context/EmojiPickerListContext.d.ts +10 -0
  200. package/dist/types/hooks/useEmojiPickerListContext.d.ts +1 -0
  201. package/dist/types/hooks/useIsMounted.d.ts +1 -0
  202. package/dist/types/i18n/cs.d.ts +34 -34
  203. package/dist/types/i18n/da.d.ts +34 -34
  204. package/dist/types/i18n/de.d.ts +34 -34
  205. package/dist/types/i18n/en.d.ts +34 -34
  206. package/dist/types/i18n/en_GB.d.ts +34 -34
  207. package/dist/types/i18n/es.d.ts +34 -34
  208. package/dist/types/i18n/fi.d.ts +34 -34
  209. package/dist/types/i18n/fr.d.ts +34 -34
  210. package/dist/types/i18n/hu.d.ts +34 -34
  211. package/dist/types/i18n/it.d.ts +34 -34
  212. package/dist/types/i18n/ja.d.ts +34 -34
  213. package/dist/types/i18n/ko.d.ts +34 -34
  214. package/dist/types/i18n/nb.d.ts +34 -34
  215. package/dist/types/i18n/nl.d.ts +34 -34
  216. package/dist/types/i18n/pl.d.ts +34 -34
  217. package/dist/types/i18n/pt_BR.d.ts +34 -34
  218. package/dist/types/i18n/ru.d.ts +34 -34
  219. package/dist/types/i18n/sv.d.ts +34 -34
  220. package/dist/types/i18n/th.d.ts +34 -34
  221. package/dist/types/i18n/tr.d.ts +34 -34
  222. package/dist/types/i18n/uk.d.ts +34 -34
  223. package/dist/types/i18n/vi.d.ts +34 -34
  224. package/dist/types/i18n/zh.d.ts +34 -34
  225. package/dist/types/i18n/zh_TW.d.ts +34 -34
  226. package/dist/types/types.d.ts +5 -0
  227. package/dist/types/util/constants.d.ts +28 -0
  228. package/dist/types/util/shared-styles.d.ts +1 -1
  229. package/dist/types/util/type-helpers.d.ts +1 -1
  230. package/package.json +12 -8
  231. package/report.api.md +62 -1
  232. package/README.md +0 -3
  233. package/dist/cjs/components/hooks.js +0 -14
  234. package/dist/es2019/components/common/EmojiButton.js +0 -49
  235. package/dist/es2019/components/hooks.js +0 -8
  236. package/dist/esm/components/common/EmojiButton.js +0 -43
  237. package/dist/esm/components/hooks.js +0 -8
  238. package/dist/types/components/hooks.d.ts +0 -1
@@ -1,17 +1,18 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
5
  import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
6
  import _inherits from "@babel/runtime/helpers/inherits";
6
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
  /** @jsx jsx */
12
- import React, { PureComponent } from 'react';
12
+ import { createRef, PureComponent } from 'react';
13
13
  import { jsx } from '@emotion/react';
14
- import { customCategory, defaultEmojiPickerSize, userCustomTitle } from '../../util/constants';
14
+ import VisuallyHidden from '@atlaskit/visually-hidden';
15
+ import { customCategory, defaultEmojiPickerSize, frequentCategory, searchCategory, userCustomTitle, yourUploadsCategory } from '../../util/constants';
15
16
  import { CategoryDescriptionMap } from './categories';
16
17
  import CategoryTracker from './CategoryTracker';
17
18
  import { sizes } from './EmojiPickerSizes';
@@ -20,6 +21,10 @@ import EmojiActions from '../common/EmojiActions';
20
21
  import { emojiPickerList } from './styles';
21
22
  import { emojiPickerHeightOffset } from './utils';
22
23
  import { VirtualList } from './VirtualList';
24
+ import { injectIntl } from 'react-intl-next';
25
+ import { messages } from '../i18n';
26
+ import { EmojiPickerListContextProvider } from '../../context/EmojiPickerListContext';
27
+
23
28
  /**
24
29
  * Test id for wrapper Emoji Picker List div
25
30
  */
@@ -28,29 +33,66 @@ var categoryClassname = 'emoji-category';
28
33
  var byOrder = function byOrder(orderableA, orderableB) {
29
34
  return (orderableA.order || 0) - (orderableB.order || 0);
30
35
  };
31
- var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
32
- _inherits(EmojiPickerVirtualList, _PureComponent);
33
- var _super = _createSuper(EmojiPickerVirtualList);
34
- function EmojiPickerVirtualList(_props) {
36
+
37
+ /**
38
+ * TODO: have to use class component here as unit test is relying on ref.root. Will refactor this whole file to functional component in future
39
+ * ticket: COLLAB-2317
40
+ */
41
+ var EmojiPickerTabPanelInternal = /*#__PURE__*/function (_PureComponent) {
42
+ _inherits(EmojiPickerTabPanelInternal, _PureComponent);
43
+ var _super = _createSuper(EmojiPickerTabPanelInternal);
44
+ function EmojiPickerTabPanelInternal() {
45
+ _classCallCheck(this, EmojiPickerTabPanelInternal);
46
+ return _super.apply(this, arguments);
47
+ }
48
+ _createClass(EmojiPickerTabPanelInternal, [{
49
+ key: "render",
50
+ value: function render() {
51
+ var _this$props = this.props,
52
+ formatMessage = _this$props.intl.formatMessage,
53
+ children = _this$props.children,
54
+ showSearchResults = _this$props.showSearchResults;
55
+ return jsx("div", {
56
+ ref: "root",
57
+ css: emojiPickerList,
58
+ "data-testid": RENDER_EMOJI_PICKER_LIST_TESTID,
59
+ id: RENDER_EMOJI_PICKER_LIST_TESTID,
60
+ role: "tabpanel",
61
+ "aria-label": formatMessage(messages.emojiPickerListPanel)
62
+ }, jsx(VisuallyHidden, {
63
+ id: "emoji-picker-table-description"
64
+ }, formatMessage(messages.emojiPickerGrid, {
65
+ showSearchResults: showSearchResults
66
+ })), children);
67
+ }
68
+ }]);
69
+ return EmojiPickerTabPanelInternal;
70
+ }(PureComponent);
71
+ var EmojiPickerTabPanel = injectIntl(EmojiPickerTabPanelInternal);
72
+ var EmojiPickerVirtualListInternal = /*#__PURE__*/function (_PureComponent2) {
73
+ _inherits(EmojiPickerVirtualListInternal, _PureComponent2);
74
+ var _super2 = _createSuper(EmojiPickerVirtualListInternal);
75
+ function EmojiPickerVirtualListInternal(_props) {
35
76
  var _this;
36
- _classCallCheck(this, EmojiPickerVirtualList);
37
- _this = _super.call(this, _props);
77
+ _classCallCheck(this, EmojiPickerVirtualListInternal);
78
+ _this = _super2.call(this, _props);
38
79
  _defineProperty(_assertThisInitialized(_this), "virtualItems", []);
39
80
  _defineProperty(_assertThisInitialized(_this), "categoryTracker", new CategoryTracker());
40
- _defineProperty(_assertThisInitialized(_this), "onEmojiMouseEnter", function (emojiId, emoji) {
81
+ _defineProperty(_assertThisInitialized(_this), "listRef", /*#__PURE__*/createRef());
82
+ _defineProperty(_assertThisInitialized(_this), "onEmojiActive", function (emojiId, emoji) {
41
83
  if (_this.props.onEmojiActive) {
42
84
  _this.props.onEmojiActive(emojiId, emoji);
43
85
  }
44
86
  });
45
- _defineProperty(_assertThisInitialized(_this), "onSearch", function (e) {
87
+ _defineProperty(_assertThisInitialized(_this), "onSearch", function (value) {
46
88
  if (_this.props.onSearch) {
47
- _this.props.onSearch(e.target.value);
89
+ _this.props.onSearch(value);
48
90
  }
49
91
  });
50
92
  _defineProperty(_assertThisInitialized(_this), "buildVirtualItemFromGroup", function (group) {
51
- var _this$props = _this.props,
52
- onEmojiSelected = _this$props.onEmojiSelected,
53
- onEmojiDelete = _this$props.onEmojiDelete;
93
+ var _this$props2 = _this.props,
94
+ onEmojiSelected = _this$props2.onEmojiSelected,
95
+ onEmojiDelete = _this$props2.onEmojiDelete;
54
96
  var items = [];
55
97
  items.push(new CategoryHeadingItem({
56
98
  id: group.category,
@@ -62,12 +104,14 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
62
104
  var rowEmojis = remainingEmojis.slice(0, sizes.emojiPerRow);
63
105
  remainingEmojis = remainingEmojis.slice(sizes.emojiPerRow);
64
106
  items.push(new EmojisRowItem({
107
+ category: group.category,
65
108
  emojis: rowEmojis,
66
109
  title: group.title,
67
110
  showDelete: group.title === userCustomTitle,
68
111
  onSelected: onEmojiSelected,
69
112
  onDelete: onEmojiDelete,
70
- onMouseMove: _this.onEmojiMouseEnter
113
+ onMouseMove: _this.onEmojiActive,
114
+ onFocus: _this.onEmojiActive
71
115
  }));
72
116
  }
73
117
  return items;
@@ -85,7 +129,7 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
85
129
  var search = CategoryDescriptionMap.SEARCH;
86
130
  // Only a single "result" category
87
131
  items = [].concat(_toConsumableArray(items), _toConsumableArray(_this.buildVirtualItemFromGroup({
88
- category: 'SEARCH',
132
+ category: searchCategory,
89
133
  title: search.name,
90
134
  emojis: emojis,
91
135
  order: search.order
@@ -99,22 +143,16 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
99
143
  // by not passing it to irrelevant groups
100
144
  _this.categoryTracker.add(group.emojis[0].category, items.length);
101
145
  items = [].concat(_toConsumableArray(items), _toConsumableArray(_this.buildVirtualItemFromGroup(group)));
146
+ if (group.category === yourUploadsCategory) {
147
+ _this.lastYourUploadsRow = items.length - 1;
148
+ }
149
+ });
150
+ _this.onRowsRendered({
151
+ startIndex: 0
102
152
  });
103
153
  }
104
154
  }
105
- var rowCountChanged = _this.virtualItems.length !== items.length;
106
155
  _this.virtualItems = items;
107
- var list = _this.refs.list;
108
- if (!rowCountChanged && list) {
109
- // Row count has not changed, so need to tell list to rerender.
110
- list.forceUpdateGrid();
111
- }
112
- if (!query && list) {
113
- // VirtualList can apply stale heights since it performs a shallow
114
- // compare to check if the list has changed. Should manually recompute
115
- // row heights for the case when frequent category come in later
116
- list.recomputeRowHeights();
117
- }
118
156
  });
119
157
  _defineProperty(_assertThisInitialized(_this), "addToCategoryMap", function (categoryToGroupMap, emoji, category) {
120
158
  if (!categoryToGroupMap[category]) {
@@ -134,7 +172,7 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
134
172
  _this.addToCategoryMap(categoryToGroupMap, emoji, emoji.category);
135
173
  // separate user emojis
136
174
  if (emoji.category === customCategory && currentUser && emoji.creatorUserId === currentUser.id) {
137
- _this.addToCategoryMap(categoryToGroupMap, emoji, 'USER_CUSTOM');
175
+ _this.addToCategoryMap(categoryToGroupMap, emoji, yourUploadsCategory);
138
176
  }
139
177
  return categoryToGroupMap;
140
178
  };
@@ -144,37 +182,45 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
144
182
  _this.allEmojiGroups = Object.keys(categoryToGroupMap).map(function (key) {
145
183
  return categoryToGroupMap[key];
146
184
  }).map(function (group) {
147
- if (group.category !== 'FREQUENT') {
185
+ if (group.category !== frequentCategory) {
148
186
  group.emojis.sort(byOrder);
149
187
  }
150
188
  return group;
151
189
  }).sort(byOrder);
152
190
  });
153
- _defineProperty(_assertThisInitialized(_this), "repaintList", function () {
154
- if (_this.refs.root) {
155
- var root = _this.refs.root;
156
- var display = root.style.display;
157
- root.style.display = 'none';
158
-
159
- // we need to access offset to force repaint
160
- // eslint-disable-next-line no-unused-expressions
161
- root.offsetHeight;
162
- root.style.display = display;
191
+ _defineProperty(_assertThisInitialized(_this), "findCategoryToActivate", function (row) {
192
+ var category = null;
193
+ if (row instanceof CategoryHeadingItem) {
194
+ category = row.props.id;
195
+ } else if (row instanceof EmojisRowItem) {
196
+ category = row.props.category;
197
+ }
198
+ // your uploads is rendered, take it as upload category, so could be highlighted in category selector
199
+ if (category === yourUploadsCategory) {
200
+ return customCategory;
201
+ // search results is rendered, return null so won't be highlighted for category selector
202
+ } else if (category === searchCategory) {
203
+ return null;
163
204
  }
205
+ return category;
164
206
  });
165
- _defineProperty(_assertThisInitialized(_this), "checkCategoryIdChange", function (indexes) {
207
+ _defineProperty(_assertThisInitialized(_this), "onRowsRendered", function (indexes) {
166
208
  var startIndex = indexes.startIndex;
209
+ var rowItem = _this.virtualItems[startIndex];
210
+ var list = _this.listRef.current;
167
211
 
168
- // FS-1844 Fix a rendering problem when scrolling to the top
169
- if (startIndex === 0) {
170
- _this.repaintList();
212
+ // update tabIndex manually, startIndex is not 0 based here
213
+ if (rowItem instanceof CategoryHeadingItem) {
214
+ // if top of row rendered is category heading, update tabIndex for the next emoji row
215
+ list === null || list === void 0 ? void 0 : list.updateFocusIndex(startIndex + 1);
216
+ } else if (rowItem instanceof EmojisRowItem) {
217
+ // if top of row rendered is emoji row, update it's tabIndex.
218
+ list === null || list === void 0 ? void 0 : list.updateFocusIndex(startIndex);
171
219
  }
172
220
  if (!_this.props.query) {
173
221
  // Calculate category in view - only relevant if categories shown, i.e. no query
174
- var list = _this.refs.list;
175
- var currentCategory = _this.categoryTracker.findNearestCategoryAbove(startIndex, list);
176
- if (currentCategory && _this.activeCategoryId !== currentCategory) {
177
- _this.activeCategoryId = currentCategory;
222
+ var currentCategory = _this.findCategoryToActivate(rowItem);
223
+ if (currentCategory !== null && _this.props.activeCategoryId !== currentCategory) {
178
224
  if (_this.props.onCategoryActivated) {
179
225
  _this.props.onCategoryActivated(currentCategory);
180
226
  }
@@ -188,11 +234,12 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
188
234
  _defineProperty(_assertThisInitialized(_this), "renderRow", function (context) {
189
235
  return virtualItemRenderer(_this.virtualItems, context);
190
236
  });
237
+ _this.lastYourUploadsRow = 0;
191
238
  _this.buildEmojiGroupedByCategory(_props.emojis, _props.currentUser);
192
239
  _this.buildVirtualItems(_props, _this.state);
193
240
  return _this;
194
241
  }
195
- _createClass(EmojiPickerVirtualList, [{
242
+ _createClass(EmojiPickerVirtualListInternal, [{
196
243
  key: "UNSAFE_componentWillUpdate",
197
244
  value: function UNSAFE_componentWillUpdate(nextProps, nextState) {
198
245
  if (this.props.emojis !== nextProps.emojis || this.props.selectedTone !== nextProps.selectedTone || this.props.loading !== nextProps.loading || this.props.query !== nextProps.query) {
@@ -211,42 +258,59 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
211
258
  */
212
259
  function reveal(category) {
213
260
  var row = this.categoryTracker.getRow(category);
214
- var list = this.refs.list;
215
- list.scrollToRow(row);
261
+ this.scrollToRow(row);
216
262
  }
217
263
  }, {
218
264
  key: "scrollToBottom",
219
265
  value: function scrollToBottom() {
220
- var list = this.refs.list;
221
- list.scrollToRow(this.virtualItems.length);
266
+ this.scrollToRow(this.virtualItems.length);
267
+ }
268
+ }, {
269
+ key: "scrollToTop",
270
+ value: function scrollToTop() {
271
+ this.scrollToRow(0);
272
+ }
273
+ }, {
274
+ key: "scrollToRow",
275
+ value: function scrollToRow(index) {
276
+ var _this$listRef$current;
277
+ (_this$listRef$current = this.listRef.current) === null || _this$listRef$current === void 0 ? void 0 : _this$listRef$current.scrollToRow(index);
278
+ }
279
+ }, {
280
+ key: "scrollToRecentlyUploaded",
281
+ value: function scrollToRecentlyUploaded() {
282
+ var row = this.lastYourUploadsRow;
283
+ if (row > 0) {
284
+ var _this$listRef$current2;
285
+ (_this$listRef$current2 = this.listRef.current) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.scrollToRowAndFocusLastEmoji(this.lastYourUploadsRow);
286
+ }
222
287
  }
223
288
  }, {
224
289
  key: "render",
225
290
  value: function render() {
226
- var _this$props2 = this.props,
227
- query = _this$props2.query,
228
- selectedTone = _this$props2.selectedTone,
229
- onToneSelected = _this$props2.onToneSelected,
230
- onToneSelectorCancelled = _this$props2.onToneSelectorCancelled,
231
- toneEmoji = _this$props2.toneEmoji,
232
- uploading = _this$props2.uploading,
233
- uploadEnabled = _this$props2.uploadEnabled,
234
- emojiToDelete = _this$props2.emojiToDelete,
235
- initialUploadName = _this$props2.initialUploadName,
236
- uploadErrorMessage = _this$props2.uploadErrorMessage,
237
- onUploadCancelled = _this$props2.onUploadCancelled,
238
- onUploadEmoji = _this$props2.onUploadEmoji,
239
- onCloseDelete = _this$props2.onCloseDelete,
240
- onDeleteEmoji = _this$props2.onDeleteEmoji,
241
- onFileChooserClicked = _this$props2.onFileChooserClicked,
242
- onOpenUpload = _this$props2.onOpenUpload,
243
- _this$props2$size = _this$props2.size,
244
- size = _this$props2$size === void 0 ? defaultEmojiPickerSize : _this$props2$size;
291
+ var _this$props3 = this.props,
292
+ query = _this$props3.query,
293
+ selectedTone = _this$props3.selectedTone,
294
+ onToneSelected = _this$props3.onToneSelected,
295
+ onToneSelectorCancelled = _this$props3.onToneSelectorCancelled,
296
+ toneEmoji = _this$props3.toneEmoji,
297
+ uploading = _this$props3.uploading,
298
+ uploadEnabled = _this$props3.uploadEnabled,
299
+ emojiToDelete = _this$props3.emojiToDelete,
300
+ initialUploadName = _this$props3.initialUploadName,
301
+ uploadErrorMessage = _this$props3.uploadErrorMessage,
302
+ onUploadCancelled = _this$props3.onUploadCancelled,
303
+ onUploadEmoji = _this$props3.onUploadEmoji,
304
+ onCloseDelete = _this$props3.onCloseDelete,
305
+ onDeleteEmoji = _this$props3.onDeleteEmoji,
306
+ onFileChooserClicked = _this$props3.onFileChooserClicked,
307
+ onOpenUpload = _this$props3.onOpenUpload,
308
+ _this$props3$size = _this$props3.size,
309
+ size = _this$props3$size === void 0 ? defaultEmojiPickerSize : _this$props3$size,
310
+ emojis = _this$props3.emojis;
245
311
  var virtualListHeight = sizes.listHeight + emojiPickerHeightOffset(size);
246
- return jsx("div", {
247
- ref: "root",
248
- css: emojiPickerList,
249
- "data-testid": RENDER_EMOJI_PICKER_LIST_TESTID
312
+ return jsx(EmojiPickerTabPanel, {
313
+ showSearchResults: !!query
250
314
  }, jsx(EmojiActions, {
251
315
  selectedTone: selectedTone,
252
316
  onToneSelected: onToneSelected,
@@ -264,9 +328,15 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
264
328
  onFileChooserClicked: onFileChooserClicked,
265
329
  onOpenUpload: onOpenUpload,
266
330
  query: query,
267
- onChange: this.onSearch
268
- }), jsx(VirtualList, {
269
- ref: "list",
331
+ onChange: this.onSearch,
332
+ resultsCount: emojis.length
333
+ }), jsx(EmojiPickerListContextProvider, {
334
+ initialEmojisFocus: {
335
+ rowIndex: 1,
336
+ columnIndex: 0
337
+ }
338
+ }, jsx(VirtualList, {
339
+ ref: this.listRef,
270
340
  height: virtualListHeight,
271
341
  overscanRowCount: 10,
272
342
  rowCount: this.virtualItems.length,
@@ -274,13 +344,13 @@ var EmojiPickerVirtualList = /*#__PURE__*/function (_PureComponent) {
274
344
  rowRenderer: this.renderRow,
275
345
  scrollToAlignment: "start",
276
346
  width: sizes.listWidth,
277
- onRowsRendered: this.checkCategoryIdChange
278
- }));
347
+ onRowsRendered: this.onRowsRendered
348
+ })));
279
349
  }
280
350
  }]);
281
- return EmojiPickerVirtualList;
351
+ return EmojiPickerVirtualListInternal;
282
352
  }(PureComponent);
283
- _defineProperty(EmojiPickerVirtualList, "defaultProps", {
353
+ _defineProperty(EmojiPickerVirtualListInternal, "defaultProps", {
284
354
  onEmojiSelected: function onEmojiSelected() {},
285
355
  onEmojiActive: function onEmojiActive() {},
286
356
  onEmojiDelete: function onEmojiDelete() {},
@@ -288,4 +358,4 @@ _defineProperty(EmojiPickerVirtualList, "defaultProps", {
288
358
  onSearch: function onSearch() {},
289
359
  size: defaultEmojiPickerSize
290
360
  });
291
- export { EmojiPickerVirtualList as default };
361
+ export { EmojiPickerVirtualListInternal as default };
@@ -1,126 +1,73 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
10
2
  /** @jsx jsx */
11
- import React, { PureComponent } from 'react';
3
+ import React, { useLayoutEffect, useRef, useState } from 'react';
12
4
  import { jsx } from '@emotion/react';
13
5
  import TextField from '@atlaskit/textfield';
14
6
  import SearchIcon from '@atlaskit/icon/glyph/search';
15
- import { injectIntl } from 'react-intl-next';
7
+ import VisuallyHidden from '@atlaskit/visually-hidden';
8
+ import { useIntl } from 'react-intl-next';
16
9
  import { messages } from '../i18n';
17
10
  import { input, pickerSearch, searchIcon } from './styles';
11
+ import { EMOJI_SEARCH_DEBOUNCE } from '../../util/constants';
12
+ import { useDebouncedCallback } from 'use-debounce';
18
13
  export var emojiPickerSearchTestId = 'emoji-picker-serach';
19
- var EmojiPickerListSearch = /*#__PURE__*/function (_PureComponent) {
20
- _inherits(EmojiPickerListSearch, _PureComponent);
21
- var _super = _createSuper(EmojiPickerListSearch);
22
- function EmojiPickerListSearch() {
23
- var _this;
24
- _classCallCheck(this, EmojiPickerListSearch);
25
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
- args[_key] = arguments[_key];
27
- }
28
- _this = _super.call.apply(_super, [this].concat(args));
29
- _defineProperty(_assertThisInitialized(_this), "onBlur", function () {
30
- var activeElement = document.activeElement;
31
- // Input lost focus to emoji picker container (happens in IE11 when updating search results)
32
- // See FS-2111
33
- if (activeElement instanceof HTMLElement && activeElement.getAttribute('data-emoji-picker-container')) {
34
- _this.restoreInputFocus();
14
+ export var EmojiPickerListSearch = function EmojiPickerListSearch(props) {
15
+ var style = props.style,
16
+ query = props.query,
17
+ resultsCount = props.resultsCount,
18
+ onChange = props.onChange;
19
+ var textRef = useRef(null);
20
+ var _useState = useState(false),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ dirty = _useState2[0],
23
+ setDirty = _useState2[1];
24
+ var _useIntl = useIntl(),
25
+ formatMessage = _useIntl.formatMessage;
26
+
27
+ // Debounce callback
28
+ var _useDebouncedCallback = useDebouncedCallback(function (value) {
29
+ onChange(value);
30
+ setDirty(true);
31
+ },
32
+ // delay in ms
33
+ EMOJI_SEARCH_DEBOUNCE),
34
+ _useDebouncedCallback2 = _slicedToArray(_useDebouncedCallback, 1),
35
+ debouncedSearch = _useDebouncedCallback2[0];
36
+ var handleOnChange = function handleOnChange(e) {
37
+ debouncedSearch(e.target.value);
38
+ };
39
+ useLayoutEffect(function () {
40
+ requestAnimationFrame(function () {
41
+ if (textRef) {
42
+ var _textRef$current;
43
+ (_textRef$current = textRef.current) === null || _textRef$current === void 0 ? void 0 : _textRef$current.focus();
35
44
  }
36
45
  });
37
- _defineProperty(_assertThisInitialized(_this), "onChange", function (e) {
38
- _this.saveInputSelection();
39
- _this.props.onChange(e);
40
- });
41
- _defineProperty(_assertThisInitialized(_this), "focusInput", function () {
42
- if (_this.inputRef) {
43
- _this.inputRef.focus();
44
- }
45
- });
46
- _defineProperty(_assertThisInitialized(_this), "handleInputRef", function (input) {
47
- if (input) {
48
- // Defer focus so it give some time to position the popup before
49
- // setting the focus to search input.
50
- // see FS-2056
51
- _this.inputRef = input;
52
- if (typeof window === 'undefined') {
53
- return;
54
- }
55
- window.requestAnimationFrame(_this.focusInput);
56
- }
57
- });
58
- return _this;
59
- }
60
- _createClass(EmojiPickerListSearch, [{
61
- key: "saveInputSelection",
62
- value: function saveInputSelection() {
63
- this.inputSelection = undefined;
64
- if (this.inputRef) {
65
- var _this$inputRef = this.inputRef,
66
- selectionStart = _this$inputRef.selectionStart,
67
- selectionEnd = _this$inputRef.selectionEnd,
68
- selectionDirection = _this$inputRef.selectionDirection;
69
- if (selectionStart && selectionEnd && selectionDirection) {
70
- this.inputSelection = {
71
- selectionStart: selectionStart,
72
- selectionEnd: selectionEnd,
73
- selectionDirection: selectionDirection
74
- };
75
- }
76
- }
77
- }
78
- }, {
79
- key: "restoreInputFocus",
80
- value: function restoreInputFocus() {
81
- this.focusInput();
82
- if (this.inputSelection && this.inputRef && this.inputRef.setSelectionRange) {
83
- var _this$inputSelection = this.inputSelection,
84
- selectionStart = _this$inputSelection.selectionStart,
85
- selectionEnd = _this$inputSelection.selectionEnd,
86
- selectionDirection = _this$inputSelection.selectionDirection;
87
- this.inputRef.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
88
- }
89
- }
90
- }, {
91
- key: "render",
92
- value: function render() {
93
- var _this$props = this.props,
94
- style = _this$props.style,
95
- query = _this$props.query,
96
- intl = _this$props.intl;
97
- var formatMessage = intl.formatMessage;
98
- return jsx("div", {
99
- css: pickerSearch,
100
- style: style
101
- }, jsx(TextField, {
102
- "aria-label": formatMessage(messages.searchLabel),
103
- css: input,
104
- autoComplete: "off",
105
- name: "search",
106
- placeholder: "".concat(formatMessage(messages.searchPlaceholder), "..."),
107
- onChange: this.onChange,
108
- value: query || '',
109
- ref: this.handleInputRef,
110
- isCompact: true,
111
- onBlur: this.onBlur,
112
- elemBeforeInput: jsx("span", {
113
- css: searchIcon
114
- }, jsx(SearchIcon, {
115
- label: ""
116
- })),
117
- testId: emojiPickerSearchTestId
118
- }));
119
- }
120
- }]);
121
- return EmojiPickerListSearch;
122
- }(PureComponent);
123
- _defineProperty(EmojiPickerListSearch, "defaultProps", {
124
- style: {}
125
- });
126
- export default injectIntl(EmojiPickerListSearch);
46
+ }, []);
47
+ return jsx("div", {
48
+ css: pickerSearch,
49
+ style: style
50
+ }, jsx(VisuallyHidden, {
51
+ id: "emoji-search-results-status",
52
+ role: "status"
53
+ }, dirty && query === '' && formatMessage(messages.searchResultsStatusSeeAll), query !== '' && formatMessage(messages.searchResultsStatus, {
54
+ count: resultsCount
55
+ })), jsx(TextField, {
56
+ role: "searchbox",
57
+ "aria-label": formatMessage(messages.searchLabel),
58
+ css: input,
59
+ autoComplete: "off",
60
+ name: "search",
61
+ placeholder: "".concat(formatMessage(messages.searchPlaceholder), "..."),
62
+ defaultValue: query || '',
63
+ onChange: handleOnChange,
64
+ elemBeforeInput: jsx("span", {
65
+ css: searchIcon
66
+ }, jsx(SearchIcon, {
67
+ label: ""
68
+ })),
69
+ testId: emojiPickerSearchTestId,
70
+ ref: textRef,
71
+ isCompact: true
72
+ }));
73
+ };
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
2
3
  import _inherits from "@babel/runtime/helpers/inherits";
3
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
@@ -27,8 +28,10 @@ export var EmojisRowItem = /*#__PURE__*/function (_AbstractItem) {
27
28
  var _this;
28
29
  _classCallCheck(this, EmojisRowItem);
29
30
  _this = _super.call(this, props, sizes.emojiRowHeight);
30
- _defineProperty(_assertThisInitialized(_this), "renderItem", function () {
31
- return jsx(EmojiPickerEmojiRow, _this.props);
31
+ _defineProperty(_assertThisInitialized(_this), "renderItem", function (context) {
32
+ return jsx(EmojiPickerEmojiRow, _extends({}, _this.props, {
33
+ virtualItemContext: context
34
+ }));
32
35
  });
33
36
  return _this;
34
37
  }