emoji-picker-react 4.13.3 → 4.14.0-rc.1
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 +552 -514
- 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 +553 -515
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/hooks/useCategoryHeight.d.ts +5 -0
- package/dist/hooks/useOnScroll.d.ts +1 -1
- package/package.json +1 -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 +126 -35
- 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/useCategoryHeight.ts +92 -0
- package/src/hooks/useFilter.ts +17 -24
- package/src/hooks/useOnScroll.ts +5 -1
- 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
|
@@ -197,6 +197,86 @@ function compareConfig(prev, next) {
|
|
|
197
197
|
var DEFAULT_REACTIONS = ['1f44d', '2764-fe0f', '1f603', '1f622', '1f64f', '1f44e', '1f621' // 😡
|
|
198
198
|
];
|
|
199
199
|
|
|
200
|
+
var alphaNumericEmojiIndex = {};
|
|
201
|
+
setTimeout(function () {
|
|
202
|
+
allEmojis.reduce(function (searchIndex, emoji) {
|
|
203
|
+
indexEmoji(emoji);
|
|
204
|
+
return searchIndex;
|
|
205
|
+
}, alphaNumericEmojiIndex);
|
|
206
|
+
});
|
|
207
|
+
function indexEmoji(emoji) {
|
|
208
|
+
var joinedNameString = emojiNames(emoji).flat().join('').toLowerCase().replace(/[^a-zA-Z\d]/g, '').split('');
|
|
209
|
+
joinedNameString.forEach(function (_char) {
|
|
210
|
+
var _alphaNumericEmojiInd;
|
|
211
|
+
alphaNumericEmojiIndex[_char] = (_alphaNumericEmojiInd = alphaNumericEmojiIndex[_char]) != null ? _alphaNumericEmojiInd : {};
|
|
212
|
+
alphaNumericEmojiIndex[_char][emojiUnified(emoji)] = emoji;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function useDebouncedState(initialValue, delay) {
|
|
217
|
+
if (delay === void 0) {
|
|
218
|
+
delay = 0;
|
|
219
|
+
}
|
|
220
|
+
var _useState = React.useState(initialValue),
|
|
221
|
+
state = _useState[0],
|
|
222
|
+
setState = _useState[1];
|
|
223
|
+
var timer = React.useRef(null);
|
|
224
|
+
function debouncedSetState(value) {
|
|
225
|
+
return new Promise(function (resolve) {
|
|
226
|
+
var _window;
|
|
227
|
+
if (timer.current) {
|
|
228
|
+
clearTimeout(timer.current);
|
|
229
|
+
}
|
|
230
|
+
timer.current = (_window = window) == null ? void 0 : _window.setTimeout(function () {
|
|
231
|
+
setState(value);
|
|
232
|
+
resolve(value);
|
|
233
|
+
}, delay);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return [state, debouncedSetState];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function useIsUnicodeHidden() {
|
|
240
|
+
var unicodeToHide = useUnicodeToHide();
|
|
241
|
+
return function (emojiUnified) {
|
|
242
|
+
return unicodeToHide.has(emojiUnified);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function useDisallowedEmojis() {
|
|
247
|
+
var DisallowedEmojisRef = React.useRef({});
|
|
248
|
+
var emojiVersionConfig = useEmojiVersionConfig();
|
|
249
|
+
return React.useMemo(function () {
|
|
250
|
+
var emojiVersion = parseFloat("" + emojiVersionConfig);
|
|
251
|
+
if (!emojiVersionConfig || Number.isNaN(emojiVersion)) {
|
|
252
|
+
return DisallowedEmojisRef.current;
|
|
253
|
+
}
|
|
254
|
+
return allEmojis.reduce(function (disallowedEmojis, emoji) {
|
|
255
|
+
if (addedInNewerVersion(emoji, emojiVersion)) {
|
|
256
|
+
disallowedEmojis[emojiUnified(emoji)] = true;
|
|
257
|
+
}
|
|
258
|
+
return disallowedEmojis;
|
|
259
|
+
}, DisallowedEmojisRef.current);
|
|
260
|
+
}, [emojiVersionConfig]);
|
|
261
|
+
}
|
|
262
|
+
function useIsEmojiDisallowed() {
|
|
263
|
+
var disallowedEmojis = useDisallowedEmojis();
|
|
264
|
+
var isUnicodeHidden = useIsUnicodeHidden();
|
|
265
|
+
return function isEmojiDisallowed(emoji) {
|
|
266
|
+
var unified = unifiedWithoutSkinTone(emojiUnified(emoji));
|
|
267
|
+
return Boolean(disallowedEmojis[unified] || isUnicodeHidden(unified));
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function addedInNewerVersion(emoji, supportedLevel) {
|
|
271
|
+
return addedIn(emoji) > supportedLevel;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function useMarkInitialLoad(dispatch) {
|
|
275
|
+
React.useEffect(function () {
|
|
276
|
+
dispatch(true);
|
|
277
|
+
}, [dispatch]);
|
|
278
|
+
}
|
|
279
|
+
|
|
200
280
|
(function (SuggestionMode) {
|
|
201
281
|
SuggestionMode["RECENT"] = "recent";
|
|
202
282
|
SuggestionMode["FREQUENT"] = "frequent";
|
|
@@ -238,6 +318,128 @@ var DEFAULT_REACTIONS = ['1f44d', '2764-fe0f', '1f603', '1f622', '1f64f', '1f44e
|
|
|
238
318
|
SkinTonePickerLocation["PREVIEW"] = "PREVIEW";
|
|
239
319
|
})(exports.SkinTonePickerLocation || (exports.SkinTonePickerLocation = {}));
|
|
240
320
|
|
|
321
|
+
function PickerContextProvider(_ref) {
|
|
322
|
+
var children = _ref.children;
|
|
323
|
+
var disallowedEmojis = useDisallowedEmojis();
|
|
324
|
+
var defaultSkinTone = useDefaultSkinToneConfig();
|
|
325
|
+
var reactionsDefaultOpen = useReactionsOpenConfig();
|
|
326
|
+
// Initialize the filter with the inititial dictionary
|
|
327
|
+
var filterRef = React.useRef(alphaNumericEmojiIndex);
|
|
328
|
+
var disallowClickRef = React.useRef(false);
|
|
329
|
+
var disallowMouseRef = React.useRef(false);
|
|
330
|
+
var disallowedEmojisRef = React.useRef(disallowedEmojis);
|
|
331
|
+
var suggestedUpdateState = useDebouncedState(Date.now(), 200);
|
|
332
|
+
var searchTerm = useDebouncedState('', 100);
|
|
333
|
+
var skinToneFanOpenState = React.useState(false);
|
|
334
|
+
var activeSkinTone = React.useState(defaultSkinTone);
|
|
335
|
+
var activeCategoryState = React.useState(null);
|
|
336
|
+
var emojisThatFailedToLoadState = React.useState(new Set());
|
|
337
|
+
var emojiVariationPickerState = React.useState(null);
|
|
338
|
+
var reactionsModeState = React.useState(reactionsDefaultOpen);
|
|
339
|
+
var _useState = React.useState(false),
|
|
340
|
+
isPastInitialLoad = _useState[0],
|
|
341
|
+
setIsPastInitialLoad = _useState[1];
|
|
342
|
+
useMarkInitialLoad(setIsPastInitialLoad);
|
|
343
|
+
return React.createElement(PickerContext.Provider, {
|
|
344
|
+
value: {
|
|
345
|
+
activeCategoryState: activeCategoryState,
|
|
346
|
+
activeSkinTone: activeSkinTone,
|
|
347
|
+
disallowClickRef: disallowClickRef,
|
|
348
|
+
disallowMouseRef: disallowMouseRef,
|
|
349
|
+
disallowedEmojisRef: disallowedEmojisRef,
|
|
350
|
+
emojiVariationPickerState: emojiVariationPickerState,
|
|
351
|
+
emojisThatFailedToLoadState: emojisThatFailedToLoadState,
|
|
352
|
+
filterRef: filterRef,
|
|
353
|
+
isPastInitialLoad: isPastInitialLoad,
|
|
354
|
+
searchTerm: searchTerm,
|
|
355
|
+
skinToneFanOpenState: skinToneFanOpenState,
|
|
356
|
+
suggestedUpdateState: suggestedUpdateState,
|
|
357
|
+
reactionsModeState: reactionsModeState
|
|
358
|
+
}
|
|
359
|
+
}, children);
|
|
360
|
+
}
|
|
361
|
+
var PickerContext = /*#__PURE__*/React.createContext({
|
|
362
|
+
activeCategoryState: [null, function () {}],
|
|
363
|
+
activeSkinTone: [exports.SkinTones.NEUTRAL, function () {}],
|
|
364
|
+
disallowClickRef: {
|
|
365
|
+
current: false
|
|
366
|
+
},
|
|
367
|
+
disallowMouseRef: {
|
|
368
|
+
current: false
|
|
369
|
+
},
|
|
370
|
+
disallowedEmojisRef: {
|
|
371
|
+
current: {}
|
|
372
|
+
},
|
|
373
|
+
emojiVariationPickerState: [null, function () {}],
|
|
374
|
+
emojisThatFailedToLoadState: [/*#__PURE__*/new Set(), function () {}],
|
|
375
|
+
filterRef: {
|
|
376
|
+
current: {}
|
|
377
|
+
},
|
|
378
|
+
isPastInitialLoad: true,
|
|
379
|
+
searchTerm: ['', function () {
|
|
380
|
+
return new Promise(function () {
|
|
381
|
+
return undefined;
|
|
382
|
+
});
|
|
383
|
+
}],
|
|
384
|
+
skinToneFanOpenState: [false, function () {}],
|
|
385
|
+
suggestedUpdateState: [/*#__PURE__*/Date.now(), function () {}],
|
|
386
|
+
reactionsModeState: [false, function () {}]
|
|
387
|
+
});
|
|
388
|
+
function useFilterRef() {
|
|
389
|
+
var _React$useContext = React.useContext(PickerContext),
|
|
390
|
+
filterRef = _React$useContext.filterRef;
|
|
391
|
+
return filterRef;
|
|
392
|
+
}
|
|
393
|
+
function useDisallowClickRef() {
|
|
394
|
+
var _React$useContext2 = React.useContext(PickerContext),
|
|
395
|
+
disallowClickRef = _React$useContext2.disallowClickRef;
|
|
396
|
+
return disallowClickRef;
|
|
397
|
+
}
|
|
398
|
+
function useDisallowMouseRef() {
|
|
399
|
+
var _React$useContext3 = React.useContext(PickerContext),
|
|
400
|
+
disallowMouseRef = _React$useContext3.disallowMouseRef;
|
|
401
|
+
return disallowMouseRef;
|
|
402
|
+
}
|
|
403
|
+
function useReactionsModeState() {
|
|
404
|
+
var _React$useContext4 = React.useContext(PickerContext),
|
|
405
|
+
reactionsModeState = _React$useContext4.reactionsModeState;
|
|
406
|
+
return reactionsModeState;
|
|
407
|
+
}
|
|
408
|
+
function useSearchTermState() {
|
|
409
|
+
var _React$useContext5 = React.useContext(PickerContext),
|
|
410
|
+
searchTerm = _React$useContext5.searchTerm;
|
|
411
|
+
return searchTerm;
|
|
412
|
+
}
|
|
413
|
+
function useActiveSkinToneState() {
|
|
414
|
+
var _React$useContext6 = React.useContext(PickerContext),
|
|
415
|
+
activeSkinTone = _React$useContext6.activeSkinTone;
|
|
416
|
+
return activeSkinTone;
|
|
417
|
+
}
|
|
418
|
+
function useEmojisThatFailedToLoadState() {
|
|
419
|
+
var _React$useContext7 = React.useContext(PickerContext),
|
|
420
|
+
emojisThatFailedToLoadState = _React$useContext7.emojisThatFailedToLoadState;
|
|
421
|
+
return emojisThatFailedToLoadState;
|
|
422
|
+
}
|
|
423
|
+
function useEmojiVariationPickerState() {
|
|
424
|
+
var _React$useContext9 = React.useContext(PickerContext),
|
|
425
|
+
emojiVariationPickerState = _React$useContext9.emojiVariationPickerState;
|
|
426
|
+
return emojiVariationPickerState;
|
|
427
|
+
}
|
|
428
|
+
function useSkinToneFanOpenState() {
|
|
429
|
+
var _React$useContext10 = React.useContext(PickerContext),
|
|
430
|
+
skinToneFanOpenState = _React$useContext10.skinToneFanOpenState;
|
|
431
|
+
return skinToneFanOpenState;
|
|
432
|
+
}
|
|
433
|
+
function useUpdateSuggested() {
|
|
434
|
+
var _React$useContext12 = React.useContext(PickerContext),
|
|
435
|
+
suggestedUpdateState = _React$useContext12.suggestedUpdateState;
|
|
436
|
+
var suggestedUpdated = suggestedUpdateState[0],
|
|
437
|
+
setsuggestedUpdate = suggestedUpdateState[1];
|
|
438
|
+
return [suggestedUpdated, function updateSuggested() {
|
|
439
|
+
setsuggestedUpdate(Date.now());
|
|
440
|
+
}];
|
|
441
|
+
}
|
|
442
|
+
|
|
241
443
|
var _configByCategory;
|
|
242
444
|
var categoriesOrdered = [exports.Categories.SUGGESTED, exports.Categories.CUSTOM, exports.Categories.SMILEYS_PEOPLE, exports.Categories.ANIMALS_NATURE, exports.Categories.FOOD_DRINK, exports.Categories.TRAVEL_PLACES, exports.Categories.ACTIVITIES, exports.Categories.OBJECTS, exports.Categories.SYMBOLS, exports.Categories.FLAGS];
|
|
243
445
|
var SuggestedRecent = {
|
|
@@ -17165,56 +17367,107 @@ var EmojiProperties;
|
|
|
17165
17367
|
EmojiProperties["imgUrl"] = "imgUrl";
|
|
17166
17368
|
})(EmojiProperties || (EmojiProperties = {}));
|
|
17167
17369
|
|
|
17168
|
-
var
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
}
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
}
|
|
17183
|
-
|
|
17184
|
-
function emojiNames(emoji) {
|
|
17185
|
-
var _emoji$EmojiPropertie;
|
|
17186
|
-
return (_emoji$EmojiPropertie = emoji[EmojiProperties.name]) != null ? _emoji$EmojiPropertie : [];
|
|
17187
|
-
}
|
|
17188
|
-
function addedIn(emoji) {
|
|
17189
|
-
return parseFloat(emoji[EmojiProperties.added_in]);
|
|
17190
|
-
}
|
|
17191
|
-
function emojiName(emoji) {
|
|
17192
|
-
if (!emoji) {
|
|
17193
|
-
return '';
|
|
17194
|
-
}
|
|
17195
|
-
return emojiNames(emoji)[0];
|
|
17196
|
-
}
|
|
17197
|
-
function unifiedWithoutSkinTone(unified) {
|
|
17198
|
-
var splat = unified.split('-');
|
|
17199
|
-
var _splat$splice = splat.splice(1, 1),
|
|
17200
|
-
skinTone = _splat$splice[0];
|
|
17201
|
-
if (skinTonesMapped[skinTone]) {
|
|
17202
|
-
return splat.join('-');
|
|
17370
|
+
var SUGGESTED_LS_KEY = 'epr_suggested';
|
|
17371
|
+
function getSuggested(mode) {
|
|
17372
|
+
try {
|
|
17373
|
+
var _window, _window$localStorage$, _window2;
|
|
17374
|
+
if (!((_window = window) != null && _window.localStorage)) {
|
|
17375
|
+
return [];
|
|
17376
|
+
}
|
|
17377
|
+
var recent = JSON.parse((_window$localStorage$ = (_window2 = window) == null ? void 0 : _window2.localStorage.getItem(SUGGESTED_LS_KEY)) != null ? _window$localStorage$ : '[]');
|
|
17378
|
+
if (mode === exports.SuggestionMode.FREQUENT) {
|
|
17379
|
+
return recent.sort(function (a, b) {
|
|
17380
|
+
return b.count - a.count;
|
|
17381
|
+
});
|
|
17382
|
+
}
|
|
17383
|
+
return recent;
|
|
17384
|
+
} catch (_unused) {
|
|
17385
|
+
return [];
|
|
17203
17386
|
}
|
|
17204
|
-
return unified;
|
|
17205
17387
|
}
|
|
17206
|
-
function
|
|
17207
|
-
var
|
|
17388
|
+
function setSuggested(emoji, skinTone) {
|
|
17389
|
+
var recent = getSuggested();
|
|
17390
|
+
var unified = emojiUnified(emoji, skinTone);
|
|
17391
|
+
var originalUnified = emojiUnified(emoji);
|
|
17392
|
+
var existing = recent.find(function (_ref) {
|
|
17393
|
+
var u = _ref.unified;
|
|
17394
|
+
return u === unified;
|
|
17395
|
+
});
|
|
17396
|
+
var nextList;
|
|
17397
|
+
if (existing) {
|
|
17398
|
+
nextList = [existing].concat(recent.filter(function (i) {
|
|
17399
|
+
return i !== existing;
|
|
17400
|
+
}));
|
|
17401
|
+
} else {
|
|
17402
|
+
existing = {
|
|
17403
|
+
unified: unified,
|
|
17404
|
+
original: originalUnified,
|
|
17405
|
+
count: 0
|
|
17406
|
+
};
|
|
17407
|
+
nextList = [existing].concat(recent);
|
|
17408
|
+
}
|
|
17409
|
+
existing.count++;
|
|
17410
|
+
nextList.length = Math.min(nextList.length, 14);
|
|
17411
|
+
try {
|
|
17412
|
+
var _window3;
|
|
17413
|
+
(_window3 = window) == null ? void 0 : _window3.localStorage.setItem(SUGGESTED_LS_KEY, JSON.stringify(nextList));
|
|
17414
|
+
// Prevents the change from being seen immediately.
|
|
17415
|
+
} catch (_unused2) {
|
|
17416
|
+
// ignore
|
|
17417
|
+
}
|
|
17418
|
+
}
|
|
17419
|
+
|
|
17420
|
+
function emojiNames(emoji) {
|
|
17421
|
+
var _emoji$EmojiPropertie;
|
|
17422
|
+
return (_emoji$EmojiPropertie = emoji[EmojiProperties.name]) != null ? _emoji$EmojiPropertie : [];
|
|
17423
|
+
}
|
|
17424
|
+
function addedIn(emoji) {
|
|
17425
|
+
return parseFloat(emoji[EmojiProperties.added_in]);
|
|
17426
|
+
}
|
|
17427
|
+
function emojiName(emoji) {
|
|
17428
|
+
if (!emoji) {
|
|
17429
|
+
return '';
|
|
17430
|
+
}
|
|
17431
|
+
return emojiNames(emoji)[0];
|
|
17432
|
+
}
|
|
17433
|
+
function unifiedWithoutSkinTone(unified) {
|
|
17434
|
+
var splat = unified.split('-');
|
|
17435
|
+
var _splat$splice = splat.splice(1, 1),
|
|
17436
|
+
skinTone = _splat$splice[0];
|
|
17437
|
+
if (skinTonesMapped[skinTone]) {
|
|
17438
|
+
return splat.join('-');
|
|
17439
|
+
}
|
|
17440
|
+
return unified;
|
|
17441
|
+
}
|
|
17442
|
+
function emojiUnified(emoji, skinTone) {
|
|
17443
|
+
var _emojiVariationUnifie;
|
|
17208
17444
|
var unified = emoji[EmojiProperties.unified];
|
|
17209
17445
|
if (!skinTone || !emojiHasVariations(emoji)) {
|
|
17210
17446
|
return unified;
|
|
17211
17447
|
}
|
|
17212
17448
|
return (_emojiVariationUnifie = emojiVariationUnified(emoji, skinTone)) != null ? _emojiVariationUnifie : unified;
|
|
17213
17449
|
}
|
|
17214
|
-
function
|
|
17215
|
-
var
|
|
17216
|
-
|
|
17217
|
-
|
|
17450
|
+
function useGetEmojisByCategory() {
|
|
17451
|
+
var suggestedEmojisModeConfig = useSuggestedEmojisModeConfig();
|
|
17452
|
+
var _useUpdateSuggested = useUpdateSuggested(),
|
|
17453
|
+
suggestedUpdated = _useUpdateSuggested[0];
|
|
17454
|
+
var suggested = React__default.useMemo(function () {
|
|
17455
|
+
var _getSuggested;
|
|
17456
|
+
var suggested = (_getSuggested = getSuggested(suggestedEmojisModeConfig)) != null ? _getSuggested : [];
|
|
17457
|
+
return suggested.map(function (s) {
|
|
17458
|
+
return emojiByUnified(s.unified);
|
|
17459
|
+
}).filter(Boolean);
|
|
17460
|
+
},
|
|
17461
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17462
|
+
[suggestedUpdated, suggestedEmojisModeConfig]);
|
|
17463
|
+
return function getEmojisByCategory(category) {
|
|
17464
|
+
var _emojis$category;
|
|
17465
|
+
if (category === exports.Categories.SUGGESTED) {
|
|
17466
|
+
return suggested;
|
|
17467
|
+
}
|
|
17468
|
+
// @ts-ignore
|
|
17469
|
+
return (_emojis$category = emojis[category]) != null ? _emojis$category : [];
|
|
17470
|
+
};
|
|
17218
17471
|
}
|
|
17219
17472
|
// WARNING: DO NOT USE DIRECTLY
|
|
17220
17473
|
function emojiUrlByUnified(unified, emojiStyle) {
|
|
@@ -17375,197 +17628,6 @@ function usePickerConfig() {
|
|
|
17375
17628
|
return React.useContext(ConfigContext);
|
|
17376
17629
|
}
|
|
17377
17630
|
|
|
17378
|
-
function useDebouncedState(initialValue, delay) {
|
|
17379
|
-
if (delay === void 0) {
|
|
17380
|
-
delay = 0;
|
|
17381
|
-
}
|
|
17382
|
-
var _useState = React.useState(initialValue),
|
|
17383
|
-
state = _useState[0],
|
|
17384
|
-
setState = _useState[1];
|
|
17385
|
-
var timer = React.useRef(null);
|
|
17386
|
-
function debouncedSetState(value) {
|
|
17387
|
-
return new Promise(function (resolve) {
|
|
17388
|
-
var _window;
|
|
17389
|
-
if (timer.current) {
|
|
17390
|
-
clearTimeout(timer.current);
|
|
17391
|
-
}
|
|
17392
|
-
timer.current = (_window = window) == null ? void 0 : _window.setTimeout(function () {
|
|
17393
|
-
setState(value);
|
|
17394
|
-
resolve(value);
|
|
17395
|
-
}, delay);
|
|
17396
|
-
});
|
|
17397
|
-
}
|
|
17398
|
-
return [state, debouncedSetState];
|
|
17399
|
-
}
|
|
17400
|
-
|
|
17401
|
-
function useIsUnicodeHidden() {
|
|
17402
|
-
var unicodeToHide = useUnicodeToHide();
|
|
17403
|
-
return function (emojiUnified) {
|
|
17404
|
-
return unicodeToHide.has(emojiUnified);
|
|
17405
|
-
};
|
|
17406
|
-
}
|
|
17407
|
-
|
|
17408
|
-
function useDisallowedEmojis() {
|
|
17409
|
-
var DisallowedEmojisRef = React.useRef({});
|
|
17410
|
-
var emojiVersionConfig = useEmojiVersionConfig();
|
|
17411
|
-
return React.useMemo(function () {
|
|
17412
|
-
var emojiVersion = parseFloat("" + emojiVersionConfig);
|
|
17413
|
-
if (!emojiVersionConfig || Number.isNaN(emojiVersion)) {
|
|
17414
|
-
return DisallowedEmojisRef.current;
|
|
17415
|
-
}
|
|
17416
|
-
return allEmojis.reduce(function (disallowedEmojis, emoji) {
|
|
17417
|
-
if (addedInNewerVersion(emoji, emojiVersion)) {
|
|
17418
|
-
disallowedEmojis[emojiUnified(emoji)] = true;
|
|
17419
|
-
}
|
|
17420
|
-
return disallowedEmojis;
|
|
17421
|
-
}, DisallowedEmojisRef.current);
|
|
17422
|
-
}, [emojiVersionConfig]);
|
|
17423
|
-
}
|
|
17424
|
-
function useIsEmojiDisallowed() {
|
|
17425
|
-
var disallowedEmojis = useDisallowedEmojis();
|
|
17426
|
-
var isUnicodeHidden = useIsUnicodeHidden();
|
|
17427
|
-
return function isEmojiDisallowed(emoji) {
|
|
17428
|
-
var unified = unifiedWithoutSkinTone(emojiUnified(emoji));
|
|
17429
|
-
return Boolean(disallowedEmojis[unified] || isUnicodeHidden(unified));
|
|
17430
|
-
};
|
|
17431
|
-
}
|
|
17432
|
-
function addedInNewerVersion(emoji, supportedLevel) {
|
|
17433
|
-
return addedIn(emoji) > supportedLevel;
|
|
17434
|
-
}
|
|
17435
|
-
|
|
17436
|
-
function useMarkInitialLoad(dispatch) {
|
|
17437
|
-
React.useEffect(function () {
|
|
17438
|
-
dispatch(true);
|
|
17439
|
-
}, [dispatch]);
|
|
17440
|
-
}
|
|
17441
|
-
|
|
17442
|
-
function PickerContextProvider(_ref) {
|
|
17443
|
-
var children = _ref.children;
|
|
17444
|
-
var disallowedEmojis = useDisallowedEmojis();
|
|
17445
|
-
var defaultSkinTone = useDefaultSkinToneConfig();
|
|
17446
|
-
var reactionsDefaultOpen = useReactionsOpenConfig();
|
|
17447
|
-
// Initialize the filter with the inititial dictionary
|
|
17448
|
-
var filterRef = React.useRef(alphaNumericEmojiIndex);
|
|
17449
|
-
var disallowClickRef = React.useRef(false);
|
|
17450
|
-
var disallowMouseRef = React.useRef(false);
|
|
17451
|
-
var disallowedEmojisRef = React.useRef(disallowedEmojis);
|
|
17452
|
-
var suggestedUpdateState = useDebouncedState(Date.now(), 200);
|
|
17453
|
-
var searchTerm = useDebouncedState('', 100);
|
|
17454
|
-
var skinToneFanOpenState = React.useState(false);
|
|
17455
|
-
var activeSkinTone = React.useState(defaultSkinTone);
|
|
17456
|
-
var activeCategoryState = React.useState(null);
|
|
17457
|
-
var emojisThatFailedToLoadState = React.useState(new Set());
|
|
17458
|
-
var emojiVariationPickerState = React.useState(null);
|
|
17459
|
-
var reactionsModeState = React.useState(reactionsDefaultOpen);
|
|
17460
|
-
var _useState = React.useState(false),
|
|
17461
|
-
isPastInitialLoad = _useState[0],
|
|
17462
|
-
setIsPastInitialLoad = _useState[1];
|
|
17463
|
-
useMarkInitialLoad(setIsPastInitialLoad);
|
|
17464
|
-
return React.createElement(PickerContext.Provider, {
|
|
17465
|
-
value: {
|
|
17466
|
-
activeCategoryState: activeCategoryState,
|
|
17467
|
-
activeSkinTone: activeSkinTone,
|
|
17468
|
-
disallowClickRef: disallowClickRef,
|
|
17469
|
-
disallowMouseRef: disallowMouseRef,
|
|
17470
|
-
disallowedEmojisRef: disallowedEmojisRef,
|
|
17471
|
-
emojiVariationPickerState: emojiVariationPickerState,
|
|
17472
|
-
emojisThatFailedToLoadState: emojisThatFailedToLoadState,
|
|
17473
|
-
filterRef: filterRef,
|
|
17474
|
-
isPastInitialLoad: isPastInitialLoad,
|
|
17475
|
-
searchTerm: searchTerm,
|
|
17476
|
-
skinToneFanOpenState: skinToneFanOpenState,
|
|
17477
|
-
suggestedUpdateState: suggestedUpdateState,
|
|
17478
|
-
reactionsModeState: reactionsModeState
|
|
17479
|
-
}
|
|
17480
|
-
}, children);
|
|
17481
|
-
}
|
|
17482
|
-
var PickerContext = /*#__PURE__*/React.createContext({
|
|
17483
|
-
activeCategoryState: [null, function () {}],
|
|
17484
|
-
activeSkinTone: [exports.SkinTones.NEUTRAL, function () {}],
|
|
17485
|
-
disallowClickRef: {
|
|
17486
|
-
current: false
|
|
17487
|
-
},
|
|
17488
|
-
disallowMouseRef: {
|
|
17489
|
-
current: false
|
|
17490
|
-
},
|
|
17491
|
-
disallowedEmojisRef: {
|
|
17492
|
-
current: {}
|
|
17493
|
-
},
|
|
17494
|
-
emojiVariationPickerState: [null, function () {}],
|
|
17495
|
-
emojisThatFailedToLoadState: [/*#__PURE__*/new Set(), function () {}],
|
|
17496
|
-
filterRef: {
|
|
17497
|
-
current: {}
|
|
17498
|
-
},
|
|
17499
|
-
isPastInitialLoad: true,
|
|
17500
|
-
searchTerm: ['', function () {
|
|
17501
|
-
return new Promise(function () {
|
|
17502
|
-
return undefined;
|
|
17503
|
-
});
|
|
17504
|
-
}],
|
|
17505
|
-
skinToneFanOpenState: [false, function () {}],
|
|
17506
|
-
suggestedUpdateState: [/*#__PURE__*/Date.now(), function () {}],
|
|
17507
|
-
reactionsModeState: [false, function () {}]
|
|
17508
|
-
});
|
|
17509
|
-
function useFilterRef() {
|
|
17510
|
-
var _React$useContext = React.useContext(PickerContext),
|
|
17511
|
-
filterRef = _React$useContext.filterRef;
|
|
17512
|
-
return filterRef;
|
|
17513
|
-
}
|
|
17514
|
-
function useDisallowClickRef() {
|
|
17515
|
-
var _React$useContext2 = React.useContext(PickerContext),
|
|
17516
|
-
disallowClickRef = _React$useContext2.disallowClickRef;
|
|
17517
|
-
return disallowClickRef;
|
|
17518
|
-
}
|
|
17519
|
-
function useDisallowMouseRef() {
|
|
17520
|
-
var _React$useContext3 = React.useContext(PickerContext),
|
|
17521
|
-
disallowMouseRef = _React$useContext3.disallowMouseRef;
|
|
17522
|
-
return disallowMouseRef;
|
|
17523
|
-
}
|
|
17524
|
-
function useReactionsModeState() {
|
|
17525
|
-
var _React$useContext4 = React.useContext(PickerContext),
|
|
17526
|
-
reactionsModeState = _React$useContext4.reactionsModeState;
|
|
17527
|
-
return reactionsModeState;
|
|
17528
|
-
}
|
|
17529
|
-
function useSearchTermState() {
|
|
17530
|
-
var _React$useContext5 = React.useContext(PickerContext),
|
|
17531
|
-
searchTerm = _React$useContext5.searchTerm;
|
|
17532
|
-
return searchTerm;
|
|
17533
|
-
}
|
|
17534
|
-
function useActiveSkinToneState() {
|
|
17535
|
-
var _React$useContext6 = React.useContext(PickerContext),
|
|
17536
|
-
activeSkinTone = _React$useContext6.activeSkinTone;
|
|
17537
|
-
return activeSkinTone;
|
|
17538
|
-
}
|
|
17539
|
-
function useEmojisThatFailedToLoadState() {
|
|
17540
|
-
var _React$useContext7 = React.useContext(PickerContext),
|
|
17541
|
-
emojisThatFailedToLoadState = _React$useContext7.emojisThatFailedToLoadState;
|
|
17542
|
-
return emojisThatFailedToLoadState;
|
|
17543
|
-
}
|
|
17544
|
-
function useIsPastInitialLoad() {
|
|
17545
|
-
var _React$useContext8 = React.useContext(PickerContext),
|
|
17546
|
-
isPastInitialLoad = _React$useContext8.isPastInitialLoad;
|
|
17547
|
-
return isPastInitialLoad;
|
|
17548
|
-
}
|
|
17549
|
-
function useEmojiVariationPickerState() {
|
|
17550
|
-
var _React$useContext9 = React.useContext(PickerContext),
|
|
17551
|
-
emojiVariationPickerState = _React$useContext9.emojiVariationPickerState;
|
|
17552
|
-
return emojiVariationPickerState;
|
|
17553
|
-
}
|
|
17554
|
-
function useSkinToneFanOpenState() {
|
|
17555
|
-
var _React$useContext10 = React.useContext(PickerContext),
|
|
17556
|
-
skinToneFanOpenState = _React$useContext10.skinToneFanOpenState;
|
|
17557
|
-
return skinToneFanOpenState;
|
|
17558
|
-
}
|
|
17559
|
-
function useUpdateSuggested() {
|
|
17560
|
-
var _React$useContext12 = React.useContext(PickerContext),
|
|
17561
|
-
suggestedUpdateState = _React$useContext12.suggestedUpdateState;
|
|
17562
|
-
var suggestedUpdated = suggestedUpdateState[0],
|
|
17563
|
-
setsuggestedUpdate = suggestedUpdateState[1];
|
|
17564
|
-
return [suggestedUpdated, function updateSuggested() {
|
|
17565
|
-
setsuggestedUpdate(Date.now());
|
|
17566
|
-
}];
|
|
17567
|
-
}
|
|
17568
|
-
|
|
17569
17631
|
var MutableConfigContext = /*#__PURE__*/React__default.createContext({});
|
|
17570
17632
|
function useMutableConfig() {
|
|
17571
17633
|
var mutableConfig = React__default.useContext(MutableConfigContext);
|
|
@@ -17800,6 +17862,7 @@ function ElementRefContextProvider(_ref) {
|
|
|
17800
17862
|
var PickerMainRef = React.useRef(null);
|
|
17801
17863
|
var AnchoredEmojiRef = React.useRef(null);
|
|
17802
17864
|
var BodyRef = React.useRef(null);
|
|
17865
|
+
var EmojiListRef = React.useRef(null);
|
|
17803
17866
|
var SearchInputRef = React.useRef(null);
|
|
17804
17867
|
var SkinTonePickerRef = React.useRef(null);
|
|
17805
17868
|
var CategoryNavigationRef = React.useRef(null);
|
|
@@ -17809,6 +17872,7 @@ function ElementRefContextProvider(_ref) {
|
|
|
17809
17872
|
value: {
|
|
17810
17873
|
AnchoredEmojiRef: AnchoredEmojiRef,
|
|
17811
17874
|
BodyRef: BodyRef,
|
|
17875
|
+
EmojiListRef: EmojiListRef,
|
|
17812
17876
|
CategoryNavigationRef: CategoryNavigationRef,
|
|
17813
17877
|
PickerMainRef: PickerMainRef,
|
|
17814
17878
|
SearchInputRef: SearchInputRef,
|
|
@@ -17822,6 +17886,7 @@ var ElementRefContext = /*#__PURE__*/React.createContext({
|
|
|
17822
17886
|
AnchoredEmojiRef: /*#__PURE__*/React.createRef(),
|
|
17823
17887
|
BodyRef: /*#__PURE__*/React.createRef(),
|
|
17824
17888
|
CategoryNavigationRef: /*#__PURE__*/React.createRef(),
|
|
17889
|
+
EmojiListRef: /*#__PURE__*/React.createRef(),
|
|
17825
17890
|
PickerMainRef: /*#__PURE__*/React.createRef(),
|
|
17826
17891
|
SearchInputRef: /*#__PURE__*/React.createRef(),
|
|
17827
17892
|
SkinTonePickerRef: /*#__PURE__*/React.createRef(),
|
|
@@ -17831,6 +17896,9 @@ var ElementRefContext = /*#__PURE__*/React.createContext({
|
|
|
17831
17896
|
function useElementRef() {
|
|
17832
17897
|
return React.useContext(ElementRefContext);
|
|
17833
17898
|
}
|
|
17899
|
+
function useEmojiListRef() {
|
|
17900
|
+
return useElementRef()['EmojiListRef'];
|
|
17901
|
+
}
|
|
17834
17902
|
function usePickerMainRef() {
|
|
17835
17903
|
return useElementRef()['PickerMainRef'];
|
|
17836
17904
|
}
|
|
@@ -17967,38 +18035,67 @@ function visibleEmojiOneRowUp(element) {
|
|
|
17967
18035
|
}
|
|
17968
18036
|
var categoryContent = closestCategoryContent(element);
|
|
17969
18037
|
var category = closestCategory(categoryContent);
|
|
17970
|
-
var indexInRow = elementIndexInRow(categoryContent, element);
|
|
17971
|
-
var row = rowNumber(categoryContent, element);
|
|
17972
18038
|
var countInRow = elementCountInRow(categoryContent, element);
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
17976
|
-
|
|
18039
|
+
var emojisInCurrentCategory = allVisibleEmojis(category);
|
|
18040
|
+
var currentEmojiIndex = emojisInCurrentCategory.indexOf(element);
|
|
18041
|
+
var indexInRow = currentEmojiIndex % countInRow;
|
|
18042
|
+
if (currentEmojiIndex === -1) {
|
|
18043
|
+
return null;
|
|
18044
|
+
}
|
|
18045
|
+
if (emojisInCurrentCategory[currentEmojiIndex - countInRow]) {
|
|
18046
|
+
return emojisInCurrentCategory[currentEmojiIndex - countInRow];
|
|
18047
|
+
}
|
|
18048
|
+
var prevVisibleCategory = prevCategory(category);
|
|
18049
|
+
if (!prevVisibleCategory) {
|
|
18050
|
+
return null;
|
|
18051
|
+
}
|
|
18052
|
+
var allPrevEmojis = allVisibleEmojis(prevVisibleCategory);
|
|
18053
|
+
// if there is an emoji in the same index of `indexInRow` in the previous category, return it
|
|
18054
|
+
// for this we need to find the last emoji in the previous category that shares the same indexInRow
|
|
18055
|
+
// this is by using the % operator to find the last emoji that matches
|
|
18056
|
+
var lastIndexInRow = allPrevEmojis.length % countInRow - 1;
|
|
18057
|
+
if (indexInRow > lastIndexInRow) {
|
|
18058
|
+
return allPrevEmojis.at(-1);
|
|
18059
|
+
}
|
|
18060
|
+
// otherwise, return the last emoji that shares the same indexInRow
|
|
18061
|
+
for (var i = allPrevEmojis.length - 1; i >= 0; i--) {
|
|
18062
|
+
if (i % countInRow === indexInRow) {
|
|
18063
|
+
return allPrevEmojis[i];
|
|
17977
18064
|
}
|
|
17978
|
-
return getElementInRow(allVisibleEmojis(prevVisibleCategory), -1,
|
|
17979
|
-
// last row
|
|
17980
|
-
countInRow, indexInRow);
|
|
17981
18065
|
}
|
|
17982
|
-
return
|
|
18066
|
+
return allPrevEmojis.at(-1);
|
|
17983
18067
|
}
|
|
17984
18068
|
function visibleEmojiOneRowDown(element) {
|
|
18069
|
+
var _emojisInNextCategory;
|
|
17985
18070
|
if (!element) {
|
|
17986
18071
|
return null;
|
|
17987
18072
|
}
|
|
17988
18073
|
var categoryContent = closestCategoryContent(element);
|
|
17989
18074
|
var category = closestCategory(categoryContent);
|
|
17990
|
-
var indexInRow = elementIndexInRow(categoryContent, element);
|
|
17991
|
-
var row = rowNumber(categoryContent, element);
|
|
17992
18075
|
var countInRow = elementCountInRow(categoryContent, element);
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
18076
|
+
var emojisInCurrentCategory = allVisibleEmojis(category);
|
|
18077
|
+
var currentEmojiIndex = emojisInCurrentCategory.indexOf(element);
|
|
18078
|
+
if (currentEmojiIndex === -1) {
|
|
18079
|
+
return null;
|
|
18080
|
+
}
|
|
18081
|
+
// the remainder until the end of the row
|
|
18082
|
+
var remainder = countInRow - currentEmojiIndex % countInRow - 1;
|
|
18083
|
+
var firstInNextRow = currentEmojiIndex + remainder + 1;
|
|
18084
|
+
if (emojisInCurrentCategory[firstInNextRow]) {
|
|
18085
|
+
// if we have a next row, search in the next row for the last available emoji
|
|
18086
|
+
for (var p = currentEmojiIndex + countInRow; p % countInRow >= 0; p--) {
|
|
18087
|
+
if (emojisInCurrentCategory[p]) {
|
|
18088
|
+
return emojisInCurrentCategory[p];
|
|
18089
|
+
}
|
|
17997
18090
|
}
|
|
17998
|
-
return getElementInRow(allVisibleEmojis(nextVisibleCategory), 0, countInRow, indexInRow);
|
|
17999
18091
|
}
|
|
18000
|
-
var
|
|
18001
|
-
|
|
18092
|
+
var indexInRow = currentEmojiIndex % countInRow;
|
|
18093
|
+
var nextVisibleCategory = nextCategory(category);
|
|
18094
|
+
var emojisInNextCategory = allVisibleEmojis(nextVisibleCategory);
|
|
18095
|
+
if (emojisInNextCategory[indexInRow]) {
|
|
18096
|
+
return emojisInNextCategory[indexInRow];
|
|
18097
|
+
}
|
|
18098
|
+
return (_emojisInNextCategory = emojisInNextCategory.at(0)) != null ? _emojisInNextCategory : null;
|
|
18002
18099
|
}
|
|
18003
18100
|
|
|
18004
18101
|
function useCloseAllOpenToggles() {
|
|
@@ -18066,19 +18163,6 @@ function useOnMouseMove() {
|
|
|
18066
18163
|
}, [BodyRef, allowMouseMove, isMouseDisallowed]);
|
|
18067
18164
|
}
|
|
18068
18165
|
|
|
18069
|
-
function doesBrowserSupportCssHas() {
|
|
18070
|
-
// if env is not browser:
|
|
18071
|
-
if (typeof window === 'undefined' || typeof window.CSS === 'undefined') {
|
|
18072
|
-
return false;
|
|
18073
|
-
}
|
|
18074
|
-
try {
|
|
18075
|
-
return CSS.supports('selector(:has(*))');
|
|
18076
|
-
} catch (e) {
|
|
18077
|
-
return false;
|
|
18078
|
-
}
|
|
18079
|
-
}
|
|
18080
|
-
var browserSupportsCssHas = /*#__PURE__*/doesBrowserSupportCssHas();
|
|
18081
|
-
|
|
18082
18166
|
function useFocusSearchInput() {
|
|
18083
18167
|
var SearchInputRef = useSearchInputRef();
|
|
18084
18168
|
return React.useCallback(function () {
|
|
@@ -18152,27 +18236,22 @@ function useFilter() {
|
|
|
18152
18236
|
statusSearchResults: statusSearchResults
|
|
18153
18237
|
};
|
|
18154
18238
|
function onChange(inputValue) {
|
|
18155
|
-
|
|
18156
|
-
|
|
18239
|
+
var filter = filterRef.current;
|
|
18240
|
+
var nextValue = inputValue.toLowerCase();
|
|
18241
|
+
if (filter != null && filter[nextValue] || nextValue.length <= 1) {
|
|
18242
|
+
return applySearch(nextValue);
|
|
18157
18243
|
}
|
|
18158
|
-
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
|
|
18167
|
-
// If so, we need to search among all emojis
|
|
18168
|
-
return applySearch(nextValue);
|
|
18169
|
-
}
|
|
18170
|
-
setFilterRef(function (current) {
|
|
18171
|
-
var _Object$assign;
|
|
18172
|
-
return Object.assign(current, (_Object$assign = {}, _Object$assign[nextValue] = filterEmojiObjectByKeyword(longestMatch, nextValue), _Object$assign));
|
|
18173
|
-
});
|
|
18174
|
-
applySearch(nextValue);
|
|
18244
|
+
var longestMatch = findLongestMatch(nextValue, filter);
|
|
18245
|
+
if (!longestMatch) {
|
|
18246
|
+
// Can we even get here?
|
|
18247
|
+
// If so, we need to search among all emojis
|
|
18248
|
+
return applySearch(nextValue);
|
|
18249
|
+
}
|
|
18250
|
+
setFilterRef(function (current) {
|
|
18251
|
+
var _Object$assign;
|
|
18252
|
+
return Object.assign(current, (_Object$assign = {}, _Object$assign[nextValue] = filterEmojiObjectByKeyword(longestMatch, nextValue), _Object$assign));
|
|
18175
18253
|
});
|
|
18254
|
+
applySearch(nextValue);
|
|
18176
18255
|
}
|
|
18177
18256
|
}
|
|
18178
18257
|
function useApplySearch() {
|
|
@@ -18731,7 +18810,7 @@ var styles = /*#__PURE__*/stylesheet.create({
|
|
|
18731
18810
|
borderColor: 'var(--epr-picker-border-color)',
|
|
18732
18811
|
backgroundColor: 'var(--epr-bg-color)',
|
|
18733
18812
|
overflow: 'hidden',
|
|
18734
|
-
transition: '
|
|
18813
|
+
transition: 'height 0.3s ease-in-out, background-color 0.1s ease-in-out',
|
|
18735
18814
|
'*': {
|
|
18736
18815
|
boxSizing: 'border-box',
|
|
18737
18816
|
fontFamily: 'sans-serif'
|
|
@@ -18851,65 +18930,6 @@ function elementCountInRow(parent, element) {
|
|
|
18851
18930
|
var elementWidth = element.getBoundingClientRect().width;
|
|
18852
18931
|
return Math.floor(parentWidth / elementWidth);
|
|
18853
18932
|
}
|
|
18854
|
-
function elementIndexInRow(parent, element) {
|
|
18855
|
-
if (!parent || !element) {
|
|
18856
|
-
return 0;
|
|
18857
|
-
}
|
|
18858
|
-
var elementWidth = element.getBoundingClientRect().width;
|
|
18859
|
-
var elementLeft = element.getBoundingClientRect().left;
|
|
18860
|
-
var parentLeft = parent.getBoundingClientRect().left;
|
|
18861
|
-
return Math.floor((elementLeft - parentLeft) / elementWidth);
|
|
18862
|
-
}
|
|
18863
|
-
function rowNumber(parent, element) {
|
|
18864
|
-
if (!parent || !element) {
|
|
18865
|
-
return 0;
|
|
18866
|
-
}
|
|
18867
|
-
var elementHeight = element.getBoundingClientRect().height;
|
|
18868
|
-
var elementTop = element.getBoundingClientRect().top;
|
|
18869
|
-
var parentTop = parent.getBoundingClientRect().top;
|
|
18870
|
-
return Math.round((elementTop - parentTop) / elementHeight);
|
|
18871
|
-
}
|
|
18872
|
-
function hasNextRow(parent, element) {
|
|
18873
|
-
if (!parent || !element) {
|
|
18874
|
-
return false;
|
|
18875
|
-
}
|
|
18876
|
-
var elementHeight = element.getBoundingClientRect().height;
|
|
18877
|
-
var elementTop = element.getBoundingClientRect().top;
|
|
18878
|
-
var parentTop = parent.getBoundingClientRect().top;
|
|
18879
|
-
var parentHeight = parent.getBoundingClientRect().height;
|
|
18880
|
-
return Math.round(elementTop - parentTop + elementHeight) < parentHeight;
|
|
18881
|
-
}
|
|
18882
|
-
function getRowElements(elements, row, elementsInRow) {
|
|
18883
|
-
if (row === -1) {
|
|
18884
|
-
var lastRow = Math.floor((elements.length - 1) / elementsInRow);
|
|
18885
|
-
var firstElementIndex = lastRow * elementsInRow;
|
|
18886
|
-
var lastElementIndex = elements.length - 1;
|
|
18887
|
-
return elements.slice(firstElementIndex, lastElementIndex + 1);
|
|
18888
|
-
}
|
|
18889
|
-
return elements.slice(row * elementsInRow, (row + 1) * elementsInRow);
|
|
18890
|
-
}
|
|
18891
|
-
function getNextRowElements(allElements, currentRow, elementsInRow) {
|
|
18892
|
-
var nextRow = currentRow + 1;
|
|
18893
|
-
if (nextRow * elementsInRow > allElements.length) {
|
|
18894
|
-
return [];
|
|
18895
|
-
}
|
|
18896
|
-
return getRowElements(allElements, nextRow, elementsInRow);
|
|
18897
|
-
}
|
|
18898
|
-
function getElementInRow(elements, row, elementsInRow, indexInRow) {
|
|
18899
|
-
var rowElements = getRowElements(elements, row, elementsInRow);
|
|
18900
|
-
// get element, default to last
|
|
18901
|
-
return rowElements[indexInRow] || rowElements[rowElements.length - 1] || null;
|
|
18902
|
-
}
|
|
18903
|
-
function getElementInNextRow(allElements, currentRow, elementsInRow, index) {
|
|
18904
|
-
var nextRowElements = getNextRowElements(allElements, currentRow, elementsInRow);
|
|
18905
|
-
// return item in index, or last item in row
|
|
18906
|
-
return nextRowElements[index] || nextRowElements[nextRowElements.length - 1] || null;
|
|
18907
|
-
}
|
|
18908
|
-
function getElementInPrevRow(allElements, currentRow, elementsInRow, index) {
|
|
18909
|
-
var prevRowElements = getRowElements(allElements, currentRow - 1, elementsInRow);
|
|
18910
|
-
// default to last
|
|
18911
|
-
return prevRowElements[index] || prevRowElements[prevRowElements.length - 1] || null;
|
|
18912
|
-
}
|
|
18913
18933
|
function firstVisibleElementInContainer(parent, elements, maxVisibilityDiffThreshold) {
|
|
18914
18934
|
if (maxVisibilityDiffThreshold === void 0) {
|
|
18915
18935
|
maxVisibilityDiffThreshold = 0;
|
|
@@ -18937,15 +18957,17 @@ function hasNextElementSibling(element) {
|
|
|
18937
18957
|
return !!element.nextElementSibling;
|
|
18938
18958
|
}
|
|
18939
18959
|
function getLabelHeight(parentNode) {
|
|
18940
|
-
|
|
18941
|
-
|
|
18942
|
-
|
|
18960
|
+
if (!parentNode) {
|
|
18961
|
+
return DEFAULT_LABEL_HEIGHT;
|
|
18962
|
+
}
|
|
18963
|
+
var label = parentNode.querySelector(asSelectors(ClassNames.label));
|
|
18964
|
+
if (label) {
|
|
18943
18965
|
var height = label.getBoundingClientRect().height;
|
|
18944
|
-
// return height if label is not hidden
|
|
18945
18966
|
if (height > 0) {
|
|
18946
18967
|
return height;
|
|
18947
18968
|
}
|
|
18948
18969
|
}
|
|
18970
|
+
// fallback to default
|
|
18949
18971
|
return DEFAULT_LABEL_HEIGHT;
|
|
18950
18972
|
}
|
|
18951
18973
|
|
|
@@ -19161,56 +19183,6 @@ function parseNativeEmoji(unified) {
|
|
|
19161
19183
|
}).join('');
|
|
19162
19184
|
}
|
|
19163
19185
|
|
|
19164
|
-
var SUGGESTED_LS_KEY = 'epr_suggested';
|
|
19165
|
-
function getSuggested(mode) {
|
|
19166
|
-
try {
|
|
19167
|
-
var _window, _window$localStorage$, _window2;
|
|
19168
|
-
if (!((_window = window) != null && _window.localStorage)) {
|
|
19169
|
-
return [];
|
|
19170
|
-
}
|
|
19171
|
-
var recent = JSON.parse((_window$localStorage$ = (_window2 = window) == null ? void 0 : _window2.localStorage.getItem(SUGGESTED_LS_KEY)) != null ? _window$localStorage$ : '[]');
|
|
19172
|
-
if (mode === exports.SuggestionMode.FREQUENT) {
|
|
19173
|
-
return recent.sort(function (a, b) {
|
|
19174
|
-
return b.count - a.count;
|
|
19175
|
-
});
|
|
19176
|
-
}
|
|
19177
|
-
return recent;
|
|
19178
|
-
} catch (_unused) {
|
|
19179
|
-
return [];
|
|
19180
|
-
}
|
|
19181
|
-
}
|
|
19182
|
-
function setSuggested(emoji, skinTone) {
|
|
19183
|
-
var recent = getSuggested();
|
|
19184
|
-
var unified = emojiUnified(emoji, skinTone);
|
|
19185
|
-
var originalUnified = emojiUnified(emoji);
|
|
19186
|
-
var existing = recent.find(function (_ref) {
|
|
19187
|
-
var u = _ref.unified;
|
|
19188
|
-
return u === unified;
|
|
19189
|
-
});
|
|
19190
|
-
var nextList;
|
|
19191
|
-
if (existing) {
|
|
19192
|
-
nextList = [existing].concat(recent.filter(function (i) {
|
|
19193
|
-
return i !== existing;
|
|
19194
|
-
}));
|
|
19195
|
-
} else {
|
|
19196
|
-
existing = {
|
|
19197
|
-
unified: unified,
|
|
19198
|
-
original: originalUnified,
|
|
19199
|
-
count: 0
|
|
19200
|
-
};
|
|
19201
|
-
nextList = [existing].concat(recent);
|
|
19202
|
-
}
|
|
19203
|
-
existing.count++;
|
|
19204
|
-
nextList.length = Math.min(nextList.length, 14);
|
|
19205
|
-
try {
|
|
19206
|
-
var _window3;
|
|
19207
|
-
(_window3 = window) == null ? void 0 : _window3.localStorage.setItem(SUGGESTED_LS_KEY, JSON.stringify(nextList));
|
|
19208
|
-
// Prevents the change from being seen immediately.
|
|
19209
|
-
} catch (_unused2) {
|
|
19210
|
-
// ignore
|
|
19211
|
-
}
|
|
19212
|
-
}
|
|
19213
|
-
|
|
19214
19186
|
function isCustomCategory(category) {
|
|
19215
19187
|
return category.category === exports.Categories.CUSTOM;
|
|
19216
19188
|
}
|
|
@@ -19373,12 +19345,14 @@ function ClickableEmojiButton(_ref) {
|
|
|
19373
19345
|
children = _ref.children,
|
|
19374
19346
|
className = _ref.className,
|
|
19375
19347
|
_ref$noBackground = _ref.noBackground,
|
|
19376
|
-
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground
|
|
19348
|
+
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground,
|
|
19349
|
+
style = _ref.style;
|
|
19377
19350
|
return React.createElement(Button, {
|
|
19378
19351
|
className: flairup.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),
|
|
19379
19352
|
"data-unified": unified,
|
|
19380
19353
|
"aria-label": getAriaLabel(emojiNames),
|
|
19381
|
-
"data-full-name": emojiNames
|
|
19354
|
+
"data-full-name": emojiNames,
|
|
19355
|
+
style: style
|
|
19382
19356
|
}, children);
|
|
19383
19357
|
}
|
|
19384
19358
|
function getAriaLabel(emojiNames) {
|
|
@@ -19568,7 +19542,8 @@ function ClickableEmoji(_ref) {
|
|
|
19568
19542
|
getEmojiUrl = _ref.getEmojiUrl,
|
|
19569
19543
|
className = _ref.className,
|
|
19570
19544
|
_ref$noBackground = _ref.noBackground,
|
|
19571
|
-
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground
|
|
19545
|
+
noBackground = _ref$noBackground === void 0 ? false : _ref$noBackground,
|
|
19546
|
+
style = _ref.style;
|
|
19572
19547
|
var hasVariations = emojiHasVariations(emoji);
|
|
19573
19548
|
return React.createElement(ClickableEmojiButton, {
|
|
19574
19549
|
hasVariations: hasVariations,
|
|
@@ -19577,7 +19552,8 @@ function ClickableEmoji(_ref) {
|
|
|
19577
19552
|
hiddenOnSearch: hiddenOnSearch,
|
|
19578
19553
|
emojiNames: emojiNames(emoji),
|
|
19579
19554
|
unified: unified,
|
|
19580
|
-
noBackground: noBackground
|
|
19555
|
+
noBackground: noBackground,
|
|
19556
|
+
style: style
|
|
19581
19557
|
}, React.createElement(ViewOnlyEmoji, {
|
|
19582
19558
|
unified: unified,
|
|
19583
19559
|
emoji: emoji,
|
|
@@ -19707,6 +19683,9 @@ var styles$6 = /*#__PURE__*/stylesheet.create({
|
|
|
19707
19683
|
|
|
19708
19684
|
function useOnScroll(BodyRef) {
|
|
19709
19685
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
19686
|
+
var _useState = React.useState(0),
|
|
19687
|
+
scrollTop = _useState[0],
|
|
19688
|
+
setScrollTop = _useState[1];
|
|
19710
19689
|
React.useEffect(function () {
|
|
19711
19690
|
var bodyRef = BodyRef.current;
|
|
19712
19691
|
if (!bodyRef) {
|
|
@@ -19716,12 +19695,78 @@ function useOnScroll(BodyRef) {
|
|
|
19716
19695
|
passive: true
|
|
19717
19696
|
});
|
|
19718
19697
|
function onScroll() {
|
|
19698
|
+
var _bodyRef$scrollTop;
|
|
19699
|
+
setScrollTop((_bodyRef$scrollTop = bodyRef == null ? void 0 : bodyRef.scrollTop) != null ? _bodyRef$scrollTop : 0);
|
|
19719
19700
|
closeAllOpenToggles();
|
|
19720
19701
|
}
|
|
19721
19702
|
return function () {
|
|
19722
19703
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('scroll', onScroll);
|
|
19723
19704
|
};
|
|
19724
19705
|
}, [BodyRef, closeAllOpenToggles]);
|
|
19706
|
+
return scrollTop;
|
|
19707
|
+
}
|
|
19708
|
+
|
|
19709
|
+
var EMOJI_SIZE_DEFAULT = 32;
|
|
19710
|
+
function useCategoryHeight(emojiCount) {
|
|
19711
|
+
var EmojiListRef = useEmojiListRef();
|
|
19712
|
+
var _useReactionsModeStat = useReactionsModeState(),
|
|
19713
|
+
isReactionsMode = _useReactionsModeStat[0];
|
|
19714
|
+
var PickerMainRef = usePickerMainRef();
|
|
19715
|
+
var emojiSizeRef = React.useRef();
|
|
19716
|
+
var _React$useState = React.useState(),
|
|
19717
|
+
dimensions = _React$useState[0],
|
|
19718
|
+
setDimensions = _React$useState[1];
|
|
19719
|
+
// Helper to compute and store dimensions based on current DOM
|
|
19720
|
+
var computeAndSetDimensions = React.useCallback(function () {
|
|
19721
|
+
var _ref;
|
|
19722
|
+
var listEl = EmojiListRef.current;
|
|
19723
|
+
if (!listEl) return;
|
|
19724
|
+
var emojiElement = listEl.querySelector(EmojiButtonSelector);
|
|
19725
|
+
var measured = emojiElement == null ? void 0 : emojiElement.clientHeight;
|
|
19726
|
+
var emojiSize = (_ref = measured != null ? measured : emojiSizeRef.current) != null ? _ref : EMOJI_SIZE_DEFAULT;
|
|
19727
|
+
emojiSizeRef.current = emojiSize;
|
|
19728
|
+
var pickerWidth = listEl.clientWidth;
|
|
19729
|
+
if (pickerWidth === 0 || emojiSize === 0) return;
|
|
19730
|
+
var emojisPerRow = Math.max(1, Math.floor(pickerWidth / emojiSize));
|
|
19731
|
+
var rowCount = Math.ceil(emojiCount / emojisPerRow);
|
|
19732
|
+
var categoryHeight = rowCount * emojiSize;
|
|
19733
|
+
setDimensions({
|
|
19734
|
+
categoryHeight: categoryHeight,
|
|
19735
|
+
emojisPerRow: emojisPerRow,
|
|
19736
|
+
emojiSize: emojiSize
|
|
19737
|
+
});
|
|
19738
|
+
}, [EmojiListRef, emojiCount]);
|
|
19739
|
+
// Recompute on data-count changes and when reactions mode toggles
|
|
19740
|
+
React.useEffect(function () {
|
|
19741
|
+
computeAndSetDimensions();
|
|
19742
|
+
}, [emojiCount, isReactionsMode, computeAndSetDimensions]);
|
|
19743
|
+
// Listen to transitionend on the picker root (where height transition occurs)
|
|
19744
|
+
React.useEffect(function () {
|
|
19745
|
+
var rootEl = PickerMainRef.current;
|
|
19746
|
+
if (!rootEl) return;
|
|
19747
|
+
var handler = function handler(e) {
|
|
19748
|
+
var te = e;
|
|
19749
|
+
var prop = te.propertyName;
|
|
19750
|
+
if (prop === 'width' || prop === 'max-width' || prop === 'min-width' || prop === 'height' || prop === 'max-height' || prop === 'min-height') {
|
|
19751
|
+
if (typeof queueMicrotask === 'function') {
|
|
19752
|
+
queueMicrotask(function () {
|
|
19753
|
+
return computeAndSetDimensions();
|
|
19754
|
+
});
|
|
19755
|
+
} else {
|
|
19756
|
+
requestAnimationFrame(function () {
|
|
19757
|
+
return computeAndSetDimensions();
|
|
19758
|
+
});
|
|
19759
|
+
}
|
|
19760
|
+
}
|
|
19761
|
+
};
|
|
19762
|
+
rootEl.addEventListener('transitionend', handler, {
|
|
19763
|
+
passive: true
|
|
19764
|
+
});
|
|
19765
|
+
return function () {
|
|
19766
|
+
rootEl.removeEventListener('transitionend', handler);
|
|
19767
|
+
};
|
|
19768
|
+
}, [PickerMainRef, computeAndSetDimensions]);
|
|
19769
|
+
return dimensions;
|
|
19725
19770
|
}
|
|
19726
19771
|
|
|
19727
19772
|
function useIsEmojiHidden() {
|
|
@@ -19744,7 +19789,8 @@ function EmojiCategory(_ref) {
|
|
|
19744
19789
|
var categoryConfig = _ref.categoryConfig,
|
|
19745
19790
|
children = _ref.children,
|
|
19746
19791
|
hidden = _ref.hidden,
|
|
19747
|
-
hiddenOnSearch = _ref.hiddenOnSearch
|
|
19792
|
+
hiddenOnSearch = _ref.hiddenOnSearch,
|
|
19793
|
+
height = _ref.height;
|
|
19748
19794
|
var category = categoryFromCategoryConfig(categoryConfig);
|
|
19749
19795
|
var categoryName = categoryNameFromCategoryConfig(categoryConfig);
|
|
19750
19796
|
return React.createElement("li", {
|
|
@@ -19754,15 +19800,16 @@ function EmojiCategory(_ref) {
|
|
|
19754
19800
|
}, React.createElement("h2", {
|
|
19755
19801
|
className: flairup.cx(styles$7.label)
|
|
19756
19802
|
}, categoryName), React.createElement("div", {
|
|
19757
|
-
className: flairup.cx(styles$7.categoryContent)
|
|
19803
|
+
className: flairup.cx(styles$7.categoryContent),
|
|
19804
|
+
style: {
|
|
19805
|
+
height: height
|
|
19806
|
+
}
|
|
19758
19807
|
}, children));
|
|
19759
19808
|
}
|
|
19760
19809
|
var styles$7 = /*#__PURE__*/stylesheet.create({
|
|
19761
19810
|
category: {
|
|
19762
19811
|
'.': ClassNames.category,
|
|
19763
|
-
|
|
19764
|
-
display: 'none'
|
|
19765
|
-
}
|
|
19812
|
+
position: 'relative'
|
|
19766
19813
|
},
|
|
19767
19814
|
categoryContent: {
|
|
19768
19815
|
'.': ClassNames.categoryContent,
|
|
@@ -19794,115 +19841,100 @@ var styles$7 = /*#__PURE__*/stylesheet.create({
|
|
|
19794
19841
|
}
|
|
19795
19842
|
});
|
|
19796
19843
|
|
|
19797
|
-
|
|
19798
|
-
|
|
19799
|
-
var _React$useState = React.useState(isEverMounted),
|
|
19800
|
-
isMounted = _React$useState[0],
|
|
19801
|
-
setIsMounted = _React$useState[1];
|
|
19802
|
-
React.useEffect(function () {
|
|
19803
|
-
setIsMounted(true);
|
|
19804
|
-
isEverMounted = true;
|
|
19805
|
-
}, []);
|
|
19806
|
-
return isMounted || isEverMounted;
|
|
19807
|
-
}
|
|
19808
|
-
|
|
19809
|
-
function Suggested(_ref) {
|
|
19810
|
-
var categoryConfig = _ref.categoryConfig;
|
|
19811
|
-
var _useUpdateSuggested = useUpdateSuggested(),
|
|
19812
|
-
suggestedUpdated = _useUpdateSuggested[0];
|
|
19813
|
-
var isMounted = useIsEverMounted();
|
|
19814
|
-
var suggestedEmojisModeConfig = useSuggestedEmojisModeConfig();
|
|
19815
|
-
var getEmojiUrl = useGetEmojiUrlConfig();
|
|
19816
|
-
var suggested = React.useMemo(function () {
|
|
19817
|
-
var _getSuggested;
|
|
19818
|
-
return (_getSuggested = getSuggested(suggestedEmojisModeConfig)) != null ? _getSuggested : [];
|
|
19819
|
-
},
|
|
19820
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19821
|
-
[suggestedUpdated, suggestedEmojisModeConfig]);
|
|
19822
|
-
var emojiStyle = useEmojiStyleConfig();
|
|
19823
|
-
var isEmojiDisallowed = useIsEmojiDisallowed();
|
|
19824
|
-
if (!isMounted) {
|
|
19825
|
-
return null;
|
|
19826
|
-
}
|
|
19827
|
-
return React.createElement(EmojiCategory, {
|
|
19828
|
-
categoryConfig: categoryConfig,
|
|
19829
|
-
hiddenOnSearch: true,
|
|
19830
|
-
hidden: suggested.length === 0
|
|
19831
|
-
}, suggested.map(function (suggestedItem) {
|
|
19832
|
-
var emoji = emojiByUnified(suggestedItem.original);
|
|
19833
|
-
if (!emoji) {
|
|
19834
|
-
return null;
|
|
19835
|
-
}
|
|
19836
|
-
if (isEmojiDisallowed(emoji)) {
|
|
19837
|
-
return null;
|
|
19838
|
-
}
|
|
19839
|
-
return React.createElement(ClickableEmoji, {
|
|
19840
|
-
showVariations: false,
|
|
19841
|
-
unified: suggestedItem.unified,
|
|
19842
|
-
emojiStyle: emojiStyle,
|
|
19843
|
-
emoji: emoji,
|
|
19844
|
-
key: suggestedItem.unified,
|
|
19845
|
-
getEmojiUrl: getEmojiUrl
|
|
19846
|
-
});
|
|
19847
|
-
}));
|
|
19848
|
-
}
|
|
19849
|
-
|
|
19850
|
-
function EmojiList() {
|
|
19844
|
+
function EmojiList(_ref) {
|
|
19845
|
+
var scrollTop = _ref.scrollTop;
|
|
19851
19846
|
var categories = useCategoriesConfig();
|
|
19852
|
-
var
|
|
19847
|
+
var _React$useState = React.useState({}),
|
|
19848
|
+
categoryHeights = _React$useState[0],
|
|
19849
|
+
setCategoryHeights = _React$useState[1];
|
|
19850
|
+
var EmojiListRef = useEmojiListRef();
|
|
19851
|
+
var getEmojisByCategory = useGetEmojisByCategory();
|
|
19852
|
+
var labelHeight = getLabelHeight(EmojiListRef.current);
|
|
19853
|
+
var topOffset = 0;
|
|
19853
19854
|
return React.createElement("ul", {
|
|
19854
|
-
className: flairup.cx(styles$8.emojiList)
|
|
19855
|
+
className: flairup.cx(styles$8.emojiList),
|
|
19856
|
+
ref: EmojiListRef
|
|
19855
19857
|
}, categories.map(function (categoryConfig) {
|
|
19856
19858
|
var category = categoryFromCategoryConfig(categoryConfig);
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
|
|
19861
|
-
});
|
|
19859
|
+
var currentOffset = topOffset;
|
|
19860
|
+
var categoryHeight = categoryHeights[category];
|
|
19861
|
+
if (categoryHeight) {
|
|
19862
|
+
topOffset += categoryHeight + labelHeight;
|
|
19862
19863
|
}
|
|
19863
19864
|
return React.createElement(React.Suspense, {
|
|
19864
19865
|
key: category
|
|
19865
19866
|
}, React.createElement(RenderCategory, {
|
|
19866
|
-
|
|
19867
|
+
categoryEmojis: getEmojisByCategory(category),
|
|
19867
19868
|
categoryConfig: categoryConfig,
|
|
19868
|
-
|
|
19869
|
+
topOffset: currentOffset,
|
|
19870
|
+
onHeightReady: function onHeightReady(height) {
|
|
19871
|
+
if (categoryHeights[category] !== height) {
|
|
19872
|
+
setCategoryHeights(function (prev) {
|
|
19873
|
+
var _extends2;
|
|
19874
|
+
return _extends({}, prev, (_extends2 = {}, _extends2[category] = height, _extends2));
|
|
19875
|
+
});
|
|
19876
|
+
}
|
|
19877
|
+
},
|
|
19878
|
+
scrollTop: scrollTop
|
|
19869
19879
|
}));
|
|
19870
19880
|
}));
|
|
19871
19881
|
}
|
|
19872
|
-
function RenderCategory(
|
|
19873
|
-
var
|
|
19874
|
-
categoryConfig =
|
|
19875
|
-
|
|
19882
|
+
function RenderCategory(_ref2) {
|
|
19883
|
+
var categoryEmojis = _ref2.categoryEmojis,
|
|
19884
|
+
categoryConfig = _ref2.categoryConfig,
|
|
19885
|
+
topOffset = _ref2.topOffset,
|
|
19886
|
+
onHeightReady = _ref2.onHeightReady,
|
|
19887
|
+
scrollTop = _ref2.scrollTop;
|
|
19876
19888
|
var isEmojiHidden = useIsEmojiHidden();
|
|
19877
19889
|
var lazyLoadEmojis = useLazyLoadEmojisConfig();
|
|
19878
19890
|
var emojiStyle = useEmojiStyleConfig();
|
|
19879
|
-
var isPastInitialLoad = useIsPastInitialLoad();
|
|
19880
19891
|
var _useActiveSkinToneSta = useActiveSkinToneState(),
|
|
19881
19892
|
activeSkinTone = _useActiveSkinToneSta[0];
|
|
19882
19893
|
var isEmojiDisallowed = useIsEmojiDisallowed();
|
|
19883
19894
|
var getEmojiUrl = useGetEmojiUrlConfig();
|
|
19884
19895
|
var showVariations = !useSkinTonesDisabledConfig();
|
|
19885
|
-
|
|
19886
|
-
// This way the user gets to actually see something and not wait for the whole picker to render.
|
|
19887
|
-
var emojisToPush = !isPastInitialLoad && renderdCategoriesCountRef.current > 0 ? [] : emojisByCategory(category);
|
|
19888
|
-
if (emojisToPush.length > 0) {
|
|
19889
|
-
renderdCategoriesCountRef.current++;
|
|
19890
|
-
}
|
|
19896
|
+
var BodyRef = useBodyRef();
|
|
19891
19897
|
var hiddenCounter = 0;
|
|
19892
|
-
var
|
|
19893
|
-
|
|
19898
|
+
var virtualizedCounter = 0;
|
|
19899
|
+
var emojisToPush = categoryEmojis.filter(function (emoji) {
|
|
19894
19900
|
var _isEmojiHidden = isEmojiHidden(emoji),
|
|
19895
19901
|
failedToLoad = _isEmojiHidden.failedToLoad,
|
|
19896
19902
|
filteredOut = _isEmojiHidden.filteredOut,
|
|
19897
19903
|
hidden = _isEmojiHidden.hidden;
|
|
19904
|
+
return !failedToLoad && !filteredOut && !hidden;
|
|
19905
|
+
});
|
|
19906
|
+
var dimensions = useCategoryHeight(emojisToPush.length);
|
|
19907
|
+
React.useEffect(function () {
|
|
19908
|
+
if (dimensions) {
|
|
19909
|
+
onHeightReady(dimensions.categoryHeight);
|
|
19910
|
+
}
|
|
19911
|
+
}, [dimensions, onHeightReady, emojisToPush.length]);
|
|
19912
|
+
var emojis = emojisToPush.reduce(function (accumulator, emoji, index) {
|
|
19913
|
+
var _BodyRef$current$clie, _BodyRef$current;
|
|
19914
|
+
var unified = emojiUnified(emoji, activeSkinTone);
|
|
19915
|
+
var _isEmojiHidden2 = isEmojiHidden(emoji),
|
|
19916
|
+
failedToLoad = _isEmojiHidden2.failedToLoad,
|
|
19917
|
+
filteredOut = _isEmojiHidden2.filteredOut,
|
|
19918
|
+
hidden = _isEmojiHidden2.hidden;
|
|
19898
19919
|
var isDisallowed = isEmojiDisallowed(emoji);
|
|
19899
19920
|
if (hidden || isDisallowed) {
|
|
19900
19921
|
hiddenCounter++;
|
|
19901
19922
|
}
|
|
19902
|
-
if (isDisallowed) {
|
|
19903
|
-
return
|
|
19923
|
+
if (isDisallowed || failedToLoad || filteredOut) {
|
|
19924
|
+
return accumulator;
|
|
19904
19925
|
}
|
|
19905
|
-
|
|
19926
|
+
var style = getEmojiPositionStyle(dimensions, index - hiddenCounter);
|
|
19927
|
+
if (shouldVirtualize({
|
|
19928
|
+
scrollTop: scrollTop,
|
|
19929
|
+
clientHeight: (_BodyRef$current$clie = (_BodyRef$current = BodyRef.current) == null ? void 0 : _BodyRef$current.clientHeight) != null ? _BodyRef$current$clie : 0,
|
|
19930
|
+
topOffset: topOffset,
|
|
19931
|
+
style: style,
|
|
19932
|
+
dimensions: dimensions
|
|
19933
|
+
})) {
|
|
19934
|
+
virtualizedCounter++;
|
|
19935
|
+
return accumulator;
|
|
19936
|
+
}
|
|
19937
|
+
accumulator.push(React.createElement(ClickableEmoji, {
|
|
19906
19938
|
showVariations: showVariations,
|
|
19907
19939
|
key: unified,
|
|
19908
19940
|
emoji: emoji,
|
|
@@ -19911,14 +19943,19 @@ function RenderCategory(_ref) {
|
|
|
19911
19943
|
hiddenOnSearch: filteredOut,
|
|
19912
19944
|
emojiStyle: emojiStyle,
|
|
19913
19945
|
lazyLoad: lazyLoadEmojis,
|
|
19914
|
-
getEmojiUrl: getEmojiUrl
|
|
19915
|
-
|
|
19916
|
-
|
|
19946
|
+
getEmojiUrl: getEmojiUrl,
|
|
19947
|
+
style: _extends({}, style, {
|
|
19948
|
+
position: 'absolute'
|
|
19949
|
+
})
|
|
19950
|
+
}));
|
|
19951
|
+
return accumulator;
|
|
19952
|
+
}, []);
|
|
19917
19953
|
return React.createElement(EmojiCategory, {
|
|
19918
19954
|
categoryConfig: categoryConfig,
|
|
19955
|
+
height: dimensions == null ? void 0 : dimensions.categoryHeight,
|
|
19919
19956
|
// Indicates that there are no visible emojis
|
|
19920
19957
|
// Hence, the category should be hidden
|
|
19921
|
-
hidden: hiddenCounter === emojis.length
|
|
19958
|
+
hidden: hiddenCounter === emojis.length && virtualizedCounter === 0
|
|
19922
19959
|
}, emojis);
|
|
19923
19960
|
}
|
|
19924
19961
|
var styles$8 = /*#__PURE__*/stylesheet.create({
|
|
@@ -19929,6 +19966,26 @@ var styles$8 = /*#__PURE__*/stylesheet.create({
|
|
|
19929
19966
|
padding: '0'
|
|
19930
19967
|
}
|
|
19931
19968
|
});
|
|
19969
|
+
function getEmojiPositionStyle(dimensions, index) {
|
|
19970
|
+
return dimensions ? {
|
|
19971
|
+
top: Math.floor(index / dimensions.emojisPerRow) * dimensions.emojiSize,
|
|
19972
|
+
left: index % dimensions.emojisPerRow * dimensions.emojiSize
|
|
19973
|
+
} : undefined;
|
|
19974
|
+
}
|
|
19975
|
+
function shouldVirtualize(_ref3) {
|
|
19976
|
+
var scrollTop = _ref3.scrollTop,
|
|
19977
|
+
clientHeight = _ref3.clientHeight,
|
|
19978
|
+
topOffset = _ref3.topOffset,
|
|
19979
|
+
style = _ref3.style,
|
|
19980
|
+
dimensions = _ref3.dimensions;
|
|
19981
|
+
if (!style || !dimensions) {
|
|
19982
|
+
return false;
|
|
19983
|
+
}
|
|
19984
|
+
var emojiTop = topOffset + style.top;
|
|
19985
|
+
var emojiBottom = emojiTop + dimensions.emojiSize;
|
|
19986
|
+
var isVisible = emojiBottom + dimensions.emojiSize * 2 >= scrollTop && emojiTop <= scrollTop + clientHeight + dimensions.emojiSize;
|
|
19987
|
+
return !isVisible;
|
|
19988
|
+
}
|
|
19932
19989
|
|
|
19933
19990
|
var SVGTriangle = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjMuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI1MHB4IgoJIGhlaWdodD0iMTVweCIgdmlld0JveD0iMCAwIDUwIDE1IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MCAxNSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnIGlkPSJMYXllcl8xIj4KPC9nPgo8ZyBpZD0iTGF5ZXJfMiI+Cgk8cGF0aCBmaWxsPSIjRkZGRkZGIiBzdHJva2U9IiNFOEU3RTciIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgZD0iTTEuODYtMC40M2w5LjgzLDExLjUzYzAuNTksMC42OSwxLjU2LDAuNjksMi4xNCwwbDkuODMtMTEuNTMiLz4KCTxwYXRoIGZpbGw9IiMwMTAyMDIiIHN0cm9rZT0iIzE1MTYxNyIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBkPSJNMjYuODYtMC40M2w5LjgzLDExLjUzYzAuNTksMC42OSwxLjU2LDAuNjksMi4xNCwwbDkuODMtMTEuNTMiLz4KPC9nPgo8L3N2Zz4=';
|
|
19934
19991
|
|
|
@@ -20096,13 +20153,15 @@ var styles$9 = /*#__PURE__*/stylesheet.create( /*#__PURE__*/_extends({
|
|
|
20096
20153
|
|
|
20097
20154
|
function Body() {
|
|
20098
20155
|
var BodyRef = useBodyRef();
|
|
20099
|
-
useOnScroll(BodyRef);
|
|
20156
|
+
var scrollTop = useOnScroll(BodyRef);
|
|
20100
20157
|
useMouseDownHandlers(BodyRef, MOUSE_EVENT_SOURCE.PICKER);
|
|
20101
20158
|
useOnMouseMove();
|
|
20102
20159
|
return React.createElement("div", {
|
|
20103
20160
|
className: flairup.cx(styles$a.body, commonInteractionStyles.hiddenOnReactions),
|
|
20104
20161
|
ref: BodyRef
|
|
20105
|
-
}, React.createElement(EmojiVariationPicker, null), React.createElement(EmojiList,
|
|
20162
|
+
}, React.createElement(EmojiVariationPicker, null), React.createElement(EmojiList, {
|
|
20163
|
+
scrollTop: scrollTop
|
|
20164
|
+
}));
|
|
20106
20165
|
}
|
|
20107
20166
|
var styles$a = /*#__PURE__*/stylesheet.create({
|
|
20108
20167
|
body: {
|
|
@@ -20807,21 +20866,6 @@ var styles$h = /*#__PURE__*/stylesheet.create( /*#__PURE__*/_extends({
|
|
|
20807
20866
|
backgroundPositionY: '-40px'
|
|
20808
20867
|
}), /*#__PURE__*/darkMode('btnClearSearch', HoverDark)));
|
|
20809
20868
|
|
|
20810
|
-
var SCOPE = /*#__PURE__*/asSelectors(ClassNames.emojiPicker) + " " + /*#__PURE__*/asSelectors(ClassNames.emojiList);
|
|
20811
|
-
var EMOJI_BUTTON = /*#__PURE__*/['button', asSelectors(ClassNames.emoji)].join('');
|
|
20812
|
-
var CATEGORY = /*#__PURE__*/asSelectors(ClassNames.category);
|
|
20813
|
-
function CssSearch(_ref) {
|
|
20814
|
-
var value = _ref.value;
|
|
20815
|
-
if (!value) {
|
|
20816
|
-
return null;
|
|
20817
|
-
}
|
|
20818
|
-
var q = genQuery(value);
|
|
20819
|
-
return React.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 ");
|
|
20820
|
-
}
|
|
20821
|
-
function genQuery(value) {
|
|
20822
|
-
return [EMOJI_BUTTON, '[data-full-name*="', getNormalizedSearchTerm(value), '"]'].join('');
|
|
20823
|
-
}
|
|
20824
|
-
|
|
20825
20869
|
var SVGMagnifier = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjMuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjQwcHgiIHZpZXdCb3g9IjAgMCAyMCA0MCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjAgNDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iIzg2ODY4NiIgZD0iTTEyLDguODFjMCwyLjA4LTEuNjgsMy43Ni0zLjc2LDMuNzZjLTIuMDgsMC0zLjc2LTEuNjgtMy43Ni0zLjc2CgljMC0yLjA4LDEuNjgtMy43NiwzLjc2LTMuNzZDMTAuMzIsNS4wNSwxMiw2LjczLDEyLDguODF6IE0xMS4yMywxMi43MmMtMC44MywwLjY0LTEuODcsMS4wMS0yLjk5LDEuMDFjLTIuNzIsMC00LjkyLTIuMi00LjkyLTQuOTIKCWMwLTIuNzIsMi4yLTQuOTIsNC45Mi00LjkyYzIuNzIsMCw0LjkyLDIuMiw0LjkyLDQuOTJjMCwxLjEzLTAuMzgsMi4xNi0xLjAxLDIuOTlsMy45NCwzLjkzYzAuMjUsMC4yNSwwLjI1LDAuNjYsMCwwLjkyCgljLTAuMjUsMC4yNS0wLjY2LDAuMjUtMC45MiwwTDExLjIzLDEyLjcyeiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iI0MwQzBCRiIgZD0iTTEyLDI4LjgxYzAsMi4wOC0xLjY4LDMuNzYtMy43NiwzLjc2Yy0yLjA4LDAtMy43Ni0xLjY4LTMuNzYtMy43NgoJYzAtMi4wOCwxLjY4LTMuNzYsMy43Ni0zLjc2QzEwLjMyLDI1LjA1LDEyLDI2LjczLDEyLDI4LjgxeiBNMTEuMjMsMzIuNzJjLTAuODMsMC42NC0xLjg3LDEuMDEtMi45OSwxLjAxCgljLTIuNzIsMC00LjkyLTIuMi00LjkyLTQuOTJjMC0yLjcyLDIuMi00LjkyLDQuOTItNC45MmMyLjcyLDAsNC45MiwyLjIsNC45Miw0LjkyYzAsMS4xMy0wLjM4LDIuMTYtMS4wMSwyLjk5bDMuOTQsMy45MwoJYzAuMjUsMC4yNSwwLjI1LDAuNjYsMCwwLjkyYy0wLjI1LDAuMjUtMC42NiwwLjI1LTAuOTIsMEwxMS4yMywzMi43MnoiLz4KPC9zdmc+';
|
|
20826
20870
|
|
|
20827
20871
|
function IcnSearch() {
|
|
@@ -20859,9 +20903,6 @@ function SearchContainer() {
|
|
|
20859
20903
|
}, React.createElement(Search, null), isSkinToneInSearch ? React.createElement(SkinTonePicker, null) : null);
|
|
20860
20904
|
}
|
|
20861
20905
|
function Search() {
|
|
20862
|
-
var _useState = React.useState(0),
|
|
20863
|
-
inc = _useState[0],
|
|
20864
|
-
setInc = _useState[1];
|
|
20865
20906
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
20866
20907
|
var SearchInputRef = useSearchInputRef();
|
|
20867
20908
|
var placeholder = useSearchPlaceHolderConfig();
|
|
@@ -20874,9 +20915,7 @@ function Search() {
|
|
|
20874
20915
|
var value = input == null ? void 0 : input.value;
|
|
20875
20916
|
return React.createElement(Relative, {
|
|
20876
20917
|
className: flairup.cx(styles$j.searchContainer)
|
|
20877
|
-
}, React.createElement(
|
|
20878
|
-
value: value
|
|
20879
|
-
}), React.createElement("input", {
|
|
20918
|
+
}, React.createElement("input", {
|
|
20880
20919
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
20881
20920
|
autoFocus: autoFocus,
|
|
20882
20921
|
"aria-label": 'Type to search for an emoji',
|
|
@@ -20887,7 +20926,6 @@ function Search() {
|
|
|
20887
20926
|
placeholder: placeholder,
|
|
20888
20927
|
onChange: function onChange(event) {
|
|
20889
20928
|
var _event$target$value, _event$target;
|
|
20890
|
-
setInc(inc + 1);
|
|
20891
20929
|
_onChange((_event$target$value = event == null ? void 0 : (_event$target = event.target) == null ? void 0 : _event$target.value) != null ? _event$target$value : value);
|
|
20892
20930
|
},
|
|
20893
20931
|
ref: SearchInputRef
|