@atlaskit/emoji 64.7.0 → 65.1.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 (122) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/cjs/api/EmojiResource.js +250 -87
  3. package/dist/cjs/api/media/SiteEmojiResource.js +4 -2
  4. package/dist/cjs/api/media/TokenManager.js +13 -12
  5. package/dist/cjs/components/common/CachingEmoji.js +21 -3
  6. package/dist/cjs/components/common/Emoji.js +57 -36
  7. package/dist/cjs/components/common/EmojiImage.js +99 -0
  8. package/dist/cjs/components/common/EmojiPlaceholder.js +7 -5
  9. package/dist/cjs/components/common/RecordSelectionDefault.js +13 -1
  10. package/dist/cjs/components/common/ResourcedEmoji.js +14 -4
  11. package/dist/cjs/components/common/ResourcedEmojiComponent.js +173 -156
  12. package/dist/cjs/components/common/UfoErrorBoundary.js +30 -4
  13. package/dist/cjs/components/common/UploadEmoji.js +8 -3
  14. package/dist/cjs/components/common/styles.js +26 -9
  15. package/dist/cjs/components/picker/EmojiPickerComponent.js +27 -9
  16. package/dist/cjs/components/picker/EmojiPickerFooter.js +2 -0
  17. package/dist/cjs/components/picker/styles.js +16 -13
  18. package/dist/cjs/components/typeahead/EmojiTypeAheadComponent.js +18 -2
  19. package/dist/cjs/components/uploader/EmojiUploadComponent.js +7 -2
  20. package/dist/cjs/context/EmojiContextProvider.js +33 -0
  21. package/dist/cjs/hooks/index.js +16 -0
  22. package/dist/cjs/index.js +20 -0
  23. package/dist/cjs/types.js +3 -0
  24. package/dist/cjs/util/analytics/samplingUfo.js +13 -3
  25. package/dist/cjs/util/analytics/ufoExperiences.js +22 -4
  26. package/dist/cjs/util/analytics/useSampledUFOComponentExperience.js +2 -1
  27. package/dist/cjs/util/browser-support.js +1 -1
  28. package/dist/cjs/util/constants.js +6 -5
  29. package/dist/cjs/util/useInView.js +23 -0
  30. package/dist/cjs/version.json +1 -1
  31. package/dist/es2019/api/EmojiResource.js +117 -37
  32. package/dist/es2019/api/media/SiteEmojiResource.js +2 -2
  33. package/dist/es2019/api/media/TokenManager.js +12 -12
  34. package/dist/es2019/components/common/CachingEmoji.js +20 -3
  35. package/dist/es2019/components/common/Emoji.js +53 -34
  36. package/dist/es2019/components/common/EmojiImage.js +74 -0
  37. package/dist/es2019/components/common/EmojiPlaceholder.js +7 -5
  38. package/dist/es2019/components/common/RecordSelectionDefault.js +13 -1
  39. package/dist/es2019/components/common/ResourcedEmoji.js +15 -5
  40. package/dist/es2019/components/common/ResourcedEmojiComponent.js +136 -105
  41. package/dist/es2019/components/common/UfoErrorBoundary.js +14 -2
  42. package/dist/es2019/components/common/UploadEmoji.js +8 -3
  43. package/dist/es2019/components/common/styles.js +30 -9
  44. package/dist/es2019/components/picker/EmojiPickerComponent.js +27 -8
  45. package/dist/es2019/components/picker/EmojiPickerFooter.js +2 -0
  46. package/dist/es2019/components/picker/styles.js +16 -14
  47. package/dist/es2019/components/typeahead/EmojiTypeAheadComponent.js +18 -2
  48. package/dist/es2019/components/uploader/EmojiUploadComponent.js +7 -2
  49. package/dist/es2019/context/EmojiContextProvider.js +9 -1
  50. package/dist/es2019/hooks/index.js +8 -0
  51. package/dist/es2019/index.js +5 -4
  52. package/dist/es2019/types.js +3 -0
  53. package/dist/es2019/util/analytics/samplingUfo.js +11 -1
  54. package/dist/es2019/util/analytics/ufoExperiences.js +12 -2
  55. package/dist/es2019/util/analytics/useSampledUFOComponentExperience.js +2 -1
  56. package/dist/es2019/util/browser-support.js +1 -1
  57. package/dist/es2019/util/constants.js +3 -2
  58. package/dist/es2019/util/useInView.js +12 -0
  59. package/dist/es2019/version.json +1 -1
  60. package/dist/esm/api/EmojiResource.js +257 -89
  61. package/dist/esm/api/media/SiteEmojiResource.js +5 -3
  62. package/dist/esm/api/media/TokenManager.js +13 -12
  63. package/dist/esm/components/common/CachingEmoji.js +20 -3
  64. package/dist/esm/components/common/Emoji.js +59 -38
  65. package/dist/esm/components/common/EmojiImage.js +84 -0
  66. package/dist/esm/components/common/EmojiPlaceholder.js +8 -5
  67. package/dist/esm/components/common/RecordSelectionDefault.js +13 -1
  68. package/dist/esm/components/common/ResourcedEmoji.js +15 -5
  69. package/dist/esm/components/common/ResourcedEmojiComponent.js +167 -156
  70. package/dist/esm/components/common/UfoErrorBoundary.js +30 -4
  71. package/dist/esm/components/common/UploadEmoji.js +8 -3
  72. package/dist/esm/components/common/styles.js +25 -10
  73. package/dist/esm/components/picker/EmojiPickerComponent.js +27 -8
  74. package/dist/esm/components/picker/EmojiPickerFooter.js +2 -0
  75. package/dist/esm/components/picker/styles.js +16 -14
  76. package/dist/esm/components/typeahead/EmojiTypeAheadComponent.js +18 -2
  77. package/dist/esm/components/uploader/EmojiUploadComponent.js +7 -2
  78. package/dist/esm/context/EmojiContextProvider.js +30 -1
  79. package/dist/esm/hooks/index.js +8 -0
  80. package/dist/esm/index.js +5 -4
  81. package/dist/esm/types.js +3 -0
  82. package/dist/esm/util/analytics/samplingUfo.js +13 -2
  83. package/dist/esm/util/analytics/ufoExperiences.js +14 -2
  84. package/dist/esm/util/analytics/useSampledUFOComponentExperience.js +2 -1
  85. package/dist/esm/util/browser-support.js +1 -1
  86. package/dist/esm/util/constants.js +3 -2
  87. package/dist/esm/util/useInView.js +12 -0
  88. package/dist/esm/version.json +1 -1
  89. package/dist/types/api/EmojiResource.d.ts +19 -2
  90. package/dist/types/api/EmojiUtils.d.ts +7 -1
  91. package/dist/types/api/media/SiteEmojiResource.d.ts +1 -1
  92. package/dist/types/api/media/TokenManager.d.ts +1 -0
  93. package/dist/types/components/common/Emoji.d.ts +0 -1
  94. package/dist/types/components/common/EmojiImage.d.ts +13 -0
  95. package/dist/types/components/common/EmojiPlaceholder.d.ts +1 -0
  96. package/dist/types/components/common/LoadingEmojiComponent.d.ts +7 -4
  97. package/dist/types/components/common/ResourcedEmoji.d.ts +3 -3
  98. package/dist/types/components/common/ResourcedEmojiComponent.d.ts +41 -20
  99. package/dist/types/components/common/UfoErrorBoundary.d.ts +2 -2
  100. package/dist/types/components/common/UploadEmoji.d.ts +1 -1
  101. package/dist/types/components/common/styles.d.ts +1 -0
  102. package/dist/types/components/picker/EmojiPicker.d.ts +9 -0
  103. package/dist/types/components/picker/EmojiPickerComponent.d.ts +14 -0
  104. package/dist/types/components/picker/EmojiPickerFooter.d.ts +1 -0
  105. package/dist/types/components/picker/styles.d.ts +1 -1
  106. package/dist/types/components/typeahead/EmojiTypeAheadComponent.d.ts +18 -0
  107. package/dist/types/hooks/index.d.ts +1 -0
  108. package/dist/types/index.d.ts +5 -4
  109. package/dist/types/types.d.ts +14 -2
  110. package/dist/types/util/analytics/index.d.ts +1 -1
  111. package/dist/types/util/analytics/samplingUfo.d.ts +6 -6
  112. package/dist/types/util/analytics/ufoExperiences.d.ts +5 -2
  113. package/dist/types/util/constants.d.ts +2 -1
  114. package/dist/types/util/useInView.d.ts +4 -0
  115. package/docs/0-intro.tsx +35 -27
  116. package/docs/1-resourced-emoji.tsx +74 -0
  117. package/docs/2-emoji-picker.tsx +56 -0
  118. package/docs/3-typeahead.tsx +20 -0
  119. package/docs/4-emoji-provider.tsx +98 -0
  120. package/local-config-example.ts +22 -1
  121. package/package.json +4 -4
  122. package/report.api.md +1287 -0
package/report.api.md ADDED
@@ -0,0 +1,1287 @@
1
+ ## API Report File for "@atlaskit/emoji"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+ /// <reference types="react" />
7
+
8
+ import { AbstractResource } from '@atlaskit/util-service-support';
9
+ import { Component } from 'react';
10
+ import { ComponentClass } from 'react';
11
+ import { ConcurrentExperience } from '@atlaskit/ufo';
12
+ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
13
+ import { ForwardRefExoticComponent } from 'react';
14
+ import { Provider } from '@atlaskit/util-service-support/types';
15
+ import { PureComponent } from 'react';
16
+ import { default as React_2 } from 'react';
17
+ import { RefAttributes } from 'react';
18
+ import { ServiceConfig } from '@atlaskit/util-service-support';
19
+ import { SyntheticEvent } from 'react';
20
+ import { UFOExperience } from '@atlaskit/ufo';
21
+ import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
22
+
23
+ export { AbstractResource };
24
+
25
+ export declare interface AltRepresentations {
26
+ [key: string]: EmojiServiceRepresentation;
27
+ }
28
+
29
+ declare interface BaseResourcedEmojiProps {
30
+ emojiId: EmojiId;
31
+ showTooltip?: boolean;
32
+ fitToHeight?: number;
33
+ }
34
+
35
+ export declare interface CategoryDescription {
36
+ id: string;
37
+ name: keyof typeof messages;
38
+ icon: any;
39
+ order: number;
40
+ }
41
+
42
+ export declare type CategoryId =
43
+ | 'FREQUENT'
44
+ | 'PEOPLE'
45
+ | 'NATURE'
46
+ | 'FOODS'
47
+ | 'ACTIVITY'
48
+ | 'PLACES'
49
+ | 'OBJECTS'
50
+ | 'SYMBOLS'
51
+ | 'FLAGS'
52
+ | 'ATLASSIAN'
53
+ | 'CUSTOM';
54
+
55
+ export declare const customCategory = 'CUSTOM';
56
+
57
+ export declare const defaultEmojiHeight = 20;
58
+
59
+ /**
60
+ * Denormalised an emoji response (emojis + sprite references) into an array of
61
+ * emoji with local sprite definitions.
62
+ */
63
+ export declare const denormaliseEmojiServiceResponse: (
64
+ emojiData: EmojiServiceResponse,
65
+ ) => EmojiResponse;
66
+
67
+ /**
68
+ * A queue which will limit the number of duplicates of type T that it holds. When the duplicate limit is
69
+ * reached the earliest inserted duplicate (the "original") is removed to make room for the new insertion.
70
+ */
71
+ declare class DuplicateLimitedQueue<T> {
72
+ private maximumSize;
73
+ private perItemSize;
74
+ private items;
75
+ private itemCountMap;
76
+ /**
77
+ * An array derived from items and itemCountMap which holds each item once and is ordered by
78
+ * how often an item is duplicated in the items array.
79
+ */
80
+ private itemsOrderedByFrequency;
81
+ /**
82
+ * Construct a new DuplicateLimitedQueue.
83
+ *
84
+ * @param options the options for this queue.
85
+ */
86
+ constructor(options: QueueOptions);
87
+ /**
88
+ * @param item the item to add to the queue.
89
+ */
90
+ enqueue(item: T): void;
91
+ /**
92
+ * Return the items in the queue, ordered by how often they are duplicated. The items with the
93
+ * most duplicates come first in the returned Array.
94
+ *
95
+ * If there are no items in the queue then an empty Array will be returned.
96
+ */
97
+ getItemsOrderedByDuplicateCount(): Array<T>;
98
+ /**
99
+ * Exposed for storybook/testing purposes only. Clear the contents of the queue.
100
+ */
101
+ clear(): void;
102
+ /**
103
+ * A more efficient mechanism for adding multiple items. Ordering is only performed once all
104
+ * the items have been added.
105
+ *
106
+ * @param items the items to be enqueued, which happens in their presented order.
107
+ */
108
+ protected bulkEnqueue(items: T[]): void;
109
+ /**
110
+ * Return the items currently stored in the queue.
111
+ */
112
+ protected getItems(): T[];
113
+ private createEmptyState;
114
+ /**
115
+ * Enqueue the supplied item, keeping consistency with the limits configured. However no ordering is
116
+ * performed by this enqueuing. You must trigger that manually if required.
117
+ *
118
+ * @param item the item to be queued
119
+ */
120
+ private enqueueWithoutOrdering;
121
+ /**
122
+ * Get an array of items from the queue ordered by how often they are duplicated in the queue.
123
+ */
124
+ private orderItemsByFrequency;
125
+ private decrementCount;
126
+ /**
127
+ * Walk the list of items and remove the first occurrence of the matching item.
128
+ *
129
+ * @param item the item to be removed.
130
+ */
131
+ private removeFirstOccurrence;
132
+ /**
133
+ * Remove the first item from the queue and update the itemCountMap accordingly.
134
+ * @return the item add the front of the queue or undefined if the queue is empty
135
+ */
136
+ private remove;
137
+ /**
138
+ * Add the supplied item to the end of the queue and update the itemCountMap accordingly.
139
+ * @param item the item to be added to the queue
140
+ */
141
+ private add;
142
+ }
143
+
144
+ export declare const Emoji: (props: Props) => JSX.Element;
145
+
146
+ export declare interface EmojiDescription extends EmojiId {
147
+ name?: string;
148
+ order?: number;
149
+ type: string;
150
+ category: string;
151
+ ascii?: string[];
152
+ createdDate?: string;
153
+ creatorUserId?: string;
154
+ representation: EmojiRepresentation;
155
+ altRepresentation?: EmojiRepresentation;
156
+ searchable: boolean;
157
+ }
158
+
159
+ export declare interface EmojiDescriptionWithVariations
160
+ extends EmojiDescription {
161
+ skinVariations?: EmojiDescription[];
162
+ }
163
+
164
+ /**
165
+ * Minimum information to defined an emoji is the shortName.
166
+ * In order to uniquely define an emoji, the id should be included, and is
167
+ * used in preference to shortName if provided, and has a matching emoji.
168
+ * If not emoji can be found by id (e.g. a custom emoji has been removed),
169
+ * fallback behaviour will be to attempt to find a matching emoji by shortName.
170
+ */
171
+ export declare interface EmojiId {
172
+ shortName: string;
173
+ id?: string;
174
+ fallback?: string;
175
+ }
176
+
177
+ export declare const emojiImage = 'emoji-common-emoji-image';
178
+
179
+ export declare interface EmojiImageRepresentation {
180
+ height: number;
181
+ width: number;
182
+ }
183
+
184
+ /**
185
+ * Emoji providers should return JSON in the format defined by EmojiServiceResponse.
186
+ */
187
+ export declare class EmojiLoader {
188
+ private config;
189
+ constructor(config: EmojiLoaderConfig);
190
+ /**
191
+ * Returns a promise with an array of Emoji from all providers.
192
+ */
193
+ loadEmoji(): Promise<EmojiResponse>;
194
+ }
195
+
196
+ declare interface EmojiLoaderConfig extends ServiceConfig {
197
+ getRatio?: () => number;
198
+ }
199
+
200
+ export declare interface EmojiMeta {
201
+ spriteSheets?: SpriteSheets;
202
+ mediaApiToken?: MediaApiToken;
203
+ }
204
+
205
+ export declare const emojiNode = 'emoji-common-node';
206
+
207
+ declare const EmojiPicker: ForwardRefExoticComponent<
208
+ Omit<Props_3 & WithAnalyticsEventsProps, keyof WithAnalyticsEventsProps> &
209
+ RefAttributes<any>
210
+ >;
211
+ export { EmojiPicker };
212
+ export default EmojiPicker;
213
+
214
+ export declare const emojiPickerHeight = 295;
215
+
216
+ export declare const emojiPickerWidth = 350;
217
+
218
+ export declare const EmojiPlaceholder: (props: Props_2) => JSX.Element;
219
+
220
+ declare interface EmojiProgessCallback {
221
+ (progress: EmojiProgress): void;
222
+ }
223
+
224
+ declare interface EmojiProgress {
225
+ readonly percent: number;
226
+ }
227
+
228
+ export declare interface EmojiProvider
229
+ extends Provider<string, EmojiSearchResult, any, undefined, SearchOptions> {
230
+ /**
231
+ * Returns an immutable copy of EmojiDescription where mediaPath has token and client appended to url
232
+ *
233
+ * Will allow emoji to render site emojis without needing to fail first
234
+ */
235
+ getMediaEmojiDescriptionURLWithInlineToken(
236
+ emoji: EmojiDescription,
237
+ ): Promise<EmojiDescription>;
238
+ /**
239
+ * Returns the first matching emoji matching the shortName, or null if none found.
240
+ *
241
+ * Will load media api images before returning.
242
+ */
243
+ findByShortName(
244
+ shortName: string,
245
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
246
+ /**
247
+ * Returns the first matching emoji matching the emojiId.id.
248
+ *
249
+ * If not found or emojiId.id is undefined, fallback to a search by shortName.
250
+ *
251
+ * Will load media api images before returning.
252
+ */
253
+ findByEmojiId(
254
+ emojiId: EmojiId,
255
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
256
+ /**
257
+ * Return the emoji that matches the supplied id or undefined. As with findByEmojiId, this call should load
258
+ * the media api images before returning.
259
+ */
260
+ findById(
261
+ id: string,
262
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
263
+ /**
264
+ * Finds emojis belonging to specified category.
265
+ *
266
+ * Does not automatically load Media API images.
267
+ */
268
+ findInCategory(categoryId: string): Promise<EmojiDescription[]>;
269
+ /**
270
+ * Returns a map matching ascii representations to their corresponding EmojiDescription.
271
+ */
272
+ getAsciiMap(): Promise<Map<string, EmojiDescription>>;
273
+ /**
274
+ * Returns, in a Promise, an array of the most frequently used emoji, ordered from most frequent to least frequent.
275
+ * If there is no frequently used data then an empty array should be returned.
276
+ *
277
+ * @param options supply options to be applied to the request.
278
+ */
279
+ getFrequentlyUsed(options?: SearchOptions): Promise<EmojiDescription[]>;
280
+ /**
281
+ * Records an emoji selection, for example for using in tracking recent emoji.
282
+ * If no recordConfig is configured then a resolved promise should be returned
283
+ *
284
+ * Optional.
285
+ */
286
+ recordSelection?(emoji: EmojiDescription): Promise<any>;
287
+ /**
288
+ * Deletes the given emoji from the site emoji service
289
+ * No changes are made if it is not a media emoji, no siteEmojiResource has been initialised
290
+ * or the user is not authorised.
291
+ * It should also be removed from the EmojiResource so it cannot be returned via search
292
+ *
293
+ * Optional.
294
+ *
295
+ * @return a boolean indicating whether the delete was successful
296
+ */
297
+ deleteSiteEmoji(emoji: EmojiDescription): Promise<boolean>;
298
+ /**
299
+ * Load media emoji that may require authentication to download, producing
300
+ * a new EmojiDescription to be used for rendering, if necessary.
301
+ *
302
+ * Future results may be returned from a cache.
303
+ *
304
+ * Acts as a no-op if not a media emoji.
305
+ *
306
+ * Downloads and caches the altRepresentation image if useAlt is passed in
307
+ *
308
+ * @return an OptionalEmojiDescription or a promise for one, may be the same as the input,
309
+ * or updated with a new url to cached image data. Will return the original EmojiDescription
310
+ * if not a custom emoji.
311
+ */
312
+ loadMediaEmoji(
313
+ emoji: EmojiDescription,
314
+ useAlt?: boolean,
315
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
316
+ /**
317
+ * Indicates if media emoji should be rendered optimistically,
318
+ * i.e. assume the url can be rendered directly from the URL, and
319
+ * only explicitly loaded via loadEmojiImageData if it fails to load.
320
+ *
321
+ * If useAlt is provided, the altRepresentation image URL is used
322
+ */
323
+ optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
324
+ /**
325
+ * Used by the picker and typeahead to obtain a skin tone preference
326
+ * if the user has previously selected one via the Tone Selector
327
+ */
328
+ getSelectedTone(): ToneSelection;
329
+ /**
330
+ * Used by Tone Selector to indicate to the provider that the user
331
+ * has selected a skin tone preference that should be remembered
332
+ */
333
+ setSelectedTone(tone: ToneSelection): void;
334
+ /**
335
+ * Returns a list of all the non-standard categories with emojis in the EmojiRepository
336
+ * e.g. 'FREQUENT', 'ATLASSIAN' and 'CUSTOM'
337
+ */
338
+ calculateDynamicCategories?(): Promise<string[]>;
339
+ /**
340
+ * Returns the logged user passed by the Product
341
+ */
342
+ getCurrentUser(): OptionalUser;
343
+ }
344
+
345
+ export declare class EmojiRepository {
346
+ private emojis;
347
+ private fullSearch;
348
+ private shortNameMap;
349
+ private idMap;
350
+ private asciiMap;
351
+ private dynamicCategoryList;
352
+ private static readonly defaultEmojiWeight;
353
+ protected usageTracker: UsageFrequencyTracker;
354
+ constructor(emojis: EmojiDescription[], usageTracker?: UsageFrequencyTracker);
355
+ /**
356
+ * Returns all available (and searchable) emoji in some default order.
357
+ */
358
+ all(): EmojiSearchResult;
359
+ /**
360
+ * Text search of emoji shortName and name field for suitable matches.
361
+ *
362
+ * Returns an array of all (searchable) emoji if query is empty or null, otherwise returns matching emoji.
363
+ *
364
+ * You can change how the results are sorted by specifying a custom EmojiComparator in the SearchOptions. If
365
+ * you don't want any sorting you can also disable via the SearchOptions (this might be a useful optimisation).
366
+ * If no sort is specified in SearchOptions then a default sorting it applied based on the query.
367
+ */
368
+ search(query?: string, options?: SearchOptions): EmojiSearchResult;
369
+ /**
370
+ * Returns all emoji with matching shortName
371
+ */
372
+ findAllMatchingShortName(shortName: string): EmojiDescription[];
373
+ /**
374
+ * Returns the first matching emoji matching the shortName, or null if none found.
375
+ */
376
+ findByShortName(shortName: string): OptionalEmojiDescription;
377
+ /**
378
+ * Returns the first matching emoji matching the id, or null if none found.
379
+ */
380
+ findById(id: string): OptionalEmojiDescription;
381
+ findByAsciiRepresentation(asciiEmoji: string): OptionalEmojiDescription;
382
+ findInCategory(categoryId: CategoryId): EmojiDescription[];
383
+ addUnknownEmoji(emoji: EmojiDescription): void;
384
+ getAsciiMap(): Map<string, EmojiDescription>;
385
+ /**
386
+ * Return the most frequently used emoji, ordered from most frequent to least frequent. Return an empty array if
387
+ * there are none.
388
+ *
389
+ * @param options optional settings to be applied to the set of frequently used emoji
390
+ */
391
+ getFrequentlyUsed(options?: SearchOptions): EmojiDescription[];
392
+ getDynamicCategoryList(): CategoryId[];
393
+ /**
394
+ * Call this on emoji usage to allow the EmojiRepository to track the usage of emoji (which could be useful
395
+ * in sorting, etc).
396
+ *
397
+ * @param emoji the emoji that was just used
398
+ */
399
+ used(emoji: EmojiDescription): void;
400
+ delete(emoji: EmojiDescription): void;
401
+ private withAsciiMatch;
402
+ private applySearchOptions;
403
+ private initMembers;
404
+ /**
405
+ * Optimisation to initialise all map member variables in single loop over emojis
406
+ */
407
+ private initRepositoryMetadata;
408
+ private initSearchIndex;
409
+ private getAllSearchableEmojis;
410
+ private addToMaps;
411
+ private addToDynamicCategories;
412
+ }
413
+
414
+ export declare type EmojiRepresentation =
415
+ | SpriteRepresentation
416
+ | ImageRepresentation
417
+ | MediaApiRepresentation
418
+ | undefined;
419
+
420
+ export declare class EmojiResource
421
+ extends EmojiResource_2
422
+ implements UploadingEmojiProvider {
423
+ protected allowUpload: boolean;
424
+ constructor(config: EmojiResourceConfig);
425
+ isUploadSupported(): Promise<boolean>;
426
+ uploadCustomEmoji(upload: EmojiUpload): Promise<EmojiDescription>;
427
+ prepareForUpload(): Promise<void>;
428
+ }
429
+
430
+ declare class EmojiResource_2
431
+ extends AbstractResource<
432
+ string,
433
+ EmojiSearchResult,
434
+ any,
435
+ undefined,
436
+ SearchOptions
437
+ >
438
+ implements EmojiProvider {
439
+ protected recordConfig?: ServiceConfig;
440
+ protected emojiRepository?: EmojiRepository;
441
+ protected lastQuery?: LastQuery;
442
+ protected activeLoaders: number;
443
+ protected retries: Map<Retry<any>, ResolveReject<any>>;
444
+ protected siteEmojiResource?: SiteEmojiResource;
445
+ protected selectedTone: ToneSelection;
446
+ protected currentUser?: User;
447
+ constructor(config: EmojiResourceConfig);
448
+ private getProviderType;
449
+ protected initEmojiRepository(emojiResponses: EmojiResponse[]): void;
450
+ protected initSiteEmojiResource(
451
+ emojiResponse: EmojiResponse,
452
+ provider: ServiceConfig,
453
+ ): Promise<void>;
454
+ private performRetries;
455
+ private loadStoredTone;
456
+ protected refreshLastFilter(): void;
457
+ protected isLoaded: () => false | EmojiRepository | undefined;
458
+ protected retryIfLoading<T>(retry: Retry<T>, defaultResponse: T): Promise<T>;
459
+ protected notifyResult(result: EmojiSearchResult): void;
460
+ /**
461
+ * Returns the EmojiDescription with a valid media path that includes query token and client attributes to access the emoji media inline.
462
+ */
463
+ getMediaEmojiDescriptionURLWithInlineToken(
464
+ emoji: EmojiDescription,
465
+ ): Promise<EmojiDescription>;
466
+ loadMediaEmoji(
467
+ emoji: EmojiDescription,
468
+ useAlt?: boolean,
469
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
470
+ optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
471
+ filter(query?: string, options?: SearchOptions): void;
472
+ findByShortName(
473
+ shortName: string,
474
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
475
+ findByEmojiId(
476
+ emojiId: EmojiId,
477
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
478
+ findById(
479
+ id: string,
480
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
481
+ findInCategory(categoryId: CategoryId): Promise<EmojiDescription[]>;
482
+ getAsciiMap(): Promise<Map<string, EmojiDescription>>;
483
+ getFrequentlyUsed(options?: SearchOptions): Promise<EmojiDescription[]>;
484
+ /**
485
+ * Record the selection of an emoji to a remote service if 'recordConfig' has been supplied.
486
+ * Regardless of the recordConfig, emoji selections will always be recorded on the EmojiRepository
487
+ * for the purposes of tracking the frequency of use.
488
+ *
489
+ * @param emoji The full description of the emoji to record usage for.
490
+ */
491
+ recordSelection(emoji: EmojiDescription): Promise<any>;
492
+ deleteSiteEmoji(emoji: EmojiDescription): Promise<boolean>;
493
+ getSelectedTone(): ToneSelection;
494
+ setSelectedTone(tone: ToneSelection): void;
495
+ calculateDynamicCategories(): Promise<CategoryId[]>;
496
+ getCurrentUser(): OptionalUser;
497
+ protected addUnknownEmoji(emoji: EmojiDescription): void;
498
+ }
499
+
500
+ export declare interface EmojiResourceConfig {
501
+ /**
502
+ * The service configuration for remotely recording emoji selections.
503
+ * A post will be performed to this URL with the EmojiId as the body.
504
+ */
505
+ recordConfig?: ServiceConfig;
506
+ /**
507
+ * This defines the different providers. Later providers will override earlier
508
+ * providers when performing shortName based look up.
509
+ */
510
+ providers: ServiceConfig[];
511
+ /**
512
+ * Must be set to true to enable upload support in the emoji components.
513
+ *
514
+ * Can be used for the restriction of the upload UI based on permissions, or feature flags.
515
+ *
516
+ * Note this also requires that other conditions are met (for example, one of the providers
517
+ * must support upload for the UploadingEmojiResource implementation of UploadingEmojiProvider).
518
+ */
519
+ allowUpload?: boolean;
520
+ /**
521
+ * Logged user in the Product.
522
+ */
523
+ currentUser?: User;
524
+ }
525
+
526
+ export declare interface EmojiResponse {
527
+ emojis: EmojiDescriptionWithVariations[];
528
+ mediaApiToken?: MediaApiToken;
529
+ }
530
+
531
+ export declare interface EmojiSearchResult {
532
+ emojis: EmojiDescription[];
533
+ query?: string;
534
+ }
535
+
536
+ export declare interface EmojiServiceDescription {
537
+ id: string;
538
+ shortName: string;
539
+ name?: string;
540
+ order?: number;
541
+ fallback?: string;
542
+ ascii?: string[];
543
+ createdDate?: string;
544
+ creatorUserId?: string;
545
+ type: string;
546
+ category: string;
547
+ representation: EmojiServiceRepresentation;
548
+ altRepresentations?: AltRepresentations;
549
+ searchable: boolean;
550
+ }
551
+
552
+ export declare interface EmojiServiceDescriptionWithVariations
553
+ extends EmojiServiceDescription {
554
+ skinVariations?: EmojiServiceDescription[];
555
+ }
556
+
557
+ export declare type EmojiServiceRepresentation =
558
+ | SpriteServiceRepresentation
559
+ | ImageRepresentation;
560
+
561
+ /**
562
+ * The expected response from an Emoji service.
563
+ */
564
+ export declare interface EmojiServiceResponse {
565
+ emojis: EmojiServiceDescriptionWithVariations[];
566
+ meta?: EmojiMeta;
567
+ }
568
+
569
+ export declare const emojiSprite = 'emoji-common-emoji-sprite';
570
+
571
+ export declare class EmojiTypeAhead extends LoadingEmojiComponent<
572
+ Props_7,
573
+ State
574
+ > {
575
+ static AsyncLoadedComponent?: ComponentClass<Props_8>;
576
+ state: {
577
+ asyncLoadedComponent: React_2.ComponentClass<Props_8, any> | undefined;
578
+ };
579
+ constructor(props: Props_7);
580
+ selectNext: () => void;
581
+ selectPrevious: () => void;
582
+ chooseCurrentSelection: () => void;
583
+ count: () => number;
584
+ asyncLoadComponent(): void;
585
+ renderLoaded(
586
+ loadedEmojiProvider: EmojiProvider,
587
+ EmojiTypeAheadComponent: ComponentClass<Props_8>,
588
+ ): JSX.Element | null;
589
+ }
590
+
591
+ declare interface EmojiTypeAheadBaseProps {
592
+ onSelection?: OnEmojiEvent;
593
+ query?: string;
594
+ listLimit?: number;
595
+ onOpen?: OnLifecycle;
596
+ onClose?: OnLifecycle;
597
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
598
+ }
599
+
600
+ export declare class EmojiTypeAheadItem extends PureComponent<Props_11, {}> {
601
+ onEmojiSelected: React_2.MouseEventHandler<HTMLDivElement>;
602
+ onEmojiMenuItemMouseMove: React_2.MouseEventHandler<HTMLDivElement>;
603
+ render(): JSX.Element;
604
+ }
605
+
606
+ export declare interface EmojiUpload {
607
+ name: string;
608
+ shortName: string;
609
+ filename: string;
610
+ dataURL: string;
611
+ width: number;
612
+ height: number;
613
+ }
614
+
615
+ export declare type EmojiUploader = EmojiUploaderInternal;
616
+
617
+ export declare const EmojiUploader: React_2.ForwardRefExoticComponent<
618
+ Omit<Props_5, keyof WithAnalyticsEventsProps> & React_2.RefAttributes<any>
619
+ >;
620
+
621
+ declare class EmojiUploaderInternal extends LoadingEmojiComponent<
622
+ Props_5,
623
+ State
624
+ > {
625
+ static AsyncLoadedComponent?: ComponentClass<Props_6>;
626
+ state: {
627
+ asyncLoadedComponent: React_2.ComponentClass<Props_6, any> | undefined;
628
+ };
629
+ constructor(props: Props_5);
630
+ asyncLoadComponent(): void;
631
+ renderLoaded(
632
+ loadedEmojiProvider: EmojiProvider,
633
+ EmojiUploadComponent: ComponentClass<Props_6>,
634
+ ): JSX.Element;
635
+ }
636
+
637
+ /**
638
+ * Describes an emoji which is a variant of some base emoji. This is used when you want to promote the
639
+ * skinVariations in an EmojiDescriptionWithVariations to represent them along side their base representations.
640
+ */
641
+ export declare interface EmojiVariationDescription extends EmojiDescription {
642
+ /** The id of the 'non-variant version of the emoji */
643
+ baseId: string;
644
+ }
645
+
646
+ export declare interface ImageRepresentation extends EmojiImageRepresentation {
647
+ imagePath: string;
648
+ }
649
+
650
+ declare interface LastQuery {
651
+ query?: string;
652
+ options?: SearchOptions;
653
+ }
654
+
655
+ /**
656
+ * A base class for components that don't want to start rendering
657
+ * until the EmojiProvider is resolved.
658
+ * Notes: super.componentDidMount and super.componentWillUnmount will need to be
659
+ * called explicitly if they are overridden on the child class.
660
+ */
661
+ declare abstract class LoadingEmojiComponent<
662
+ P extends Props_4,
663
+ S extends State
664
+ > extends Component<P, S> {
665
+ private isUnmounted;
666
+ constructor(props: P, state: S);
667
+ componentDidMount(): void;
668
+ UNSAFE_componentWillReceiveProps(nextProps: Readonly<P>): void;
669
+ componentWillUnmount(): void;
670
+ private loadEmojiProvider;
671
+ private loaded;
672
+ abstract asyncLoadComponent(): void;
673
+ protected setAsyncState(asyncLoadedComponent: ComponentClass<any>): void;
674
+ renderLoading(): JSX.Element | null;
675
+ abstract renderLoaded(
676
+ loadedEmojiProvider: EmojiProvider,
677
+ asyncLoadedComponent: ComponentClass<any>,
678
+ ): JSX.Element | null;
679
+ render(): JSX.Element | null;
680
+ }
681
+
682
+ export declare interface MediaApiRepresentation
683
+ extends EmojiImageRepresentation {
684
+ mediaPath: string;
685
+ }
686
+
687
+ /**
688
+ * An access token for emoji stored in the MediaApi
689
+ * (indicated by urls beginning with the url of the token.)
690
+ */
691
+ export declare interface MediaApiToken {
692
+ url: string;
693
+ clientId: string;
694
+ jwt: string;
695
+ collectionName: string;
696
+ expiresAt: number;
697
+ }
698
+
699
+ export declare type Message = React.ReactNode;
700
+
701
+ declare const messages: {
702
+ deleteEmojiTitle: {
703
+ id: string;
704
+ defaultMessage: string;
705
+ description: string;
706
+ };
707
+ deleteEmojiDescription: {
708
+ id: string;
709
+ defaultMessage: string;
710
+ description: string;
711
+ };
712
+ deleteEmojiLabel: {
713
+ id: string;
714
+ defaultMessage: string;
715
+ description: string;
716
+ };
717
+ addCustomEmojiLabel: {
718
+ id: string;
719
+ defaultMessage: string;
720
+ description: string;
721
+ };
722
+ emojiPlaceholder: {
723
+ id: string;
724
+ defaultMessage: string;
725
+ description: string;
726
+ };
727
+ emojiNameAriaLabel: {
728
+ id: string;
729
+ defaultMessage: string;
730
+ description: string;
731
+ };
732
+ emojiChooseFileTitle: {
733
+ id: string;
734
+ defaultMessage: string;
735
+ description: string;
736
+ };
737
+ emojiChooseFileScreenReaderDescription: {
738
+ id: string;
739
+ defaultMessage: string;
740
+ description: string;
741
+ };
742
+ emojiSelectSkinToneButtonAriaLabelText: {
743
+ id: string;
744
+ defaultMessage: string;
745
+ description: string;
746
+ };
747
+ emojiImageRequirements: {
748
+ id: string;
749
+ defaultMessage: string;
750
+ description: string;
751
+ };
752
+ emojiPreviewTitle: {
753
+ id: string;
754
+ defaultMessage: string;
755
+ description: string;
756
+ };
757
+ emojiPreview: {
758
+ id: string;
759
+ defaultMessage: string;
760
+ description: string;
761
+ };
762
+ addEmojiLabel: {
763
+ id: string;
764
+ defaultMessage: string;
765
+ description: string;
766
+ };
767
+ retryLabel: {
768
+ id: string;
769
+ defaultMessage: string;
770
+ description: string;
771
+ };
772
+ cancelLabel: {
773
+ id: string;
774
+ defaultMessage: string;
775
+ description: string;
776
+ };
777
+ searchPlaceholder: {
778
+ id: string;
779
+ defaultMessage: string;
780
+ description: string;
781
+ };
782
+ searchLabel: {
783
+ id: string;
784
+ defaultMessage: string;
785
+ description: string;
786
+ };
787
+ categoriesSearchResults: {
788
+ id: string;
789
+ defaultMessage: string;
790
+ description: string;
791
+ };
792
+ frequentCategory: {
793
+ id: string;
794
+ defaultMessage: string;
795
+ description: string;
796
+ };
797
+ peopleCategory: {
798
+ id: string;
799
+ defaultMessage: string;
800
+ description: string;
801
+ };
802
+ natureCategory: {
803
+ id: string;
804
+ defaultMessage: string;
805
+ description: string;
806
+ };
807
+ foodsCategory: {
808
+ id: string;
809
+ defaultMessage: string;
810
+ description: string;
811
+ };
812
+ activityCategory: {
813
+ id: string;
814
+ defaultMessage: string;
815
+ description: string;
816
+ };
817
+ placesCategory: {
818
+ id: string;
819
+ defaultMessage: string;
820
+ description: string;
821
+ };
822
+ objectsCategory: {
823
+ id: string;
824
+ defaultMessage: string;
825
+ description: string;
826
+ };
827
+ symbolsCategory: {
828
+ id: string;
829
+ defaultMessage: string;
830
+ description: string;
831
+ };
832
+ flagsCategory: {
833
+ id: string;
834
+ defaultMessage: string;
835
+ description: string;
836
+ };
837
+ productivityCategory: {
838
+ id: string;
839
+ defaultMessage: string;
840
+ description: string;
841
+ };
842
+ userUploadsCustomCategory: {
843
+ id: string;
844
+ defaultMessage: string;
845
+ description: string;
846
+ };
847
+ allUploadsCustomCategory: {
848
+ id: string;
849
+ defaultMessage: string;
850
+ description: string;
851
+ };
852
+ deleteEmojiFailed: {
853
+ id: string;
854
+ defaultMessage: string;
855
+ description: string;
856
+ };
857
+ emojiInvalidImage: {
858
+ id: string;
859
+ defaultMessage: string;
860
+ description: string;
861
+ };
862
+ emojiUploadFailed: {
863
+ id: string;
864
+ defaultMessage: string;
865
+ description: string;
866
+ };
867
+ emojiImageTooBig: {
868
+ id: string;
869
+ defaultMessage: string;
870
+ description: string;
871
+ };
872
+ };
873
+
874
+ export declare interface OnCategory {
875
+ (categoryId: CategoryId | null): void;
876
+ }
877
+
878
+ export declare interface OnEmojiEvent<T = any> {
879
+ (
880
+ emojiId: EmojiId,
881
+ emoji: OptionalEmojiDescription,
882
+ event?: SyntheticEvent<T>,
883
+ ): void;
884
+ }
885
+
886
+ declare interface OnLifecycle {
887
+ (): void;
888
+ }
889
+
890
+ export declare interface OnToneSelected {
891
+ (variation: number): void;
892
+ }
893
+
894
+ export declare interface OnToneSelectorCancelled {
895
+ (): void;
896
+ }
897
+
898
+ export declare type OptionalEmojiDescription = EmojiDescription | undefined;
899
+
900
+ export declare type OptionalEmojiDescriptionWithVariations =
901
+ | EmojiDescriptionWithVariations
902
+ | undefined;
903
+
904
+ export declare type OptionalUser = User | undefined;
905
+
906
+ declare interface PickerRefHandler {
907
+ (ref: any): any;
908
+ }
909
+
910
+ declare interface Props {
911
+ /**
912
+ * The emoji to render
913
+ */
914
+ emoji: EmojiDescription;
915
+ /**
916
+ * Show the emoji as selected
917
+ */
918
+ selected?: boolean;
919
+ /**
920
+ * Automatically show the emoji as selected based on mouse hover.
921
+ *
922
+ * CSS, fast, does not require a re-render, but selected state not
923
+ * externally controlled via props.
924
+ */
925
+ selectOnHover?: boolean;
926
+ /**
927
+ * Called when an emoji is selected
928
+ */
929
+ onSelected?: OnEmojiEvent;
930
+ /**
931
+ * Called when the mouse moved over the emoji.
932
+ */
933
+ onMouseMove?: OnEmojiEvent;
934
+ /**
935
+ * Called when an emoji is deleted
936
+ */
937
+ onDelete?: OnEmojiEvent;
938
+ /**
939
+ * Callback for if an emoji image fails to load.
940
+ */
941
+ onLoadError?: OnEmojiEvent<HTMLImageElement>;
942
+ /**
943
+ * Additional css classes, if required.
944
+ */
945
+ className?: string;
946
+ /**
947
+ * Show a tooltip on mouse hover.
948
+ */
949
+ showTooltip?: boolean;
950
+ /**
951
+ * Show a delete button on mouse hover
952
+ * Used only for custom emoji
953
+ */
954
+ showDelete?: boolean;
955
+ /**
956
+ * Fits emoji to height in pixels, keeping aspect ratio
957
+ */
958
+ fitToHeight?: number;
959
+ shouldBeInteractive?: boolean;
960
+ }
961
+
962
+ declare interface Props_10 extends BaseResourcedEmojiProps {
963
+ emojiProvider: EmojiResource;
964
+ }
965
+
966
+ declare interface Props_11 {
967
+ onMouseMove: OnEmojiEvent;
968
+ onSelection: OnEmojiEvent;
969
+ selected: boolean;
970
+ emoji: EmojiDescription;
971
+ }
972
+
973
+ declare interface Props_2 {
974
+ shortName: string;
975
+ size?: number;
976
+ showTooltip?: boolean;
977
+ representation?: EmojiImageRepresentation;
978
+ }
979
+
980
+ declare interface Props_3 extends Props_4 {
981
+ onSelection?: OnEmojiEvent;
982
+ onPickerRef?: PickerRefHandler;
983
+ hideToneSelector?: boolean;
984
+ }
985
+
986
+ declare interface Props_4 {
987
+ emojiProvider: Promise<EmojiProvider>;
988
+ }
989
+
990
+ declare interface Props_5 extends Props_4 {
991
+ onUploaderRef?: UploadRefHandler;
992
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
993
+ }
994
+
995
+ declare interface Props_6 {
996
+ emojiProvider: EmojiProvider;
997
+ onUploaderRef?: UploadRefHandler;
998
+ createAnalyticsEvent?: CreateUIAnalyticsEvent;
999
+ }
1000
+
1001
+ declare interface Props_7 extends EmojiTypeAheadBaseProps, Props_4 {
1002
+ /** CSS selector, or target HTML element */
1003
+ target?: string | HTMLElement;
1004
+ position?: RelativePosition;
1005
+ zIndex?: number | string;
1006
+ offsetX?: number;
1007
+ offsetY?: number;
1008
+ }
1009
+
1010
+ declare interface Props_8 extends EmojiTypeAheadBaseProps {
1011
+ emojiProvider: EmojiProvider;
1012
+ }
1013
+
1014
+ declare interface Props_9 extends BaseResourcedEmojiProps, Props_4 {}
1015
+
1016
+ /**
1017
+ * The options used to configure a newly constructed queue.
1018
+ */
1019
+ declare interface QueueOptions {
1020
+ /**
1021
+ * The maximum number of duplicates allowed per item in the queue.
1022
+ */
1023
+ maxDuplicates: number;
1024
+ /**
1025
+ * The minimum number of unique items the queue should try to contain.
1026
+ * This number constrains the absolute size of the queue. It needs to be
1027
+ * large enough to contain maxDuplicates * minUniqueItems.
1028
+ */
1029
+ minUniqueItems: number;
1030
+ }
1031
+
1032
+ export declare const recordSelectionFailedSli: (
1033
+ options?:
1034
+ | {
1035
+ createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined;
1036
+ }
1037
+ | undefined,
1038
+ ) => (err: Error) => Promise<never>;
1039
+
1040
+ export declare const recordSelectionSucceededSli: (
1041
+ options?:
1042
+ | {
1043
+ createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined;
1044
+ }
1045
+ | undefined,
1046
+ ) => () => void;
1047
+
1048
+ export declare type RelativePosition = 'above' | 'below' | 'auto';
1049
+
1050
+ declare interface ResolveReject<T> {
1051
+ resolve(result: T): void;
1052
+ reject(reason?: any): void;
1053
+ }
1054
+
1055
+ export declare class ResourcedEmoji extends LoadingEmojiComponent<
1056
+ Props_9,
1057
+ State
1058
+ > {
1059
+ static AsyncLoadedComponent: ComponentClass<Props_10>;
1060
+ state: {
1061
+ asyncLoadedComponent: React_2.ComponentClass<Props_10, any>;
1062
+ };
1063
+ constructor(props: Props_9);
1064
+ componentWillUnmount(): void;
1065
+ asyncLoadComponent(): void;
1066
+ renderLoading(): JSX.Element;
1067
+ renderLoaded(
1068
+ loadedEmojiProvider: EmojiResource,
1069
+ ResourcedEmojiComponent: ComponentClass<Props_10>,
1070
+ ): JSX.Element;
1071
+ }
1072
+
1073
+ declare interface Retry<T> {
1074
+ (): Promise<T> | T;
1075
+ }
1076
+
1077
+ export declare interface SearchOptions {
1078
+ skinTone?: number;
1079
+ limit?: number;
1080
+ sort?: SearchSort;
1081
+ }
1082
+
1083
+ export declare enum SearchSort {
1084
+ None = 0,
1085
+ Default = 1,
1086
+ UsageFrequency = 2,
1087
+ }
1088
+
1089
+ export declare const selected = 'emoji-common-selected';
1090
+
1091
+ export declare const selectOnHover = 'emoji-common-select-on-hover';
1092
+
1093
+ declare class SiteEmojiResource {
1094
+ private siteServiceConfig;
1095
+ private mediaApiToken;
1096
+ private mediaEmojiCache;
1097
+ protected tokenManager: TokenManager;
1098
+ constructor(siteServiceConfig: ServiceConfig, mediaApiToken: MediaApiToken);
1099
+ /**
1100
+ * Will generate an emoji media path that is inclusive of client and token within the query parameter
1101
+ */
1102
+ generateTokenisedMediaURL(emoji: EmojiDescription): Promise<string>;
1103
+ /**
1104
+ * Will load media emoji, returning a new EmojiDescription if, for example,
1105
+ * the URL has changed.
1106
+ */
1107
+ loadMediaEmoji(
1108
+ emoji: EmojiDescription,
1109
+ useAlt?: boolean,
1110
+ ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
1111
+ optimisticRendering(
1112
+ emoji: EmojiDescription,
1113
+ useAlt?: boolean,
1114
+ ): boolean | Promise<boolean>;
1115
+ uploadEmoji(
1116
+ upload: EmojiUpload,
1117
+ progressCallback?: EmojiProgessCallback,
1118
+ ): Promise<EmojiDescription>;
1119
+ /**
1120
+ * Check if the MediaEmojiResource has been able to initialise an uploadToken. Retrieving an upload token
1121
+ * is asynchronous so the Promise will need to resolve before the state is known. If the token retrieval
1122
+ * completes with failure then the Promise will resolve to false.
1123
+ */
1124
+ hasUploadToken(): Promise<boolean>;
1125
+ prepareForUpload(): void;
1126
+ findEmoji(emojiId: EmojiId): Promise<OptionalEmojiDescription>;
1127
+ /**
1128
+ * Calls to site-scoped EmojiResource to delete emoji
1129
+ * @param emoji media emoji to delete
1130
+ * @returns Promise.resolve() if success and Promise.reject() for failure
1131
+ */
1132
+ deleteEmoji(emoji: EmojiDescription): Promise<boolean>;
1133
+ private postToEmojiService;
1134
+ }
1135
+
1136
+ export declare interface SpriteImageRepresentation
1137
+ extends EmojiImageRepresentation {
1138
+ x: number;
1139
+ y: number;
1140
+ xIndex: number;
1141
+ yIndex: number;
1142
+ }
1143
+
1144
+ /**
1145
+ * Sprite representation exposed from the EmojiResource.
1146
+ */
1147
+ export declare interface SpriteRepresentation
1148
+ extends SpriteImageRepresentation {
1149
+ sprite: SpriteSheet;
1150
+ }
1151
+
1152
+ /**
1153
+ * Representation returned from a sprite service.
1154
+ */
1155
+ export declare interface SpriteServiceRepresentation
1156
+ extends SpriteImageRepresentation {
1157
+ /** Should match a index in a SpriteSheets */
1158
+ spriteRef: string;
1159
+ }
1160
+
1161
+ export declare interface SpriteSheet {
1162
+ url: string;
1163
+ row: number;
1164
+ column: number;
1165
+ height: number;
1166
+ width: number;
1167
+ }
1168
+
1169
+ export declare interface SpriteSheets {
1170
+ [index: string]: SpriteSheet;
1171
+ }
1172
+
1173
+ declare interface State {
1174
+ loadedEmojiProvider?: EmojiProvider;
1175
+ asyncLoadedComponent?: ComponentClass<any>;
1176
+ }
1177
+
1178
+ export declare interface Styles {
1179
+ [index: string]: any;
1180
+ }
1181
+
1182
+ export declare const toEmojiId: (emoji: EmojiDescription) => EmojiId;
1183
+
1184
+ declare class TokenManager {
1185
+ private siteServiceConfig;
1186
+ private tokens;
1187
+ constructor(siteServiceConfig: ServiceConfig);
1188
+ isValidToken(mediaApiToken: MediaApiToken): boolean;
1189
+ addToken(type: TokenType, mediaApiToken: MediaApiToken): void;
1190
+ getToken(type: TokenType, forceRefresh?: boolean): Promise<MediaApiToken>;
1191
+ }
1192
+
1193
+ declare type TokenType = 'read' | 'upload';
1194
+
1195
+ export declare type ToneSelection = number | undefined;
1196
+
1197
+ export declare const toOptionalEmojiId: (
1198
+ emoji: OptionalEmojiDescription,
1199
+ ) => EmojiId | undefined;
1200
+
1201
+ export declare enum UfoComponentName {
1202
+ EMOJI = 'emoji',
1203
+ EMOJI_PICKER = 'emoji-picker',
1204
+ EMOJI_PROVIDER = 'emoji-provider',
1205
+ }
1206
+
1207
+ export declare enum UfoExperienceName {
1208
+ EMOJI_RENDERED = 'emoji-rendered',
1209
+ EMOJI_RESOURCE_FETCHED = 'emoji-resource-fetched',
1210
+ EMOJI_PICKER_OPENED = 'emoji-picker-opened',
1211
+ EMOJI_SELECTION_RECORDED = 'emoji-selection-recorded',
1212
+ EMOJI_UPLOADED = 'emoji-uploaded',
1213
+ EMOJI_SEARCHED = 'emoji-searched',
1214
+ }
1215
+
1216
+ export declare const ufoExperiences: {
1217
+ 'emoji-rendered': ConcurrentExperience;
1218
+ 'emoji-resource-fetched': ConcurrentExperience;
1219
+ 'emoji-picker-opened': UFOExperience;
1220
+ 'emoji-selection-recorded': UFOExperience;
1221
+ 'emoji-uploaded': UFOExperience;
1222
+ 'emoji-searched': UFOExperience;
1223
+ };
1224
+
1225
+ export declare interface UploadingEmojiProvider extends EmojiProvider {
1226
+ /**
1227
+ * Returns true if upload is supported.
1228
+ *
1229
+ * Waits until resources have loaded before returning.
1230
+ */
1231
+ isUploadSupported(): Promise<boolean>;
1232
+ /**
1233
+ * Uploads an emoji to the configured repository.
1234
+ *
1235
+ * Will return a promise with the EmojiDescription once completed.
1236
+ *
1237
+ * The last search will be re-run to ensure the new emoji is considered in the search.
1238
+ */
1239
+ uploadCustomEmoji(upload: EmojiUpload): Promise<EmojiDescription>;
1240
+ /**
1241
+ * Allows the preloading of data (e.g. authentication tokens) to speed the uploading of emoji.
1242
+ */
1243
+ prepareForUpload(): Promise<void>;
1244
+ }
1245
+
1246
+ declare interface UploadRefHandler {
1247
+ (ref: HTMLDivElement): void;
1248
+ }
1249
+
1250
+ /**
1251
+ * Keeps track of the last 150 emoji usages, although limiting the maximum count for a single emoji to 25 to
1252
+ * ensure we don't end up with only a single emoji being recorded. Usage is persisted to local storage for
1253
+ * consistency between 'sessions'.
1254
+ *
1255
+ * Skin tone variations for an emoji will be 'collapsed' so they are tracked as their base emoji. Gender
1256
+ * variations are not collapsed in this way and will be tracked per gender. This decision reflects the UI of
1257
+ * the EmojiPicker component.
1258
+ */
1259
+ export declare class UsageFrequencyTracker {
1260
+ private static readonly queueOptions;
1261
+ protected queue: DuplicateLimitedQueue<string>;
1262
+ private gateway;
1263
+ constructor(useStorageIfPossible?: boolean);
1264
+ /**
1265
+ * Record the fact that the supplied emoji was used. You should note that usage is updated asynchronously so you can not
1266
+ * count on getOrder() reflecting this usage immediately.
1267
+ *
1268
+ * @param emoji the emoji who's usage is to be recorded. If the emoji has no id then no usage will be recorded
1269
+ */
1270
+ recordUsage(emoji: EmojiDescription): void;
1271
+ /**
1272
+ * Returns an array of emoji id (without skin tone variations) sorted by most used to least used. If there
1273
+ * are no usages then an empty array will be returned.
1274
+ */
1275
+ getOrder(): Array<string>;
1276
+ /**
1277
+ * Exposed for testing only. Clear any recorded usage.
1278
+ */
1279
+ clear(): void;
1280
+ }
1281
+
1282
+ export declare interface User {
1283
+ id: string;
1284
+ }
1285
+
1286
+ export {};
1287
+ ```