emoji-picker-react 4.13.3 → 4.14.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.
- package/dist/DomUtils/elementPositionInRow.d.ts +1 -6
- package/dist/components/body/EmojiCategory.d.ts +2 -1
- package/dist/components/body/EmojiList.d.ts +3 -1
- package/dist/components/context/ElementRefContext.d.ts +1 -0
- package/dist/components/emoji/ClickableEmojiButton.d.ts +2 -1
- package/dist/components/emoji/Emoji.d.ts +3 -2
- package/dist/dataUtils/emojiSelectors.d.ts +1 -1
- package/dist/emoji-picker-react.cjs.development.js +615 -544
- package/dist/emoji-picker-react.cjs.development.js.map +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
- package/dist/emoji-picker-react.esm.js +616 -545
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/hooks/preloadEmoji.d.ts +4 -0
- package/dist/hooks/useCategoryHeight.d.ts +5 -0
- package/dist/hooks/useEmojiVirtualization.d.ts +16 -0
- package/dist/hooks/useOnScroll.d.ts +1 -1
- package/dist/virtualization/virtualizationHelpers.d.ts +18 -0
- package/package.json +2 -1
- package/src/DomUtils/elementPositionInRow.ts +8 -131
- package/src/DomUtils/keyboardNavigation.ts +62 -48
- package/src/components/body/Body.tsx +2 -2
- package/src/components/body/EmojiCategory.tsx +7 -5
- package/src/components/body/EmojiList.tsx +43 -78
- package/src/components/context/ElementRefContext.tsx +8 -0
- package/src/components/emoji/ClickableEmojiButton.tsx +4 -1
- package/src/components/emoji/Emoji.tsx +4 -1
- package/src/components/header/Search/Search.tsx +0 -5
- package/src/components/main/PickerMain.tsx +8 -5
- package/src/dataUtils/emojiSelectors.ts +29 -3
- package/src/hooks/preloadEmoji.ts +49 -7
- package/src/hooks/useCategoryHeight.ts +92 -0
- package/src/hooks/useEmojiVirtualization.tsx +112 -0
- package/src/hooks/useFilter.ts +17 -24
- package/src/hooks/useOnScroll.ts +5 -1
- package/src/virtualization/virtualizationHelpers.ts +45 -0
- package/dist/components/body/Suggested.d.ts +0 -7
- package/dist/components/header/Search/CssSearch.d.ts +0 -4
- package/dist/globals/doesBrowserSupportCssHas.d.ts +0 -2
- package/src/components/body/Suggested.tsx +0 -69
- package/src/components/header/Search/CssSearch.tsx +0 -45
- package/src/globals/doesBrowserSupportCssHas.ts +0 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { memo, createElement, useState,
|
|
1
|
+
import React__default, { memo, createElement, useState, useRef, useMemo, useEffect, createContext, useContext, createRef, useCallback, Fragment, Suspense, Component } from 'react';
|
|
2
2
|
import { createSheet, cx } from 'flairup';
|
|
3
3
|
|
|
4
4
|
function _extends() {
|
|
@@ -190,6 +190,86 @@ function compareConfig(prev, next) {
|
|
|
190
190
|
var DEFAULT_REACTIONS = ['1f44d', '2764-fe0f', '1f603', '1f622', '1f64f', '1f44e', '1f621' // 😡
|
|
191
191
|
];
|
|
192
192
|
|
|
193
|
+
var alphaNumericEmojiIndex = {};
|
|
194
|
+
setTimeout(function () {
|
|
195
|
+
allEmojis.reduce(function (searchIndex, emoji) {
|
|
196
|
+
indexEmoji(emoji);
|
|
197
|
+
return searchIndex;
|
|
198
|
+
}, alphaNumericEmojiIndex);
|
|
199
|
+
});
|
|
200
|
+
function indexEmoji(emoji) {
|
|
201
|
+
var joinedNameString = emojiNames(emoji).flat().join('').toLowerCase().replace(/[^a-zA-Z\d]/g, '').split('');
|
|
202
|
+
joinedNameString.forEach(function (_char) {
|
|
203
|
+
var _alphaNumericEmojiInd;
|
|
204
|
+
alphaNumericEmojiIndex[_char] = (_alphaNumericEmojiInd = alphaNumericEmojiIndex[_char]) != null ? _alphaNumericEmojiInd : {};
|
|
205
|
+
alphaNumericEmojiIndex[_char][emojiUnified(emoji)] = emoji;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function useDebouncedState(initialValue, delay) {
|
|
210
|
+
if (delay === void 0) {
|
|
211
|
+
delay = 0;
|
|
212
|
+
}
|
|
213
|
+
var _useState = useState(initialValue),
|
|
214
|
+
state = _useState[0],
|
|
215
|
+
setState = _useState[1];
|
|
216
|
+
var timer = useRef(null);
|
|
217
|
+
function debouncedSetState(value) {
|
|
218
|
+
return new Promise(function (resolve) {
|
|
219
|
+
var _window;
|
|
220
|
+
if (timer.current) {
|
|
221
|
+
clearTimeout(timer.current);
|
|
222
|
+
}
|
|
223
|
+
timer.current = (_window = window) == null ? void 0 : _window.setTimeout(function () {
|
|
224
|
+
setState(value);
|
|
225
|
+
resolve(value);
|
|
226
|
+
}, delay);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return [state, debouncedSetState];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function useIsUnicodeHidden() {
|
|
233
|
+
var unicodeToHide = useUnicodeToHide();
|
|
234
|
+
return function (emojiUnified) {
|
|
235
|
+
return unicodeToHide.has(emojiUnified);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function useDisallowedEmojis() {
|
|
240
|
+
var DisallowedEmojisRef = useRef({});
|
|
241
|
+
var emojiVersionConfig = useEmojiVersionConfig();
|
|
242
|
+
return useMemo(function () {
|
|
243
|
+
var emojiVersion = parseFloat("" + emojiVersionConfig);
|
|
244
|
+
if (!emojiVersionConfig || Number.isNaN(emojiVersion)) {
|
|
245
|
+
return DisallowedEmojisRef.current;
|
|
246
|
+
}
|
|
247
|
+
return allEmojis.reduce(function (disallowedEmojis, emoji) {
|
|
248
|
+
if (addedInNewerVersion(emoji, emojiVersion)) {
|
|
249
|
+
disallowedEmojis[emojiUnified(emoji)] = true;
|
|
250
|
+
}
|
|
251
|
+
return disallowedEmojis;
|
|
252
|
+
}, DisallowedEmojisRef.current);
|
|
253
|
+
}, [emojiVersionConfig]);
|
|
254
|
+
}
|
|
255
|
+
function useIsEmojiDisallowed() {
|
|
256
|
+
var disallowedEmojis = useDisallowedEmojis();
|
|
257
|
+
var isUnicodeHidden = useIsUnicodeHidden();
|
|
258
|
+
return function isEmojiDisallowed(emoji) {
|
|
259
|
+
var unified = unifiedWithoutSkinTone(emojiUnified(emoji));
|
|
260
|
+
return Boolean(disallowedEmojis[unified] || isUnicodeHidden(unified));
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function addedInNewerVersion(emoji, supportedLevel) {
|
|
264
|
+
return addedIn(emoji) > supportedLevel;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function useMarkInitialLoad(dispatch) {
|
|
268
|
+
useEffect(function () {
|
|
269
|
+
dispatch(true);
|
|
270
|
+
}, [dispatch]);
|
|
271
|
+
}
|
|
272
|
+
|
|
193
273
|
var SuggestionMode;
|
|
194
274
|
(function (SuggestionMode) {
|
|
195
275
|
SuggestionMode["RECENT"] = "recent";
|
|
@@ -237,6 +317,128 @@ var SkinTonePickerLocation;
|
|
|
237
317
|
SkinTonePickerLocation["PREVIEW"] = "PREVIEW";
|
|
238
318
|
})(SkinTonePickerLocation || (SkinTonePickerLocation = {}));
|
|
239
319
|
|
|
320
|
+
function PickerContextProvider(_ref) {
|
|
321
|
+
var children = _ref.children;
|
|
322
|
+
var disallowedEmojis = useDisallowedEmojis();
|
|
323
|
+
var defaultSkinTone = useDefaultSkinToneConfig();
|
|
324
|
+
var reactionsDefaultOpen = useReactionsOpenConfig();
|
|
325
|
+
// Initialize the filter with the inititial dictionary
|
|
326
|
+
var filterRef = useRef(alphaNumericEmojiIndex);
|
|
327
|
+
var disallowClickRef = useRef(false);
|
|
328
|
+
var disallowMouseRef = useRef(false);
|
|
329
|
+
var disallowedEmojisRef = useRef(disallowedEmojis);
|
|
330
|
+
var suggestedUpdateState = useDebouncedState(Date.now(), 200);
|
|
331
|
+
var searchTerm = useDebouncedState('', 100);
|
|
332
|
+
var skinToneFanOpenState = useState(false);
|
|
333
|
+
var activeSkinTone = useState(defaultSkinTone);
|
|
334
|
+
var activeCategoryState = useState(null);
|
|
335
|
+
var emojisThatFailedToLoadState = useState(new Set());
|
|
336
|
+
var emojiVariationPickerState = useState(null);
|
|
337
|
+
var reactionsModeState = useState(reactionsDefaultOpen);
|
|
338
|
+
var _useState = useState(false),
|
|
339
|
+
isPastInitialLoad = _useState[0],
|
|
340
|
+
setIsPastInitialLoad = _useState[1];
|
|
341
|
+
useMarkInitialLoad(setIsPastInitialLoad);
|
|
342
|
+
return createElement(PickerContext.Provider, {
|
|
343
|
+
value: {
|
|
344
|
+
activeCategoryState: activeCategoryState,
|
|
345
|
+
activeSkinTone: activeSkinTone,
|
|
346
|
+
disallowClickRef: disallowClickRef,
|
|
347
|
+
disallowMouseRef: disallowMouseRef,
|
|
348
|
+
disallowedEmojisRef: disallowedEmojisRef,
|
|
349
|
+
emojiVariationPickerState: emojiVariationPickerState,
|
|
350
|
+
emojisThatFailedToLoadState: emojisThatFailedToLoadState,
|
|
351
|
+
filterRef: filterRef,
|
|
352
|
+
isPastInitialLoad: isPastInitialLoad,
|
|
353
|
+
searchTerm: searchTerm,
|
|
354
|
+
skinToneFanOpenState: skinToneFanOpenState,
|
|
355
|
+
suggestedUpdateState: suggestedUpdateState,
|
|
356
|
+
reactionsModeState: reactionsModeState
|
|
357
|
+
}
|
|
358
|
+
}, children);
|
|
359
|
+
}
|
|
360
|
+
var PickerContext = /*#__PURE__*/createContext({
|
|
361
|
+
activeCategoryState: [null, function () {}],
|
|
362
|
+
activeSkinTone: [SkinTones.NEUTRAL, function () {}],
|
|
363
|
+
disallowClickRef: {
|
|
364
|
+
current: false
|
|
365
|
+
},
|
|
366
|
+
disallowMouseRef: {
|
|
367
|
+
current: false
|
|
368
|
+
},
|
|
369
|
+
disallowedEmojisRef: {
|
|
370
|
+
current: {}
|
|
371
|
+
},
|
|
372
|
+
emojiVariationPickerState: [null, function () {}],
|
|
373
|
+
emojisThatFailedToLoadState: [/*#__PURE__*/new Set(), function () {}],
|
|
374
|
+
filterRef: {
|
|
375
|
+
current: {}
|
|
376
|
+
},
|
|
377
|
+
isPastInitialLoad: true,
|
|
378
|
+
searchTerm: ['', function () {
|
|
379
|
+
return new Promise(function () {
|
|
380
|
+
return undefined;
|
|
381
|
+
});
|
|
382
|
+
}],
|
|
383
|
+
skinToneFanOpenState: [false, function () {}],
|
|
384
|
+
suggestedUpdateState: [/*#__PURE__*/Date.now(), function () {}],
|
|
385
|
+
reactionsModeState: [false, function () {}]
|
|
386
|
+
});
|
|
387
|
+
function useFilterRef() {
|
|
388
|
+
var _React$useContext = useContext(PickerContext),
|
|
389
|
+
filterRef = _React$useContext.filterRef;
|
|
390
|
+
return filterRef;
|
|
391
|
+
}
|
|
392
|
+
function useDisallowClickRef() {
|
|
393
|
+
var _React$useContext2 = useContext(PickerContext),
|
|
394
|
+
disallowClickRef = _React$useContext2.disallowClickRef;
|
|
395
|
+
return disallowClickRef;
|
|
396
|
+
}
|
|
397
|
+
function useDisallowMouseRef() {
|
|
398
|
+
var _React$useContext3 = useContext(PickerContext),
|
|
399
|
+
disallowMouseRef = _React$useContext3.disallowMouseRef;
|
|
400
|
+
return disallowMouseRef;
|
|
401
|
+
}
|
|
402
|
+
function useReactionsModeState() {
|
|
403
|
+
var _React$useContext4 = useContext(PickerContext),
|
|
404
|
+
reactionsModeState = _React$useContext4.reactionsModeState;
|
|
405
|
+
return reactionsModeState;
|
|
406
|
+
}
|
|
407
|
+
function useSearchTermState() {
|
|
408
|
+
var _React$useContext5 = useContext(PickerContext),
|
|
409
|
+
searchTerm = _React$useContext5.searchTerm;
|
|
410
|
+
return searchTerm;
|
|
411
|
+
}
|
|
412
|
+
function useActiveSkinToneState() {
|
|
413
|
+
var _React$useContext6 = useContext(PickerContext),
|
|
414
|
+
activeSkinTone = _React$useContext6.activeSkinTone;
|
|
415
|
+
return activeSkinTone;
|
|
416
|
+
}
|
|
417
|
+
function useEmojisThatFailedToLoadState() {
|
|
418
|
+
var _React$useContext7 = useContext(PickerContext),
|
|
419
|
+
emojisThatFailedToLoadState = _React$useContext7.emojisThatFailedToLoadState;
|
|
420
|
+
return emojisThatFailedToLoadState;
|
|
421
|
+
}
|
|
422
|
+
function useEmojiVariationPickerState() {
|
|
423
|
+
var _React$useContext9 = useContext(PickerContext),
|
|
424
|
+
emojiVariationPickerState = _React$useContext9.emojiVariationPickerState;
|
|
425
|
+
return emojiVariationPickerState;
|
|
426
|
+
}
|
|
427
|
+
function useSkinToneFanOpenState() {
|
|
428
|
+
var _React$useContext10 = useContext(PickerContext),
|
|
429
|
+
skinToneFanOpenState = _React$useContext10.skinToneFanOpenState;
|
|
430
|
+
return skinToneFanOpenState;
|
|
431
|
+
}
|
|
432
|
+
function useUpdateSuggested() {
|
|
433
|
+
var _React$useContext12 = useContext(PickerContext),
|
|
434
|
+
suggestedUpdateState = _React$useContext12.suggestedUpdateState;
|
|
435
|
+
var suggestedUpdated = suggestedUpdateState[0],
|
|
436
|
+
setsuggestedUpdate = suggestedUpdateState[1];
|
|
437
|
+
return [suggestedUpdated, function updateSuggested() {
|
|
438
|
+
setsuggestedUpdate(Date.now());
|
|
439
|
+
}];
|
|
440
|
+
}
|
|
441
|
+
|
|
240
442
|
var _configByCategory;
|
|
241
443
|
var categoriesOrdered = [Categories.SUGGESTED, Categories.CUSTOM, Categories.SMILEYS_PEOPLE, Categories.ANIMALS_NATURE, Categories.FOOD_DRINK, Categories.TRAVEL_PLACES, Categories.ACTIVITIES, Categories.OBJECTS, Categories.SYMBOLS, Categories.FLAGS];
|
|
242
444
|
var SuggestedRecent = {
|
|
@@ -17164,56 +17366,107 @@ var EmojiProperties;
|
|
|
17164
17366
|
EmojiProperties["imgUrl"] = "imgUrl";
|
|
17165
17367
|
})(EmojiProperties || (EmojiProperties = {}));
|
|
17166
17368
|
|
|
17167
|
-
var
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
}
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
}
|
|
17182
|
-
|
|
17183
|
-
function emojiNames(emoji) {
|
|
17184
|
-
var _emoji$EmojiPropertie;
|
|
17185
|
-
return (_emoji$EmojiPropertie = emoji[EmojiProperties.name]) != null ? _emoji$EmojiPropertie : [];
|
|
17186
|
-
}
|
|
17187
|
-
function addedIn(emoji) {
|
|
17188
|
-
return parseFloat(emoji[EmojiProperties.added_in]);
|
|
17189
|
-
}
|
|
17190
|
-
function emojiName(emoji) {
|
|
17191
|
-
if (!emoji) {
|
|
17192
|
-
return '';
|
|
17193
|
-
}
|
|
17194
|
-
return emojiNames(emoji)[0];
|
|
17195
|
-
}
|
|
17196
|
-
function unifiedWithoutSkinTone(unified) {
|
|
17197
|
-
var splat = unified.split('-');
|
|
17198
|
-
var _splat$splice = splat.splice(1, 1),
|
|
17199
|
-
skinTone = _splat$splice[0];
|
|
17200
|
-
if (skinTonesMapped[skinTone]) {
|
|
17201
|
-
return splat.join('-');
|
|
17369
|
+
var SUGGESTED_LS_KEY = 'epr_suggested';
|
|
17370
|
+
function getSuggested(mode) {
|
|
17371
|
+
try {
|
|
17372
|
+
var _window, _window$localStorage$, _window2;
|
|
17373
|
+
if (!((_window = window) != null && _window.localStorage)) {
|
|
17374
|
+
return [];
|
|
17375
|
+
}
|
|
17376
|
+
var recent = JSON.parse((_window$localStorage$ = (_window2 = window) == null ? void 0 : _window2.localStorage.getItem(SUGGESTED_LS_KEY)) != null ? _window$localStorage$ : '[]');
|
|
17377
|
+
if (mode === SuggestionMode.FREQUENT) {
|
|
17378
|
+
return recent.sort(function (a, b) {
|
|
17379
|
+
return b.count - a.count;
|
|
17380
|
+
});
|
|
17381
|
+
}
|
|
17382
|
+
return recent;
|
|
17383
|
+
} catch (_unused) {
|
|
17384
|
+
return [];
|
|
17202
17385
|
}
|
|
17203
|
-
return unified;
|
|
17204
17386
|
}
|
|
17205
|
-
function
|
|
17206
|
-
var
|
|
17387
|
+
function setSuggested(emoji, skinTone) {
|
|
17388
|
+
var recent = getSuggested();
|
|
17389
|
+
var unified = emojiUnified(emoji, skinTone);
|
|
17390
|
+
var originalUnified = emojiUnified(emoji);
|
|
17391
|
+
var existing = recent.find(function (_ref) {
|
|
17392
|
+
var u = _ref.unified;
|
|
17393
|
+
return u === unified;
|
|
17394
|
+
});
|
|
17395
|
+
var nextList;
|
|
17396
|
+
if (existing) {
|
|
17397
|
+
nextList = [existing].concat(recent.filter(function (i) {
|
|
17398
|
+
return i !== existing;
|
|
17399
|
+
}));
|
|
17400
|
+
} else {
|
|
17401
|
+
existing = {
|
|
17402
|
+
unified: unified,
|
|
17403
|
+
original: originalUnified,
|
|
17404
|
+
count: 0
|
|
17405
|
+
};
|
|
17406
|
+
nextList = [existing].concat(recent);
|
|
17407
|
+
}
|
|
17408
|
+
existing.count++;
|
|
17409
|
+
nextList.length = Math.min(nextList.length, 14);
|
|
17410
|
+
try {
|
|
17411
|
+
var _window3;
|
|
17412
|
+
(_window3 = window) == null ? void 0 : _window3.localStorage.setItem(SUGGESTED_LS_KEY, JSON.stringify(nextList));
|
|
17413
|
+
// Prevents the change from being seen immediately.
|
|
17414
|
+
} catch (_unused2) {
|
|
17415
|
+
// ignore
|
|
17416
|
+
}
|
|
17417
|
+
}
|
|
17418
|
+
|
|
17419
|
+
function emojiNames(emoji) {
|
|
17420
|
+
var _emoji$EmojiPropertie;
|
|
17421
|
+
return (_emoji$EmojiPropertie = emoji[EmojiProperties.name]) != null ? _emoji$EmojiPropertie : [];
|
|
17422
|
+
}
|
|
17423
|
+
function addedIn(emoji) {
|
|
17424
|
+
return parseFloat(emoji[EmojiProperties.added_in]);
|
|
17425
|
+
}
|
|
17426
|
+
function emojiName(emoji) {
|
|
17427
|
+
if (!emoji) {
|
|
17428
|
+
return '';
|
|
17429
|
+
}
|
|
17430
|
+
return emojiNames(emoji)[0];
|
|
17431
|
+
}
|
|
17432
|
+
function unifiedWithoutSkinTone(unified) {
|
|
17433
|
+
var splat = unified.split('-');
|
|
17434
|
+
var _splat$splice = splat.splice(1, 1),
|
|
17435
|
+
skinTone = _splat$splice[0];
|
|
17436
|
+
if (skinTonesMapped[skinTone]) {
|
|
17437
|
+
return splat.join('-');
|
|
17438
|
+
}
|
|
17439
|
+
return unified;
|
|
17440
|
+
}
|
|
17441
|
+
function emojiUnified(emoji, skinTone) {
|
|
17442
|
+
var _emojiVariationUnifie;
|
|
17207
17443
|
var unified = emoji[EmojiProperties.unified];
|
|
17208
17444
|
if (!skinTone || !emojiHasVariations(emoji)) {
|
|
17209
17445
|
return unified;
|
|
17210
17446
|
}
|
|
17211
17447
|
return (_emojiVariationUnifie = emojiVariationUnified(emoji, skinTone)) != null ? _emojiVariationUnifie : unified;
|
|
17212
17448
|
}
|
|
17213
|
-
function
|
|
17214
|
-
var
|
|
17215
|
-
|
|
17216
|
-
|
|
17449
|
+
function useGetEmojisByCategory() {
|
|
17450
|
+
var suggestedEmojisModeConfig = useSuggestedEmojisModeConfig();
|
|
17451
|
+
var _useUpdateSuggested = useUpdateSuggested(),
|
|
17452
|
+
suggestedUpdated = _useUpdateSuggested[0];
|
|
17453
|
+
var suggested = React__default.useMemo(function () {
|
|
17454
|
+
var _getSuggested;
|
|
17455
|
+
var suggested = (_getSuggested = getSuggested(suggestedEmojisModeConfig)) != null ? _getSuggested : [];
|
|
17456
|
+
return suggested.map(function (s) {
|
|
17457
|
+
return emojiByUnified(s.unified);
|
|
17458
|
+
}).filter(Boolean);
|
|
17459
|
+
},
|
|
17460
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17461
|
+
[suggestedUpdated, suggestedEmojisModeConfig]);
|
|
17462
|
+
return function getEmojisByCategory(category) {
|
|
17463
|
+
var _emojis$category;
|
|
17464
|
+
if (category === Categories.SUGGESTED) {
|
|
17465
|
+
return suggested;
|
|
17466
|
+
}
|
|
17467
|
+
// @ts-ignore
|
|
17468
|
+
return (_emojis$category = emojis[category]) != null ? _emojis$category : [];
|
|
17469
|
+
};
|
|
17217
17470
|
}
|
|
17218
17471
|
// WARNING: DO NOT USE DIRECTLY
|
|
17219
17472
|
function emojiUrlByUnified(unified, emojiStyle) {
|
|
@@ -17374,197 +17627,6 @@ function usePickerConfig() {
|
|
|
17374
17627
|
return useContext(ConfigContext);
|
|
17375
17628
|
}
|
|
17376
17629
|
|
|
17377
|
-
function useDebouncedState(initialValue, delay) {
|
|
17378
|
-
if (delay === void 0) {
|
|
17379
|
-
delay = 0;
|
|
17380
|
-
}
|
|
17381
|
-
var _useState = useState(initialValue),
|
|
17382
|
-
state = _useState[0],
|
|
17383
|
-
setState = _useState[1];
|
|
17384
|
-
var timer = useRef(null);
|
|
17385
|
-
function debouncedSetState(value) {
|
|
17386
|
-
return new Promise(function (resolve) {
|
|
17387
|
-
var _window;
|
|
17388
|
-
if (timer.current) {
|
|
17389
|
-
clearTimeout(timer.current);
|
|
17390
|
-
}
|
|
17391
|
-
timer.current = (_window = window) == null ? void 0 : _window.setTimeout(function () {
|
|
17392
|
-
setState(value);
|
|
17393
|
-
resolve(value);
|
|
17394
|
-
}, delay);
|
|
17395
|
-
});
|
|
17396
|
-
}
|
|
17397
|
-
return [state, debouncedSetState];
|
|
17398
|
-
}
|
|
17399
|
-
|
|
17400
|
-
function useIsUnicodeHidden() {
|
|
17401
|
-
var unicodeToHide = useUnicodeToHide();
|
|
17402
|
-
return function (emojiUnified) {
|
|
17403
|
-
return unicodeToHide.has(emojiUnified);
|
|
17404
|
-
};
|
|
17405
|
-
}
|
|
17406
|
-
|
|
17407
|
-
function useDisallowedEmojis() {
|
|
17408
|
-
var DisallowedEmojisRef = useRef({});
|
|
17409
|
-
var emojiVersionConfig = useEmojiVersionConfig();
|
|
17410
|
-
return useMemo(function () {
|
|
17411
|
-
var emojiVersion = parseFloat("" + emojiVersionConfig);
|
|
17412
|
-
if (!emojiVersionConfig || Number.isNaN(emojiVersion)) {
|
|
17413
|
-
return DisallowedEmojisRef.current;
|
|
17414
|
-
}
|
|
17415
|
-
return allEmojis.reduce(function (disallowedEmojis, emoji) {
|
|
17416
|
-
if (addedInNewerVersion(emoji, emojiVersion)) {
|
|
17417
|
-
disallowedEmojis[emojiUnified(emoji)] = true;
|
|
17418
|
-
}
|
|
17419
|
-
return disallowedEmojis;
|
|
17420
|
-
}, DisallowedEmojisRef.current);
|
|
17421
|
-
}, [emojiVersionConfig]);
|
|
17422
|
-
}
|
|
17423
|
-
function useIsEmojiDisallowed() {
|
|
17424
|
-
var disallowedEmojis = useDisallowedEmojis();
|
|
17425
|
-
var isUnicodeHidden = useIsUnicodeHidden();
|
|
17426
|
-
return function isEmojiDisallowed(emoji) {
|
|
17427
|
-
var unified = unifiedWithoutSkinTone(emojiUnified(emoji));
|
|
17428
|
-
return Boolean(disallowedEmojis[unified] || isUnicodeHidden(unified));
|
|
17429
|
-
};
|
|
17430
|
-
}
|
|
17431
|
-
function addedInNewerVersion(emoji, supportedLevel) {
|
|
17432
|
-
return addedIn(emoji) > supportedLevel;
|
|
17433
|
-
}
|
|
17434
|
-
|
|
17435
|
-
function useMarkInitialLoad(dispatch) {
|
|
17436
|
-
useEffect(function () {
|
|
17437
|
-
dispatch(true);
|
|
17438
|
-
}, [dispatch]);
|
|
17439
|
-
}
|
|
17440
|
-
|
|
17441
|
-
function PickerContextProvider(_ref) {
|
|
17442
|
-
var children = _ref.children;
|
|
17443
|
-
var disallowedEmojis = useDisallowedEmojis();
|
|
17444
|
-
var defaultSkinTone = useDefaultSkinToneConfig();
|
|
17445
|
-
var reactionsDefaultOpen = useReactionsOpenConfig();
|
|
17446
|
-
// Initialize the filter with the inititial dictionary
|
|
17447
|
-
var filterRef = useRef(alphaNumericEmojiIndex);
|
|
17448
|
-
var disallowClickRef = useRef(false);
|
|
17449
|
-
var disallowMouseRef = useRef(false);
|
|
17450
|
-
var disallowedEmojisRef = useRef(disallowedEmojis);
|
|
17451
|
-
var suggestedUpdateState = useDebouncedState(Date.now(), 200);
|
|
17452
|
-
var searchTerm = useDebouncedState('', 100);
|
|
17453
|
-
var skinToneFanOpenState = useState(false);
|
|
17454
|
-
var activeSkinTone = useState(defaultSkinTone);
|
|
17455
|
-
var activeCategoryState = useState(null);
|
|
17456
|
-
var emojisThatFailedToLoadState = useState(new Set());
|
|
17457
|
-
var emojiVariationPickerState = useState(null);
|
|
17458
|
-
var reactionsModeState = useState(reactionsDefaultOpen);
|
|
17459
|
-
var _useState = useState(false),
|
|
17460
|
-
isPastInitialLoad = _useState[0],
|
|
17461
|
-
setIsPastInitialLoad = _useState[1];
|
|
17462
|
-
useMarkInitialLoad(setIsPastInitialLoad);
|
|
17463
|
-
return createElement(PickerContext.Provider, {
|
|
17464
|
-
value: {
|
|
17465
|
-
activeCategoryState: activeCategoryState,
|
|
17466
|
-
activeSkinTone: activeSkinTone,
|
|
17467
|
-
disallowClickRef: disallowClickRef,
|
|
17468
|
-
disallowMouseRef: disallowMouseRef,
|
|
17469
|
-
disallowedEmojisRef: disallowedEmojisRef,
|
|
17470
|
-
emojiVariationPickerState: emojiVariationPickerState,
|
|
17471
|
-
emojisThatFailedToLoadState: emojisThatFailedToLoadState,
|
|
17472
|
-
filterRef: filterRef,
|
|
17473
|
-
isPastInitialLoad: isPastInitialLoad,
|
|
17474
|
-
searchTerm: searchTerm,
|
|
17475
|
-
skinToneFanOpenState: skinToneFanOpenState,
|
|
17476
|
-
suggestedUpdateState: suggestedUpdateState,
|
|
17477
|
-
reactionsModeState: reactionsModeState
|
|
17478
|
-
}
|
|
17479
|
-
}, children);
|
|
17480
|
-
}
|
|
17481
|
-
var PickerContext = /*#__PURE__*/createContext({
|
|
17482
|
-
activeCategoryState: [null, function () {}],
|
|
17483
|
-
activeSkinTone: [SkinTones.NEUTRAL, function () {}],
|
|
17484
|
-
disallowClickRef: {
|
|
17485
|
-
current: false
|
|
17486
|
-
},
|
|
17487
|
-
disallowMouseRef: {
|
|
17488
|
-
current: false
|
|
17489
|
-
},
|
|
17490
|
-
disallowedEmojisRef: {
|
|
17491
|
-
current: {}
|
|
17492
|
-
},
|
|
17493
|
-
emojiVariationPickerState: [null, function () {}],
|
|
17494
|
-
emojisThatFailedToLoadState: [/*#__PURE__*/new Set(), function () {}],
|
|
17495
|
-
filterRef: {
|
|
17496
|
-
current: {}
|
|
17497
|
-
},
|
|
17498
|
-
isPastInitialLoad: true,
|
|
17499
|
-
searchTerm: ['', function () {
|
|
17500
|
-
return new Promise(function () {
|
|
17501
|
-
return undefined;
|
|
17502
|
-
});
|
|
17503
|
-
}],
|
|
17504
|
-
skinToneFanOpenState: [false, function () {}],
|
|
17505
|
-
suggestedUpdateState: [/*#__PURE__*/Date.now(), function () {}],
|
|
17506
|
-
reactionsModeState: [false, function () {}]
|
|
17507
|
-
});
|
|
17508
|
-
function useFilterRef() {
|
|
17509
|
-
var _React$useContext = useContext(PickerContext),
|
|
17510
|
-
filterRef = _React$useContext.filterRef;
|
|
17511
|
-
return filterRef;
|
|
17512
|
-
}
|
|
17513
|
-
function useDisallowClickRef() {
|
|
17514
|
-
var _React$useContext2 = useContext(PickerContext),
|
|
17515
|
-
disallowClickRef = _React$useContext2.disallowClickRef;
|
|
17516
|
-
return disallowClickRef;
|
|
17517
|
-
}
|
|
17518
|
-
function useDisallowMouseRef() {
|
|
17519
|
-
var _React$useContext3 = useContext(PickerContext),
|
|
17520
|
-
disallowMouseRef = _React$useContext3.disallowMouseRef;
|
|
17521
|
-
return disallowMouseRef;
|
|
17522
|
-
}
|
|
17523
|
-
function useReactionsModeState() {
|
|
17524
|
-
var _React$useContext4 = useContext(PickerContext),
|
|
17525
|
-
reactionsModeState = _React$useContext4.reactionsModeState;
|
|
17526
|
-
return reactionsModeState;
|
|
17527
|
-
}
|
|
17528
|
-
function useSearchTermState() {
|
|
17529
|
-
var _React$useContext5 = useContext(PickerContext),
|
|
17530
|
-
searchTerm = _React$useContext5.searchTerm;
|
|
17531
|
-
return searchTerm;
|
|
17532
|
-
}
|
|
17533
|
-
function useActiveSkinToneState() {
|
|
17534
|
-
var _React$useContext6 = useContext(PickerContext),
|
|
17535
|
-
activeSkinTone = _React$useContext6.activeSkinTone;
|
|
17536
|
-
return activeSkinTone;
|
|
17537
|
-
}
|
|
17538
|
-
function useEmojisThatFailedToLoadState() {
|
|
17539
|
-
var _React$useContext7 = useContext(PickerContext),
|
|
17540
|
-
emojisThatFailedToLoadState = _React$useContext7.emojisThatFailedToLoadState;
|
|
17541
|
-
return emojisThatFailedToLoadState;
|
|
17542
|
-
}
|
|
17543
|
-
function useIsPastInitialLoad() {
|
|
17544
|
-
var _React$useContext8 = useContext(PickerContext),
|
|
17545
|
-
isPastInitialLoad = _React$useContext8.isPastInitialLoad;
|
|
17546
|
-
return isPastInitialLoad;
|
|
17547
|
-
}
|
|
17548
|
-
function useEmojiVariationPickerState() {
|
|
17549
|
-
var _React$useContext9 = useContext(PickerContext),
|
|
17550
|
-
emojiVariationPickerState = _React$useContext9.emojiVariationPickerState;
|
|
17551
|
-
return emojiVariationPickerState;
|
|
17552
|
-
}
|
|
17553
|
-
function useSkinToneFanOpenState() {
|
|
17554
|
-
var _React$useContext10 = useContext(PickerContext),
|
|
17555
|
-
skinToneFanOpenState = _React$useContext10.skinToneFanOpenState;
|
|
17556
|
-
return skinToneFanOpenState;
|
|
17557
|
-
}
|
|
17558
|
-
function useUpdateSuggested() {
|
|
17559
|
-
var _React$useContext12 = useContext(PickerContext),
|
|
17560
|
-
suggestedUpdateState = _React$useContext12.suggestedUpdateState;
|
|
17561
|
-
var suggestedUpdated = suggestedUpdateState[0],
|
|
17562
|
-
setsuggestedUpdate = suggestedUpdateState[1];
|
|
17563
|
-
return [suggestedUpdated, function updateSuggested() {
|
|
17564
|
-
setsuggestedUpdate(Date.now());
|
|
17565
|
-
}];
|
|
17566
|
-
}
|
|
17567
|
-
|
|
17568
17630
|
var MutableConfigContext = /*#__PURE__*/React__default.createContext({});
|
|
17569
17631
|
function useMutableConfig() {
|
|
17570
17632
|
var mutableConfig = React__default.useContext(MutableConfigContext);
|
|
@@ -17799,6 +17861,7 @@ function ElementRefContextProvider(_ref) {
|
|
|
17799
17861
|
var PickerMainRef = useRef(null);
|
|
17800
17862
|
var AnchoredEmojiRef = useRef(null);
|
|
17801
17863
|
var BodyRef = useRef(null);
|
|
17864
|
+
var EmojiListRef = useRef(null);
|
|
17802
17865
|
var SearchInputRef = useRef(null);
|
|
17803
17866
|
var SkinTonePickerRef = useRef(null);
|
|
17804
17867
|
var CategoryNavigationRef = useRef(null);
|
|
@@ -17808,6 +17871,7 @@ function ElementRefContextProvider(_ref) {
|
|
|
17808
17871
|
value: {
|
|
17809
17872
|
AnchoredEmojiRef: AnchoredEmojiRef,
|
|
17810
17873
|
BodyRef: BodyRef,
|
|
17874
|
+
EmojiListRef: EmojiListRef,
|
|
17811
17875
|
CategoryNavigationRef: CategoryNavigationRef,
|
|
17812
17876
|
PickerMainRef: PickerMainRef,
|
|
17813
17877
|
SearchInputRef: SearchInputRef,
|
|
@@ -17821,6 +17885,7 @@ var ElementRefContext = /*#__PURE__*/createContext({
|
|
|
17821
17885
|
AnchoredEmojiRef: /*#__PURE__*/createRef(),
|
|
17822
17886
|
BodyRef: /*#__PURE__*/createRef(),
|
|
17823
17887
|
CategoryNavigationRef: /*#__PURE__*/createRef(),
|
|
17888
|
+
EmojiListRef: /*#__PURE__*/createRef(),
|
|
17824
17889
|
PickerMainRef: /*#__PURE__*/createRef(),
|
|
17825
17890
|
SearchInputRef: /*#__PURE__*/createRef(),
|
|
17826
17891
|
SkinTonePickerRef: /*#__PURE__*/createRef(),
|
|
@@ -17830,6 +17895,9 @@ var ElementRefContext = /*#__PURE__*/createContext({
|
|
|
17830
17895
|
function useElementRef() {
|
|
17831
17896
|
return useContext(ElementRefContext);
|
|
17832
17897
|
}
|
|
17898
|
+
function useEmojiListRef() {
|
|
17899
|
+
return useElementRef()['EmojiListRef'];
|
|
17900
|
+
}
|
|
17833
17901
|
function usePickerMainRef() {
|
|
17834
17902
|
return useElementRef()['PickerMainRef'];
|
|
17835
17903
|
}
|
|
@@ -17966,38 +18034,67 @@ function visibleEmojiOneRowUp(element) {
|
|
|
17966
18034
|
}
|
|
17967
18035
|
var categoryContent = closestCategoryContent(element);
|
|
17968
18036
|
var category = closestCategory(categoryContent);
|
|
17969
|
-
var indexInRow = elementIndexInRow(categoryContent, element);
|
|
17970
|
-
var row = rowNumber(categoryContent, element);
|
|
17971
18037
|
var countInRow = elementCountInRow(categoryContent, element);
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
18038
|
+
var emojisInCurrentCategory = allVisibleEmojis(category);
|
|
18039
|
+
var currentEmojiIndex = emojisInCurrentCategory.indexOf(element);
|
|
18040
|
+
var indexInRow = currentEmojiIndex % countInRow;
|
|
18041
|
+
if (currentEmojiIndex === -1) {
|
|
18042
|
+
return null;
|
|
18043
|
+
}
|
|
18044
|
+
if (emojisInCurrentCategory[currentEmojiIndex - countInRow]) {
|
|
18045
|
+
return emojisInCurrentCategory[currentEmojiIndex - countInRow];
|
|
18046
|
+
}
|
|
18047
|
+
var prevVisibleCategory = prevCategory(category);
|
|
18048
|
+
if (!prevVisibleCategory) {
|
|
18049
|
+
return null;
|
|
18050
|
+
}
|
|
18051
|
+
var allPrevEmojis = allVisibleEmojis(prevVisibleCategory);
|
|
18052
|
+
// if there is an emoji in the same index of `indexInRow` in the previous category, return it
|
|
18053
|
+
// for this we need to find the last emoji in the previous category that shares the same indexInRow
|
|
18054
|
+
// this is by using the % operator to find the last emoji that matches
|
|
18055
|
+
var lastIndexInRow = allPrevEmojis.length % countInRow - 1;
|
|
18056
|
+
if (indexInRow > lastIndexInRow) {
|
|
18057
|
+
return allPrevEmojis.at(-1);
|
|
18058
|
+
}
|
|
18059
|
+
// otherwise, return the last emoji that shares the same indexInRow
|
|
18060
|
+
for (var i = allPrevEmojis.length - 1; i >= 0; i--) {
|
|
18061
|
+
if (i % countInRow === indexInRow) {
|
|
18062
|
+
return allPrevEmojis[i];
|
|
17976
18063
|
}
|
|
17977
|
-
return getElementInRow(allVisibleEmojis(prevVisibleCategory), -1,
|
|
17978
|
-
// last row
|
|
17979
|
-
countInRow, indexInRow);
|
|
17980
18064
|
}
|
|
17981
|
-
return
|
|
18065
|
+
return allPrevEmojis.at(-1);
|
|
17982
18066
|
}
|
|
17983
18067
|
function visibleEmojiOneRowDown(element) {
|
|
18068
|
+
var _emojisInNextCategory;
|
|
17984
18069
|
if (!element) {
|
|
17985
18070
|
return null;
|
|
17986
18071
|
}
|
|
17987
18072
|
var categoryContent = closestCategoryContent(element);
|
|
17988
18073
|
var category = closestCategory(categoryContent);
|
|
17989
|
-
var indexInRow = elementIndexInRow(categoryContent, element);
|
|
17990
|
-
var row = rowNumber(categoryContent, element);
|
|
17991
18074
|
var countInRow = elementCountInRow(categoryContent, element);
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
18075
|
+
var emojisInCurrentCategory = allVisibleEmojis(category);
|
|
18076
|
+
var currentEmojiIndex = emojisInCurrentCategory.indexOf(element);
|
|
18077
|
+
if (currentEmojiIndex === -1) {
|
|
18078
|
+
return null;
|
|
18079
|
+
}
|
|
18080
|
+
// the remainder until the end of the row
|
|
18081
|
+
var remainder = countInRow - currentEmojiIndex % countInRow - 1;
|
|
18082
|
+
var firstInNextRow = currentEmojiIndex + remainder + 1;
|
|
18083
|
+
if (emojisInCurrentCategory[firstInNextRow]) {
|
|
18084
|
+
// if we have a next row, search in the next row for the last available emoji
|
|
18085
|
+
for (var p = currentEmojiIndex + countInRow; p % countInRow >= 0; p--) {
|
|
18086
|
+
if (emojisInCurrentCategory[p]) {
|
|
18087
|
+
return emojisInCurrentCategory[p];
|
|
18088
|
+
}
|
|
17996
18089
|
}
|
|
17997
|
-
return getElementInRow(allVisibleEmojis(nextVisibleCategory), 0, countInRow, indexInRow);
|
|
17998
18090
|
}
|
|
17999
|
-
var
|
|
18000
|
-
|
|
18091
|
+
var indexInRow = currentEmojiIndex % countInRow;
|
|
18092
|
+
var nextVisibleCategory = nextCategory(category);
|
|
18093
|
+
var emojisInNextCategory = allVisibleEmojis(nextVisibleCategory);
|
|
18094
|
+
if (emojisInNextCategory[indexInRow]) {
|
|
18095
|
+
return emojisInNextCategory[indexInRow];
|
|
18096
|
+
}
|
|
18097
|
+
return (_emojisInNextCategory = emojisInNextCategory.at(0)) != null ? _emojisInNextCategory : null;
|
|
18001
18098
|
}
|
|
18002
18099
|
|
|
18003
18100
|
function useCloseAllOpenToggles() {
|
|
@@ -18065,19 +18162,6 @@ function useOnMouseMove() {
|
|
|
18065
18162
|
}, [BodyRef, allowMouseMove, isMouseDisallowed]);
|
|
18066
18163
|
}
|
|
18067
18164
|
|
|
18068
|
-
function doesBrowserSupportCssHas() {
|
|
18069
|
-
// if env is not browser:
|
|
18070
|
-
if (typeof window === 'undefined' || typeof window.CSS === 'undefined') {
|
|
18071
|
-
return false;
|
|
18072
|
-
}
|
|
18073
|
-
try {
|
|
18074
|
-
return CSS.supports('selector(:has(*))');
|
|
18075
|
-
} catch (e) {
|
|
18076
|
-
return false;
|
|
18077
|
-
}
|
|
18078
|
-
}
|
|
18079
|
-
var browserSupportsCssHas = /*#__PURE__*/doesBrowserSupportCssHas();
|
|
18080
|
-
|
|
18081
18165
|
function useFocusSearchInput() {
|
|
18082
18166
|
var SearchInputRef = useSearchInputRef();
|
|
18083
18167
|
return useCallback(function () {
|
|
@@ -18151,27 +18235,22 @@ function useFilter() {
|
|
|
18151
18235
|
statusSearchResults: statusSearchResults
|
|
18152
18236
|
};
|
|
18153
18237
|
function onChange(inputValue) {
|
|
18154
|
-
|
|
18155
|
-
|
|
18238
|
+
var filter = filterRef.current;
|
|
18239
|
+
var nextValue = inputValue.toLowerCase();
|
|
18240
|
+
if (filter != null && filter[nextValue] || nextValue.length <= 1) {
|
|
18241
|
+
return applySearch(nextValue);
|
|
18156
18242
|
}
|
|
18157
|
-
|
|
18158
|
-
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
// If so, we need to search among all emojis
|
|
18167
|
-
return applySearch(nextValue);
|
|
18168
|
-
}
|
|
18169
|
-
setFilterRef(function (current) {
|
|
18170
|
-
var _Object$assign;
|
|
18171
|
-
return Object.assign(current, (_Object$assign = {}, _Object$assign[nextValue] = filterEmojiObjectByKeyword(longestMatch, nextValue), _Object$assign));
|
|
18172
|
-
});
|
|
18173
|
-
applySearch(nextValue);
|
|
18243
|
+
var longestMatch = findLongestMatch(nextValue, filter);
|
|
18244
|
+
if (!longestMatch) {
|
|
18245
|
+
// Can we even get here?
|
|
18246
|
+
// If so, we need to search among all emojis
|
|
18247
|
+
return applySearch(nextValue);
|
|
18248
|
+
}
|
|
18249
|
+
setFilterRef(function (current) {
|
|
18250
|
+
var _Object$assign;
|
|
18251
|
+
return Object.assign(current, (_Object$assign = {}, _Object$assign[nextValue] = filterEmojiObjectByKeyword(longestMatch, nextValue), _Object$assign));
|
|
18174
18252
|
});
|
|
18253
|
+
applySearch(nextValue);
|
|
18175
18254
|
}
|
|
18176
18255
|
}
|
|
18177
18256
|
function useApplySearch() {
|
|
@@ -18615,22 +18694,44 @@ function hasModifier(event) {
|
|
|
18615
18694
|
return metaKey || ctrlKey || altKey;
|
|
18616
18695
|
}
|
|
18617
18696
|
|
|
18618
|
-
|
|
18697
|
+
// eslint-disable-next-line max-params
|
|
18698
|
+
function preloaEmojidIfNeeded(emoji, emojiStyles, scrollTop, clientHeight, topOffset, style, dimensions, getEmojiUrl) {
|
|
18619
18699
|
if (!emoji) {
|
|
18620
18700
|
return;
|
|
18621
18701
|
}
|
|
18622
|
-
if (
|
|
18702
|
+
if (emojiStyles === EmojiStyle.NATIVE) {
|
|
18703
|
+
return;
|
|
18704
|
+
}
|
|
18705
|
+
var unified = emojiUnified(emoji);
|
|
18706
|
+
if (preloadedEmojs.has(unified)) {
|
|
18707
|
+
return;
|
|
18708
|
+
}
|
|
18709
|
+
// preload only if the emoji is a few rows below the viewport
|
|
18710
|
+
if (!style || !dimensions) {
|
|
18711
|
+
return;
|
|
18712
|
+
}
|
|
18713
|
+
setTimeout(function () {
|
|
18714
|
+
var emojiTop = topOffset + style.top;
|
|
18715
|
+
var viewportBottom = scrollTop + clientHeight;
|
|
18716
|
+
var isJustBelowViewport = emojiTop >= viewportBottom && emojiTop < viewportBottom + dimensions.emojiSize * 2;
|
|
18717
|
+
if (isJustBelowViewport) {
|
|
18718
|
+
preloadEmoji(getEmojiUrl, emoji, emojiStyles);
|
|
18719
|
+
}
|
|
18720
|
+
});
|
|
18721
|
+
}
|
|
18722
|
+
function preloadEmoji(getEmojiUrl, emoji, emojiStyle) {
|
|
18723
|
+
if (!emoji) {
|
|
18623
18724
|
return;
|
|
18624
18725
|
}
|
|
18625
18726
|
var unified = emojiUnified(emoji);
|
|
18626
18727
|
if (preloadedEmojs.has(unified)) {
|
|
18627
18728
|
return;
|
|
18628
18729
|
}
|
|
18629
|
-
|
|
18730
|
+
preloadedEmojs.add(unified);
|
|
18731
|
+
emojiVariations(emoji).concat(unified).forEach(function (variation) {
|
|
18630
18732
|
var emojiUrl = getEmojiUrl(variation, emojiStyle);
|
|
18631
18733
|
preloadImage(emojiUrl);
|
|
18632
18734
|
});
|
|
18633
|
-
preloadedEmojs.add(unified);
|
|
18634
18735
|
}
|
|
18635
18736
|
var preloadedEmojs = /*#__PURE__*/new Set();
|
|
18636
18737
|
function preloadImage(url) {
|
|
@@ -18730,7 +18831,7 @@ var styles = /*#__PURE__*/stylesheet.create({
|
|
|
18730
18831
|
borderColor: 'var(--epr-picker-border-color)',
|
|
18731
18832
|
backgroundColor: 'var(--epr-bg-color)',
|
|
18732
18833
|
overflow: 'hidden',
|
|
18733
|
-
transition: '
|
|
18834
|
+
transition: 'height 0.3s ease-in-out, background-color 0.1s ease-in-out',
|
|
18734
18835
|
'*': {
|
|
18735
18836
|
boxSizing: 'border-box',
|
|
18736
18837
|
fontFamily: 'sans-serif'
|
|
@@ -18850,65 +18951,6 @@ function elementCountInRow(parent, element) {
|
|
|
18850
18951
|
var elementWidth = element.getBoundingClientRect().width;
|
|
18851
18952
|
return Math.floor(parentWidth / elementWidth);
|
|
18852
18953
|
}
|
|
18853
|
-
function elementIndexInRow(parent, element) {
|
|
18854
|
-
if (!parent || !element) {
|
|
18855
|
-
return 0;
|
|
18856
|
-
}
|
|
18857
|
-
var elementWidth = element.getBoundingClientRect().width;
|
|
18858
|
-
var elementLeft = element.getBoundingClientRect().left;
|
|
18859
|
-
var parentLeft = parent.getBoundingClientRect().left;
|
|
18860
|
-
return Math.floor((elementLeft - parentLeft) / elementWidth);
|
|
18861
|
-
}
|
|
18862
|
-
function rowNumber(parent, element) {
|
|
18863
|
-
if (!parent || !element) {
|
|
18864
|
-
return 0;
|
|
18865
|
-
}
|
|
18866
|
-
var elementHeight = element.getBoundingClientRect().height;
|
|
18867
|
-
var elementTop = element.getBoundingClientRect().top;
|
|
18868
|
-
var parentTop = parent.getBoundingClientRect().top;
|
|
18869
|
-
return Math.round((elementTop - parentTop) / elementHeight);
|
|
18870
|
-
}
|
|
18871
|
-
function hasNextRow(parent, element) {
|
|
18872
|
-
if (!parent || !element) {
|
|
18873
|
-
return false;
|
|
18874
|
-
}
|
|
18875
|
-
var elementHeight = element.getBoundingClientRect().height;
|
|
18876
|
-
var elementTop = element.getBoundingClientRect().top;
|
|
18877
|
-
var parentTop = parent.getBoundingClientRect().top;
|
|
18878
|
-
var parentHeight = parent.getBoundingClientRect().height;
|
|
18879
|
-
return Math.round(elementTop - parentTop + elementHeight) < parentHeight;
|
|
18880
|
-
}
|
|
18881
|
-
function getRowElements(elements, row, elementsInRow) {
|
|
18882
|
-
if (row === -1) {
|
|
18883
|
-
var lastRow = Math.floor((elements.length - 1) / elementsInRow);
|
|
18884
|
-
var firstElementIndex = lastRow * elementsInRow;
|
|
18885
|
-
var lastElementIndex = elements.length - 1;
|
|
18886
|
-
return elements.slice(firstElementIndex, lastElementIndex + 1);
|
|
18887
|
-
}
|
|
18888
|
-
return elements.slice(row * elementsInRow, (row + 1) * elementsInRow);
|
|
18889
|
-
}
|
|
18890
|
-
function getNextRowElements(allElements, currentRow, elementsInRow) {
|
|
18891
|
-
var nextRow = currentRow + 1;
|
|
18892
|
-
if (nextRow * elementsInRow > allElements.length) {
|
|
18893
|
-
return [];
|
|
18894
|
-
}
|
|
18895
|
-
return getRowElements(allElements, nextRow, elementsInRow);
|
|
18896
|
-
}
|
|
18897
|
-
function getElementInRow(elements, row, elementsInRow, indexInRow) {
|
|
18898
|
-
var rowElements = getRowElements(elements, row, elementsInRow);
|
|
18899
|
-
// get element, default to last
|
|
18900
|
-
return rowElements[indexInRow] || rowElements[rowElements.length - 1] || null;
|
|
18901
|
-
}
|
|
18902
|
-
function getElementInNextRow(allElements, currentRow, elementsInRow, index) {
|
|
18903
|
-
var nextRowElements = getNextRowElements(allElements, currentRow, elementsInRow);
|
|
18904
|
-
// return item in index, or last item in row
|
|
18905
|
-
return nextRowElements[index] || nextRowElements[nextRowElements.length - 1] || null;
|
|
18906
|
-
}
|
|
18907
|
-
function getElementInPrevRow(allElements, currentRow, elementsInRow, index) {
|
|
18908
|
-
var prevRowElements = getRowElements(allElements, currentRow - 1, elementsInRow);
|
|
18909
|
-
// default to last
|
|
18910
|
-
return prevRowElements[index] || prevRowElements[prevRowElements.length - 1] || null;
|
|
18911
|
-
}
|
|
18912
18954
|
function firstVisibleElementInContainer(parent, elements, maxVisibilityDiffThreshold) {
|
|
18913
18955
|
if (maxVisibilityDiffThreshold === void 0) {
|
|
18914
18956
|
maxVisibilityDiffThreshold = 0;
|
|
@@ -18936,15 +18978,17 @@ function hasNextElementSibling(element) {
|
|
|
18936
18978
|
return !!element.nextElementSibling;
|
|
18937
18979
|
}
|
|
18938
18980
|
function getLabelHeight(parentNode) {
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18981
|
+
if (!parentNode) {
|
|
18982
|
+
return DEFAULT_LABEL_HEIGHT;
|
|
18983
|
+
}
|
|
18984
|
+
var label = parentNode.querySelector(asSelectors(ClassNames.label));
|
|
18985
|
+
if (label) {
|
|
18942
18986
|
var height = label.getBoundingClientRect().height;
|
|
18943
|
-
// return height if label is not hidden
|
|
18944
18987
|
if (height > 0) {
|
|
18945
18988
|
return height;
|
|
18946
18989
|
}
|
|
18947
18990
|
}
|
|
18991
|
+
// fallback to default
|
|
18948
18992
|
return DEFAULT_LABEL_HEIGHT;
|
|
18949
18993
|
}
|
|
18950
18994
|
|
|
@@ -19160,56 +19204,6 @@ function parseNativeEmoji(unified) {
|
|
|
19160
19204
|
}).join('');
|
|
19161
19205
|
}
|
|
19162
19206
|
|
|
19163
|
-
var SUGGESTED_LS_KEY = 'epr_suggested';
|
|
19164
|
-
function getSuggested(mode) {
|
|
19165
|
-
try {
|
|
19166
|
-
var _window, _window$localStorage$, _window2;
|
|
19167
|
-
if (!((_window = window) != null && _window.localStorage)) {
|
|
19168
|
-
return [];
|
|
19169
|
-
}
|
|
19170
|
-
var recent = JSON.parse((_window$localStorage$ = (_window2 = window) == null ? void 0 : _window2.localStorage.getItem(SUGGESTED_LS_KEY)) != null ? _window$localStorage$ : '[]');
|
|
19171
|
-
if (mode === SuggestionMode.FREQUENT) {
|
|
19172
|
-
return recent.sort(function (a, b) {
|
|
19173
|
-
return b.count - a.count;
|
|
19174
|
-
});
|
|
19175
|
-
}
|
|
19176
|
-
return recent;
|
|
19177
|
-
} catch (_unused) {
|
|
19178
|
-
return [];
|
|
19179
|
-
}
|
|
19180
|
-
}
|
|
19181
|
-
function setSuggested(emoji, skinTone) {
|
|
19182
|
-
var recent = getSuggested();
|
|
19183
|
-
var unified = emojiUnified(emoji, skinTone);
|
|
19184
|
-
var originalUnified = emojiUnified(emoji);
|
|
19185
|
-
var existing = recent.find(function (_ref) {
|
|
19186
|
-
var u = _ref.unified;
|
|
19187
|
-
return u === unified;
|
|
19188
|
-
});
|
|
19189
|
-
var nextList;
|
|
19190
|
-
if (existing) {
|
|
19191
|
-
nextList = [existing].concat(recent.filter(function (i) {
|
|
19192
|
-
return i !== existing;
|
|
19193
|
-
}));
|
|
19194
|
-
} else {
|
|
19195
|
-
existing = {
|
|
19196
|
-
unified: unified,
|
|
19197
|
-
original: originalUnified,
|
|
19198
|
-
count: 0
|
|
19199
|
-
};
|
|
19200
|
-
nextList = [existing].concat(recent);
|
|
19201
|
-
}
|
|
19202
|
-
existing.count++;
|
|
19203
|
-
nextList.length = Math.min(nextList.length, 14);
|
|
19204
|
-
try {
|
|
19205
|
-
var _window3;
|
|
19206
|
-
(_window3 = window) == null ? void 0 : _window3.localStorage.setItem(SUGGESTED_LS_KEY, JSON.stringify(nextList));
|
|
19207
|
-
// Prevents the change from being seen immediately.
|
|
19208
|
-
} catch (_unused2) {
|
|
19209
|
-
// ignore
|
|
19210
|
-
}
|
|
19211
|
-
}
|
|
19212
|
-
|
|
19213
19207
|
function isCustomCategory(category) {
|
|
19214
19208
|
return category.category === Categories.CUSTOM;
|
|
19215
19209
|
}
|
|
@@ -19372,12 +19366,14 @@ function ClickableEmojiButton(_ref) {
|
|
|
19372
19366
|
children = _ref.children,
|
|
19373
19367
|
className = _ref.className,
|
|
19374
19368
|
_ref$noBackground = _ref.noBackground,
|
|
19375
|
-
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground
|
|
19369
|
+
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground,
|
|
19370
|
+
style = _ref.style;
|
|
19376
19371
|
return createElement(Button, {
|
|
19377
19372
|
className: cx(styles$2.emoji, hidden && commonStyles.hidden, hiddenOnSearch && commonInteractionStyles.hiddenOnSearch, (_cx = {}, _cx[ClassNames.visible] = !hidden && !hiddenOnSearch, _cx), !!(hasVariations && showVariations) && styles$2.hasVariations, noBackground && styles$2.noBackground, className),
|
|
19378
19373
|
"data-unified": unified,
|
|
19379
19374
|
"aria-label": getAriaLabel(emojiNames),
|
|
19380
|
-
"data-full-name": emojiNames
|
|
19375
|
+
"data-full-name": emojiNames,
|
|
19376
|
+
style: style
|
|
19381
19377
|
}, children);
|
|
19382
19378
|
}
|
|
19383
19379
|
function getAriaLabel(emojiNames) {
|
|
@@ -19567,7 +19563,8 @@ function ClickableEmoji(_ref) {
|
|
|
19567
19563
|
getEmojiUrl = _ref.getEmojiUrl,
|
|
19568
19564
|
className = _ref.className,
|
|
19569
19565
|
_ref$noBackground = _ref.noBackground,
|
|
19570
|
-
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground
|
|
19566
|
+
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground,
|
|
19567
|
+
style = _ref.style;
|
|
19571
19568
|
var hasVariations = emojiHasVariations(emoji);
|
|
19572
19569
|
return createElement(ClickableEmojiButton, {
|
|
19573
19570
|
hasVariations: hasVariations,
|
|
@@ -19576,7 +19573,8 @@ function ClickableEmoji(_ref) {
|
|
|
19576
19573
|
hiddenOnSearch: hiddenOnSearch,
|
|
19577
19574
|
emojiNames: emojiNames(emoji),
|
|
19578
19575
|
unified: unified,
|
|
19579
|
-
noBackground: noBackground
|
|
19576
|
+
noBackground: noBackground,
|
|
19577
|
+
style: style
|
|
19580
19578
|
}, createElement(ViewOnlyEmoji, {
|
|
19581
19579
|
unified: unified,
|
|
19582
19580
|
emoji: emoji,
|
|
@@ -19706,6 +19704,9 @@ var styles$6 = /*#__PURE__*/stylesheet.create({
|
|
|
19706
19704
|
|
|
19707
19705
|
function useOnScroll(BodyRef) {
|
|
19708
19706
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
19707
|
+
var _useState = useState(0),
|
|
19708
|
+
scrollTop = _useState[0],
|
|
19709
|
+
setScrollTop = _useState[1];
|
|
19709
19710
|
useEffect(function () {
|
|
19710
19711
|
var bodyRef = BodyRef.current;
|
|
19711
19712
|
if (!bodyRef) {
|
|
@@ -19715,12 +19716,99 @@ function useOnScroll(BodyRef) {
|
|
|
19715
19716
|
passive: true
|
|
19716
19717
|
});
|
|
19717
19718
|
function onScroll() {
|
|
19719
|
+
var _bodyRef$scrollTop;
|
|
19720
|
+
setScrollTop((_bodyRef$scrollTop = bodyRef == null ? void 0 : bodyRef.scrollTop) != null ? _bodyRef$scrollTop : 0);
|
|
19718
19721
|
closeAllOpenToggles();
|
|
19719
19722
|
}
|
|
19720
19723
|
return function () {
|
|
19721
19724
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('scroll', onScroll);
|
|
19722
19725
|
};
|
|
19723
19726
|
}, [BodyRef, closeAllOpenToggles]);
|
|
19727
|
+
return scrollTop;
|
|
19728
|
+
}
|
|
19729
|
+
|
|
19730
|
+
function shouldVirtualize(_ref) {
|
|
19731
|
+
var scrollTop = _ref.scrollTop,
|
|
19732
|
+
clientHeight = _ref.clientHeight,
|
|
19733
|
+
topOffset = _ref.topOffset,
|
|
19734
|
+
style = _ref.style,
|
|
19735
|
+
dimensions = _ref.dimensions;
|
|
19736
|
+
if (!style || !dimensions) {
|
|
19737
|
+
return false;
|
|
19738
|
+
}
|
|
19739
|
+
var emojiTop = topOffset + style.top;
|
|
19740
|
+
var emojiBottom = emojiTop + dimensions.emojiSize;
|
|
19741
|
+
var isVisible = emojiBottom + dimensions.emojiSize * 2 >= scrollTop && emojiTop <= scrollTop + clientHeight + dimensions.emojiSize;
|
|
19742
|
+
return !isVisible;
|
|
19743
|
+
}
|
|
19744
|
+
function getEmojiPositionStyle(dimensions, index) {
|
|
19745
|
+
return dimensions ? {
|
|
19746
|
+
top: Math.floor(index / dimensions.emojisPerRow) * dimensions.emojiSize,
|
|
19747
|
+
left: index % dimensions.emojisPerRow * dimensions.emojiSize
|
|
19748
|
+
} : undefined;
|
|
19749
|
+
}
|
|
19750
|
+
|
|
19751
|
+
var EMOJI_SIZE_DEFAULT = 32;
|
|
19752
|
+
function useCategoryHeight(emojiCount) {
|
|
19753
|
+
var EmojiListRef = useEmojiListRef();
|
|
19754
|
+
var _useReactionsModeStat = useReactionsModeState(),
|
|
19755
|
+
isReactionsMode = _useReactionsModeStat[0];
|
|
19756
|
+
var PickerMainRef = usePickerMainRef();
|
|
19757
|
+
var emojiSizeRef = useRef();
|
|
19758
|
+
var _React$useState = useState(),
|
|
19759
|
+
dimensions = _React$useState[0],
|
|
19760
|
+
setDimensions = _React$useState[1];
|
|
19761
|
+
// Helper to compute and store dimensions based on current DOM
|
|
19762
|
+
var computeAndSetDimensions = useCallback(function () {
|
|
19763
|
+
var _ref;
|
|
19764
|
+
var listEl = EmojiListRef.current;
|
|
19765
|
+
if (!listEl) return;
|
|
19766
|
+
var emojiElement = listEl.querySelector(EmojiButtonSelector);
|
|
19767
|
+
var measured = emojiElement == null ? void 0 : emojiElement.clientHeight;
|
|
19768
|
+
var emojiSize = (_ref = measured != null ? measured : emojiSizeRef.current) != null ? _ref : EMOJI_SIZE_DEFAULT;
|
|
19769
|
+
emojiSizeRef.current = emojiSize;
|
|
19770
|
+
var pickerWidth = listEl.clientWidth;
|
|
19771
|
+
if (pickerWidth === 0 || emojiSize === 0) return;
|
|
19772
|
+
var emojisPerRow = Math.max(1, Math.floor(pickerWidth / emojiSize));
|
|
19773
|
+
var rowCount = Math.ceil(emojiCount / emojisPerRow);
|
|
19774
|
+
var categoryHeight = rowCount * emojiSize;
|
|
19775
|
+
setDimensions({
|
|
19776
|
+
categoryHeight: categoryHeight,
|
|
19777
|
+
emojisPerRow: emojisPerRow,
|
|
19778
|
+
emojiSize: emojiSize
|
|
19779
|
+
});
|
|
19780
|
+
}, [EmojiListRef, emojiCount]);
|
|
19781
|
+
// Recompute on data-count changes and when reactions mode toggles
|
|
19782
|
+
useEffect(function () {
|
|
19783
|
+
computeAndSetDimensions();
|
|
19784
|
+
}, [emojiCount, isReactionsMode, computeAndSetDimensions]);
|
|
19785
|
+
// Listen to transitionend on the picker root (where height transition occurs)
|
|
19786
|
+
useEffect(function () {
|
|
19787
|
+
var rootEl = PickerMainRef.current;
|
|
19788
|
+
if (!rootEl) return;
|
|
19789
|
+
var handler = function handler(e) {
|
|
19790
|
+
var te = e;
|
|
19791
|
+
var prop = te.propertyName;
|
|
19792
|
+
if (prop === 'width' || prop === 'max-width' || prop === 'min-width' || prop === 'height' || prop === 'max-height' || prop === 'min-height') {
|
|
19793
|
+
if (typeof queueMicrotask === 'function') {
|
|
19794
|
+
queueMicrotask(function () {
|
|
19795
|
+
return computeAndSetDimensions();
|
|
19796
|
+
});
|
|
19797
|
+
} else {
|
|
19798
|
+
requestAnimationFrame(function () {
|
|
19799
|
+
return computeAndSetDimensions();
|
|
19800
|
+
});
|
|
19801
|
+
}
|
|
19802
|
+
}
|
|
19803
|
+
};
|
|
19804
|
+
rootEl.addEventListener('transitionend', handler, {
|
|
19805
|
+
passive: true
|
|
19806
|
+
});
|
|
19807
|
+
return function () {
|
|
19808
|
+
rootEl.removeEventListener('transitionend', handler);
|
|
19809
|
+
};
|
|
19810
|
+
}, [PickerMainRef, computeAndSetDimensions]);
|
|
19811
|
+
return dimensions;
|
|
19724
19812
|
}
|
|
19725
19813
|
|
|
19726
19814
|
function useIsEmojiHidden() {
|
|
@@ -19739,11 +19827,78 @@ function useIsEmojiHidden() {
|
|
|
19739
19827
|
};
|
|
19740
19828
|
}
|
|
19741
19829
|
|
|
19830
|
+
function useEmojiVirtualization(_ref) {
|
|
19831
|
+
var categoryEmojis = _ref.categoryEmojis,
|
|
19832
|
+
topOffset = _ref.topOffset,
|
|
19833
|
+
onHeightReady = _ref.onHeightReady,
|
|
19834
|
+
scrollTop = _ref.scrollTop;
|
|
19835
|
+
var isEmojiHidden = useIsEmojiHidden();
|
|
19836
|
+
var lazyLoadEmojis = useLazyLoadEmojisConfig();
|
|
19837
|
+
var emojiStyle = useEmojiStyleConfig();
|
|
19838
|
+
var _useActiveSkinToneSta = useActiveSkinToneState(),
|
|
19839
|
+
activeSkinTone = _useActiveSkinToneSta[0];
|
|
19840
|
+
var isEmojiDisallowed = useIsEmojiDisallowed();
|
|
19841
|
+
var getEmojiUrl = useGetEmojiUrlConfig();
|
|
19842
|
+
var showVariations = !useSkinTonesDisabledConfig();
|
|
19843
|
+
var BodyRef = useBodyRef();
|
|
19844
|
+
var virtualizedCounter = 0;
|
|
19845
|
+
var emojisToPush = categoryEmojis.filter(function (emoji) {
|
|
19846
|
+
var isDisallowed = isEmojiDisallowed(emoji);
|
|
19847
|
+
var _isEmojiHidden = isEmojiHidden(emoji),
|
|
19848
|
+
failedToLoad = _isEmojiHidden.failedToLoad,
|
|
19849
|
+
filteredOut = _isEmojiHidden.filteredOut,
|
|
19850
|
+
hidden = _isEmojiHidden.hidden;
|
|
19851
|
+
return !failedToLoad && !filteredOut && !hidden && !isDisallowed;
|
|
19852
|
+
});
|
|
19853
|
+
var dimensions = useCategoryHeight(emojisToPush.length);
|
|
19854
|
+
useEffect(function () {
|
|
19855
|
+
if (dimensions) {
|
|
19856
|
+
onHeightReady(dimensions.categoryHeight);
|
|
19857
|
+
}
|
|
19858
|
+
}, [dimensions, onHeightReady, emojisToPush.length]);
|
|
19859
|
+
var emojis = emojisToPush.reduce(function (accumulator, emoji, index) {
|
|
19860
|
+
var _BodyRef$current$clie, _BodyRef$current;
|
|
19861
|
+
var unified = emojiUnified(emoji, activeSkinTone);
|
|
19862
|
+
var style = getEmojiPositionStyle(dimensions, index);
|
|
19863
|
+
if (dimensions && BodyRef.current && shouldVirtualize({
|
|
19864
|
+
scrollTop: scrollTop,
|
|
19865
|
+
clientHeight: (_BodyRef$current$clie = (_BodyRef$current = BodyRef.current) == null ? void 0 : _BodyRef$current.clientHeight) != null ? _BodyRef$current$clie : 0,
|
|
19866
|
+
topOffset: topOffset,
|
|
19867
|
+
style: style,
|
|
19868
|
+
dimensions: dimensions
|
|
19869
|
+
})) {
|
|
19870
|
+
var _BodyRef$current$clie2, _BodyRef$current2;
|
|
19871
|
+
virtualizedCounter++;
|
|
19872
|
+
preloaEmojidIfNeeded(emoji, emojiStyle, scrollTop, (_BodyRef$current$clie2 = (_BodyRef$current2 = BodyRef.current) == null ? void 0 : _BodyRef$current2.clientHeight) != null ? _BodyRef$current$clie2 : 0, topOffset, style, dimensions, getEmojiUrl);
|
|
19873
|
+
return accumulator;
|
|
19874
|
+
}
|
|
19875
|
+
accumulator.push(createElement(ClickableEmoji, {
|
|
19876
|
+
showVariations: showVariations,
|
|
19877
|
+
key: unified,
|
|
19878
|
+
emoji: emoji,
|
|
19879
|
+
unified: unified,
|
|
19880
|
+
emojiStyle: emojiStyle,
|
|
19881
|
+
lazyLoad: lazyLoadEmojis,
|
|
19882
|
+
getEmojiUrl: getEmojiUrl,
|
|
19883
|
+
style: _extends({}, style, {
|
|
19884
|
+
position: 'absolute'
|
|
19885
|
+
})
|
|
19886
|
+
}));
|
|
19887
|
+
return accumulator;
|
|
19888
|
+
}, []);
|
|
19889
|
+
return {
|
|
19890
|
+
virtualizedCounter: virtualizedCounter,
|
|
19891
|
+
emojis: emojis,
|
|
19892
|
+
dimensions: dimensions
|
|
19893
|
+
};
|
|
19894
|
+
}
|
|
19895
|
+
|
|
19742
19896
|
function EmojiCategory(_ref) {
|
|
19743
19897
|
var categoryConfig = _ref.categoryConfig,
|
|
19744
19898
|
children = _ref.children,
|
|
19745
19899
|
hidden = _ref.hidden,
|
|
19746
|
-
hiddenOnSearch = _ref.hiddenOnSearch
|
|
19900
|
+
hiddenOnSearch = _ref.hiddenOnSearch,
|
|
19901
|
+
height = _ref.height;
|
|
19747
19902
|
var category = categoryFromCategoryConfig(categoryConfig);
|
|
19748
19903
|
var categoryName = categoryNameFromCategoryConfig(categoryConfig);
|
|
19749
19904
|
return createElement("li", {
|
|
@@ -19753,15 +19908,16 @@ function EmojiCategory(_ref) {
|
|
|
19753
19908
|
}, createElement("h2", {
|
|
19754
19909
|
className: cx(styles$7.label)
|
|
19755
19910
|
}, categoryName), createElement("div", {
|
|
19756
|
-
className: cx(styles$7.categoryContent)
|
|
19911
|
+
className: cx(styles$7.categoryContent),
|
|
19912
|
+
style: {
|
|
19913
|
+
height: height
|
|
19914
|
+
}
|
|
19757
19915
|
}, children));
|
|
19758
19916
|
}
|
|
19759
19917
|
var styles$7 = /*#__PURE__*/stylesheet.create({
|
|
19760
19918
|
category: {
|
|
19761
19919
|
'.': ClassNames.category,
|
|
19762
|
-
|
|
19763
|
-
display: 'none'
|
|
19764
|
-
}
|
|
19920
|
+
position: 'relative'
|
|
19765
19921
|
},
|
|
19766
19922
|
categoryContent: {
|
|
19767
19923
|
'.': ClassNames.categoryContent,
|
|
@@ -19793,131 +19949,65 @@ var styles$7 = /*#__PURE__*/stylesheet.create({
|
|
|
19793
19949
|
}
|
|
19794
19950
|
});
|
|
19795
19951
|
|
|
19796
|
-
|
|
19797
|
-
|
|
19798
|
-
var _React$useState = useState(isEverMounted),
|
|
19799
|
-
isMounted = _React$useState[0],
|
|
19800
|
-
setIsMounted = _React$useState[1];
|
|
19801
|
-
useEffect(function () {
|
|
19802
|
-
setIsMounted(true);
|
|
19803
|
-
isEverMounted = true;
|
|
19804
|
-
}, []);
|
|
19805
|
-
return isMounted || isEverMounted;
|
|
19806
|
-
}
|
|
19807
|
-
|
|
19808
|
-
function Suggested(_ref) {
|
|
19809
|
-
var categoryConfig = _ref.categoryConfig;
|
|
19810
|
-
var _useUpdateSuggested = useUpdateSuggested(),
|
|
19811
|
-
suggestedUpdated = _useUpdateSuggested[0];
|
|
19812
|
-
var isMounted = useIsEverMounted();
|
|
19813
|
-
var suggestedEmojisModeConfig = useSuggestedEmojisModeConfig();
|
|
19814
|
-
var getEmojiUrl = useGetEmojiUrlConfig();
|
|
19815
|
-
var suggested = useMemo(function () {
|
|
19816
|
-
var _getSuggested;
|
|
19817
|
-
return (_getSuggested = getSuggested(suggestedEmojisModeConfig)) != null ? _getSuggested : [];
|
|
19818
|
-
},
|
|
19819
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19820
|
-
[suggestedUpdated, suggestedEmojisModeConfig]);
|
|
19821
|
-
var emojiStyle = useEmojiStyleConfig();
|
|
19822
|
-
var isEmojiDisallowed = useIsEmojiDisallowed();
|
|
19823
|
-
if (!isMounted) {
|
|
19824
|
-
return null;
|
|
19825
|
-
}
|
|
19826
|
-
return createElement(EmojiCategory, {
|
|
19827
|
-
categoryConfig: categoryConfig,
|
|
19828
|
-
hiddenOnSearch: true,
|
|
19829
|
-
hidden: suggested.length === 0
|
|
19830
|
-
}, suggested.map(function (suggestedItem) {
|
|
19831
|
-
var emoji = emojiByUnified(suggestedItem.original);
|
|
19832
|
-
if (!emoji) {
|
|
19833
|
-
return null;
|
|
19834
|
-
}
|
|
19835
|
-
if (isEmojiDisallowed(emoji)) {
|
|
19836
|
-
return null;
|
|
19837
|
-
}
|
|
19838
|
-
return createElement(ClickableEmoji, {
|
|
19839
|
-
showVariations: false,
|
|
19840
|
-
unified: suggestedItem.unified,
|
|
19841
|
-
emojiStyle: emojiStyle,
|
|
19842
|
-
emoji: emoji,
|
|
19843
|
-
key: suggestedItem.unified,
|
|
19844
|
-
getEmojiUrl: getEmojiUrl
|
|
19845
|
-
});
|
|
19846
|
-
}));
|
|
19847
|
-
}
|
|
19848
|
-
|
|
19849
|
-
function EmojiList() {
|
|
19952
|
+
function EmojiList(_ref) {
|
|
19953
|
+
var scrollTop = _ref.scrollTop;
|
|
19850
19954
|
var categories = useCategoriesConfig();
|
|
19851
|
-
var
|
|
19955
|
+
var _React$useState = useState({}),
|
|
19956
|
+
categoryHeights = _React$useState[0],
|
|
19957
|
+
setCategoryHeights = _React$useState[1];
|
|
19958
|
+
var EmojiListRef = useEmojiListRef();
|
|
19959
|
+
var getEmojisByCategory = useGetEmojisByCategory();
|
|
19960
|
+
var labelHeight = getLabelHeight(EmojiListRef.current);
|
|
19961
|
+
var topOffset = 0;
|
|
19852
19962
|
return createElement("ul", {
|
|
19853
|
-
className: cx(styles$8.emojiList)
|
|
19963
|
+
className: cx(styles$8.emojiList),
|
|
19964
|
+
ref: EmojiListRef
|
|
19854
19965
|
}, categories.map(function (categoryConfig) {
|
|
19855
19966
|
var category = categoryFromCategoryConfig(categoryConfig);
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
});
|
|
19967
|
+
var currentOffset = topOffset;
|
|
19968
|
+
var categoryHeight = categoryHeights[category];
|
|
19969
|
+
if (categoryHeight) {
|
|
19970
|
+
topOffset += categoryHeight + labelHeight;
|
|
19861
19971
|
}
|
|
19862
19972
|
return createElement(Suspense, {
|
|
19863
19973
|
key: category
|
|
19864
19974
|
}, createElement(RenderCategory, {
|
|
19865
|
-
|
|
19975
|
+
categoryEmojis: getEmojisByCategory(category),
|
|
19866
19976
|
categoryConfig: categoryConfig,
|
|
19867
|
-
|
|
19977
|
+
topOffset: currentOffset,
|
|
19978
|
+
onHeightReady: function onHeightReady(height) {
|
|
19979
|
+
if (categoryHeights[category] !== height) {
|
|
19980
|
+
setCategoryHeights(function (prev) {
|
|
19981
|
+
var _extends2;
|
|
19982
|
+
return _extends({}, prev, (_extends2 = {}, _extends2[category] = height, _extends2));
|
|
19983
|
+
});
|
|
19984
|
+
}
|
|
19985
|
+
},
|
|
19986
|
+
scrollTop: scrollTop
|
|
19868
19987
|
}));
|
|
19869
19988
|
}));
|
|
19870
19989
|
}
|
|
19871
|
-
function RenderCategory(
|
|
19872
|
-
var
|
|
19873
|
-
categoryConfig =
|
|
19874
|
-
|
|
19875
|
-
|
|
19876
|
-
|
|
19877
|
-
var
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
var emojisToPush = !isPastInitialLoad && renderdCategoriesCountRef.current > 0 ? [] : emojisByCategory(category);
|
|
19887
|
-
if (emojisToPush.length > 0) {
|
|
19888
|
-
renderdCategoriesCountRef.current++;
|
|
19889
|
-
}
|
|
19890
|
-
var hiddenCounter = 0;
|
|
19891
|
-
var emojis = emojisToPush.map(function (emoji) {
|
|
19892
|
-
var unified = emojiUnified(emoji, activeSkinTone);
|
|
19893
|
-
var _isEmojiHidden = isEmojiHidden(emoji),
|
|
19894
|
-
failedToLoad = _isEmojiHidden.failedToLoad,
|
|
19895
|
-
filteredOut = _isEmojiHidden.filteredOut,
|
|
19896
|
-
hidden = _isEmojiHidden.hidden;
|
|
19897
|
-
var isDisallowed = isEmojiDisallowed(emoji);
|
|
19898
|
-
if (hidden || isDisallowed) {
|
|
19899
|
-
hiddenCounter++;
|
|
19900
|
-
}
|
|
19901
|
-
if (isDisallowed) {
|
|
19902
|
-
return null;
|
|
19903
|
-
}
|
|
19904
|
-
return createElement(ClickableEmoji, {
|
|
19905
|
-
showVariations: showVariations,
|
|
19906
|
-
key: unified,
|
|
19907
|
-
emoji: emoji,
|
|
19908
|
-
unified: unified,
|
|
19909
|
-
hidden: failedToLoad,
|
|
19910
|
-
hiddenOnSearch: filteredOut,
|
|
19911
|
-
emojiStyle: emojiStyle,
|
|
19912
|
-
lazyLoad: lazyLoadEmojis,
|
|
19913
|
-
getEmojiUrl: getEmojiUrl
|
|
19914
|
-
});
|
|
19915
|
-
});
|
|
19990
|
+
function RenderCategory(_ref2) {
|
|
19991
|
+
var categoryEmojis = _ref2.categoryEmojis,
|
|
19992
|
+
categoryConfig = _ref2.categoryConfig,
|
|
19993
|
+
topOffset = _ref2.topOffset,
|
|
19994
|
+
onHeightReady = _ref2.onHeightReady,
|
|
19995
|
+
scrollTop = _ref2.scrollTop;
|
|
19996
|
+
var _useEmojiVirtualizati = useEmojiVirtualization({
|
|
19997
|
+
categoryEmojis: categoryEmojis,
|
|
19998
|
+
topOffset: topOffset,
|
|
19999
|
+
onHeightReady: onHeightReady,
|
|
20000
|
+
scrollTop: scrollTop
|
|
20001
|
+
}),
|
|
20002
|
+
virtualizedCounter = _useEmojiVirtualizati.virtualizedCounter,
|
|
20003
|
+
emojis = _useEmojiVirtualizati.emojis,
|
|
20004
|
+
dimensions = _useEmojiVirtualizati.dimensions;
|
|
19916
20005
|
return createElement(EmojiCategory, {
|
|
19917
20006
|
categoryConfig: categoryConfig,
|
|
20007
|
+
height: dimensions == null ? void 0 : dimensions.categoryHeight,
|
|
19918
20008
|
// Indicates that there are no visible emojis
|
|
19919
20009
|
// Hence, the category should be hidden
|
|
19920
|
-
hidden:
|
|
20010
|
+
hidden: !emojis.length && virtualizedCounter === 0
|
|
19921
20011
|
}, emojis);
|
|
19922
20012
|
}
|
|
19923
20013
|
var styles$8 = /*#__PURE__*/stylesheet.create({
|
|
@@ -20095,13 +20185,15 @@ var styles$9 = /*#__PURE__*/stylesheet.create( /*#__PURE__*/_extends({
|
|
|
20095
20185
|
|
|
20096
20186
|
function Body() {
|
|
20097
20187
|
var BodyRef = useBodyRef();
|
|
20098
|
-
useOnScroll(BodyRef);
|
|
20188
|
+
var scrollTop = useOnScroll(BodyRef);
|
|
20099
20189
|
useMouseDownHandlers(BodyRef, MOUSE_EVENT_SOURCE.PICKER);
|
|
20100
20190
|
useOnMouseMove();
|
|
20101
20191
|
return createElement("div", {
|
|
20102
20192
|
className: cx(styles$a.body, commonInteractionStyles.hiddenOnReactions),
|
|
20103
20193
|
ref: BodyRef
|
|
20104
|
-
}, createElement(EmojiVariationPicker, null), createElement(EmojiList,
|
|
20194
|
+
}, createElement(EmojiVariationPicker, null), createElement(EmojiList, {
|
|
20195
|
+
scrollTop: scrollTop
|
|
20196
|
+
}));
|
|
20105
20197
|
}
|
|
20106
20198
|
var styles$a = /*#__PURE__*/stylesheet.create({
|
|
20107
20199
|
body: {
|
|
@@ -20806,21 +20898,6 @@ var styles$h = /*#__PURE__*/stylesheet.create( /*#__PURE__*/_extends({
|
|
|
20806
20898
|
backgroundPositionY: '-40px'
|
|
20807
20899
|
}), /*#__PURE__*/darkMode('btnClearSearch', HoverDark)));
|
|
20808
20900
|
|
|
20809
|
-
var SCOPE = /*#__PURE__*/asSelectors(ClassNames.emojiPicker) + " " + /*#__PURE__*/asSelectors(ClassNames.emojiList);
|
|
20810
|
-
var EMOJI_BUTTON = /*#__PURE__*/['button', asSelectors(ClassNames.emoji)].join('');
|
|
20811
|
-
var CATEGORY = /*#__PURE__*/asSelectors(ClassNames.category);
|
|
20812
|
-
function CssSearch(_ref) {
|
|
20813
|
-
var value = _ref.value;
|
|
20814
|
-
if (!value) {
|
|
20815
|
-
return null;
|
|
20816
|
-
}
|
|
20817
|
-
var q = genQuery(value);
|
|
20818
|
-
return createElement("style", null, "\n " + SCOPE + " " + EMOJI_BUTTON + " {\n display: none;\n }\n\n\n " + SCOPE + " " + q + " {\n display: flex;\n }\n\n " + SCOPE + " " + CATEGORY + ":not(:has(" + q + ")) {\n display: none;\n }\n ");
|
|
20819
|
-
}
|
|
20820
|
-
function genQuery(value) {
|
|
20821
|
-
return [EMOJI_BUTTON, '[data-full-name*="', getNormalizedSearchTerm(value), '"]'].join('');
|
|
20822
|
-
}
|
|
20823
|
-
|
|
20824
20901
|
var SVGMagnifier = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjMuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjQwcHgiIHZpZXdCb3g9IjAgMCAyMCA0MCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjAgNDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iIzg2ODY4NiIgZD0iTTEyLDguODFjMCwyLjA4LTEuNjgsMy43Ni0zLjc2LDMuNzZjLTIuMDgsMC0zLjc2LTEuNjgtMy43Ni0zLjc2CgljMC0yLjA4LDEuNjgtMy43NiwzLjc2LTMuNzZDMTAuMzIsNS4wNSwxMiw2LjczLDEyLDguODF6IE0xMS4yMywxMi43MmMtMC44MywwLjY0LTEuODcsMS4wMS0yLjk5LDEuMDFjLTIuNzIsMC00LjkyLTIuMi00LjkyLTQuOTIKCWMwLTIuNzIsMi4yLTQuOTIsNC45Mi00LjkyYzIuNzIsMCw0LjkyLDIuMiw0LjkyLDQuOTJjMCwxLjEzLTAuMzgsMi4xNi0xLjAxLDIuOTlsMy45NCwzLjkzYzAuMjUsMC4yNSwwLjI1LDAuNjYsMCwwLjkyCgljLTAuMjUsMC4yNS0wLjY2LDAuMjUtMC45MiwwTDExLjIzLDEyLjcyeiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iI0MwQzBCRiIgZD0iTTEyLDI4LjgxYzAsMi4wOC0xLjY4LDMuNzYtMy43NiwzLjc2Yy0yLjA4LDAtMy43Ni0xLjY4LTMuNzYtMy43NgoJYzAtMi4wOCwxLjY4LTMuNzYsMy43Ni0zLjc2QzEwLjMyLDI1LjA1LDEyLDI2LjczLDEyLDI4LjgxeiBNMTEuMjMsMzIuNzJjLTAuODMsMC42NC0xLjg3LDEuMDEtMi45OSwxLjAxCgljLTIuNzIsMC00LjkyLTIuMi00LjkyLTQuOTJjMC0yLjcyLDIuMi00LjkyLDQuOTItNC45MmMyLjcyLDAsNC45MiwyLjIsNC45Miw0LjkyYzAsMS4xMy0wLjM4LDIuMTYtMS4wMSwyLjk5bDMuOTQsMy45MwoJYzAuMjUsMC4yNSwwLjI1LDAuNjYsMCwwLjkyYy0wLjI1LDAuMjUtMC42NiwwLjI1LTAuOTIsMEwxMS4yMywzMi43MnoiLz4KPC9zdmc+';
|
|
20825
20902
|
|
|
20826
20903
|
function IcnSearch() {
|
|
@@ -20858,9 +20935,6 @@ function SearchContainer() {
|
|
|
20858
20935
|
}, createElement(Search, null), isSkinToneInSearch ? createElement(SkinTonePicker, null) : null);
|
|
20859
20936
|
}
|
|
20860
20937
|
function Search() {
|
|
20861
|
-
var _useState = useState(0),
|
|
20862
|
-
inc = _useState[0],
|
|
20863
|
-
setInc = _useState[1];
|
|
20864
20938
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
20865
20939
|
var SearchInputRef = useSearchInputRef();
|
|
20866
20940
|
var placeholder = useSearchPlaceHolderConfig();
|
|
@@ -20873,9 +20947,7 @@ function Search() {
|
|
|
20873
20947
|
var value = input == null ? void 0 : input.value;
|
|
20874
20948
|
return createElement(Relative, {
|
|
20875
20949
|
className: cx(styles$j.searchContainer)
|
|
20876
|
-
}, createElement(
|
|
20877
|
-
value: value
|
|
20878
|
-
}), createElement("input", {
|
|
20950
|
+
}, createElement("input", {
|
|
20879
20951
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
20880
20952
|
autoFocus: autoFocus,
|
|
20881
20953
|
"aria-label": 'Type to search for an emoji',
|
|
@@ -20886,7 +20958,6 @@ function Search() {
|
|
|
20886
20958
|
placeholder: placeholder,
|
|
20887
20959
|
onChange: function onChange(event) {
|
|
20888
20960
|
var _event$target$value, _event$target;
|
|
20889
|
-
setInc(inc + 1);
|
|
20890
20961
|
_onChange((_event$target$value = event == null ? void 0 : (_event$target = event.target) == null ? void 0 : _event$target.value) != null ? _event$target$value : value);
|
|
20891
20962
|
},
|
|
20892
20963
|
ref: SearchInputRef
|