emoji-picker-react 4.14.0 → 4.14.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/components/context/PickerContext.d.ts +1 -0
- package/dist/emoji-picker-react.cjs.development.js +48 -12
- 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 +48 -12
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/hooks/preloadEmoji.d.ts +1 -1
- package/dist/hooks/useActiveCategoryScrollDetection.d.ts +4 -1
- package/dist/hooks/useEmojiVirtualization.d.ts +2 -1
- package/dist/hooks/useIsMounted.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/body/EmojiList.tsx +5 -1
- package/src/components/context/PickerContext.tsx +11 -2
- package/src/components/navigation/CategoryNavigation.tsx +3 -1
- package/src/hooks/preloadEmoji.ts +1 -1
- package/src/hooks/useActiveCategoryScrollDetection.ts +17 -5
- package/src/hooks/useCategoryHeight.ts +11 -2
- package/src/hooks/useEmojiVirtualization.tsx +10 -3
- package/src/hooks/useIsMounted.ts +11 -0
- package/dist/hooks/useIsEverMounted.d.ts +0 -1
- package/src/hooks/useIsEverMounted.ts +0 -14
|
@@ -338,6 +338,7 @@ function PickerContextProvider(_ref) {
|
|
|
338
338
|
var _useState = useState(false),
|
|
339
339
|
isPastInitialLoad = _useState[0],
|
|
340
340
|
setIsPastInitialLoad = _useState[1];
|
|
341
|
+
var visibleCategoriesState = useState([]);
|
|
341
342
|
useMarkInitialLoad(setIsPastInitialLoad);
|
|
342
343
|
return createElement(PickerContext.Provider, {
|
|
343
344
|
value: {
|
|
@@ -353,7 +354,8 @@ function PickerContextProvider(_ref) {
|
|
|
353
354
|
searchTerm: searchTerm,
|
|
354
355
|
skinToneFanOpenState: skinToneFanOpenState,
|
|
355
356
|
suggestedUpdateState: suggestedUpdateState,
|
|
356
|
-
reactionsModeState: reactionsModeState
|
|
357
|
+
reactionsModeState: reactionsModeState,
|
|
358
|
+
visibleCategoriesState: visibleCategoriesState
|
|
357
359
|
}
|
|
358
360
|
}, children);
|
|
359
361
|
}
|
|
@@ -382,7 +384,10 @@ var PickerContext = /*#__PURE__*/createContext({
|
|
|
382
384
|
}],
|
|
383
385
|
skinToneFanOpenState: [false, function () {}],
|
|
384
386
|
suggestedUpdateState: [/*#__PURE__*/Date.now(), function () {}],
|
|
385
|
-
reactionsModeState: [false, function () {}]
|
|
387
|
+
reactionsModeState: [false, function () {}],
|
|
388
|
+
visibleCategoriesState: [[], function () {
|
|
389
|
+
return [];
|
|
390
|
+
}]
|
|
386
391
|
});
|
|
387
392
|
function useFilterRef() {
|
|
388
393
|
var _React$useContext = useContext(PickerContext),
|
|
@@ -429,9 +434,14 @@ function useSkinToneFanOpenState() {
|
|
|
429
434
|
skinToneFanOpenState = _React$useContext10.skinToneFanOpenState;
|
|
430
435
|
return skinToneFanOpenState;
|
|
431
436
|
}
|
|
432
|
-
function
|
|
437
|
+
function useVisibleCategoriesState() {
|
|
433
438
|
var _React$useContext12 = useContext(PickerContext),
|
|
434
|
-
|
|
439
|
+
visibleCategoriesState = _React$useContext12.visibleCategoriesState;
|
|
440
|
+
return visibleCategoriesState;
|
|
441
|
+
}
|
|
442
|
+
function useUpdateSuggested() {
|
|
443
|
+
var _React$useContext13 = useContext(PickerContext),
|
|
444
|
+
suggestedUpdateState = _React$useContext13.suggestedUpdateState;
|
|
435
445
|
var suggestedUpdated = suggestedUpdateState[0],
|
|
436
446
|
setsuggestedUpdate = suggestedUpdateState[1];
|
|
437
447
|
return [suggestedUpdated, function updateSuggested() {
|
|
@@ -18695,7 +18705,7 @@ function hasModifier(event) {
|
|
|
18695
18705
|
}
|
|
18696
18706
|
|
|
18697
18707
|
// eslint-disable-next-line max-params
|
|
18698
|
-
function
|
|
18708
|
+
function preloadEmojiIfNeeded(emoji, emojiStyles, scrollTop, clientHeight, topOffset, style, dimensions, getEmojiUrl) {
|
|
18699
18709
|
if (!emoji) {
|
|
18700
18710
|
return;
|
|
18701
18711
|
}
|
|
@@ -19755,6 +19765,8 @@ function useCategoryHeight(emojiCount) {
|
|
|
19755
19765
|
isReactionsMode = _useReactionsModeStat[0];
|
|
19756
19766
|
var PickerMainRef = usePickerMainRef();
|
|
19757
19767
|
var emojiSizeRef = useRef();
|
|
19768
|
+
var _useVisibleCategories = useVisibleCategoriesState(),
|
|
19769
|
+
visibleCategories = _useVisibleCategories[0];
|
|
19758
19770
|
var _React$useState = useState(),
|
|
19759
19771
|
dimensions = _React$useState[0],
|
|
19760
19772
|
setDimensions = _React$useState[1];
|
|
@@ -19781,7 +19793,7 @@ function useCategoryHeight(emojiCount) {
|
|
|
19781
19793
|
// Recompute on data-count changes and when reactions mode toggles
|
|
19782
19794
|
useEffect(function () {
|
|
19783
19795
|
computeAndSetDimensions();
|
|
19784
|
-
}, [emojiCount, isReactionsMode, computeAndSetDimensions]);
|
|
19796
|
+
}, [emojiCount, isReactionsMode, computeAndSetDimensions, visibleCategories.length]);
|
|
19785
19797
|
// Listen to transitionend on the picker root (where height transition occurs)
|
|
19786
19798
|
useEffect(function () {
|
|
19787
19799
|
var rootEl = PickerMainRef.current;
|
|
@@ -19831,7 +19843,8 @@ function useEmojiVirtualization(_ref) {
|
|
|
19831
19843
|
var categoryEmojis = _ref.categoryEmojis,
|
|
19832
19844
|
topOffset = _ref.topOffset,
|
|
19833
19845
|
onHeightReady = _ref.onHeightReady,
|
|
19834
|
-
scrollTop = _ref.scrollTop
|
|
19846
|
+
scrollTop = _ref.scrollTop,
|
|
19847
|
+
isCategoryVisible = _ref.isCategoryVisible;
|
|
19835
19848
|
var isEmojiHidden = useIsEmojiHidden();
|
|
19836
19849
|
var lazyLoadEmojis = useLazyLoadEmojisConfig();
|
|
19837
19850
|
var emojiStyle = useEmojiStyleConfig();
|
|
@@ -19869,7 +19882,10 @@ function useEmojiVirtualization(_ref) {
|
|
|
19869
19882
|
})) {
|
|
19870
19883
|
var _BodyRef$current$clie2, _BodyRef$current2;
|
|
19871
19884
|
virtualizedCounter++;
|
|
19872
|
-
|
|
19885
|
+
preloadEmojiIfNeeded(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);
|
|
19886
|
+
return accumulator;
|
|
19887
|
+
}
|
|
19888
|
+
if (!isCategoryVisible) {
|
|
19873
19889
|
return accumulator;
|
|
19874
19890
|
}
|
|
19875
19891
|
accumulator.push(createElement(ClickableEmoji, {
|
|
@@ -19993,11 +20009,14 @@ function RenderCategory(_ref2) {
|
|
|
19993
20009
|
topOffset = _ref2.topOffset,
|
|
19994
20010
|
onHeightReady = _ref2.onHeightReady,
|
|
19995
20011
|
scrollTop = _ref2.scrollTop;
|
|
20012
|
+
var _useVisibleCategories = useVisibleCategoriesState(),
|
|
20013
|
+
visibleCategroies = _useVisibleCategories[0];
|
|
19996
20014
|
var _useEmojiVirtualizati = useEmojiVirtualization({
|
|
19997
20015
|
categoryEmojis: categoryEmojis,
|
|
19998
20016
|
topOffset: topOffset,
|
|
19999
20017
|
onHeightReady: onHeightReady,
|
|
20000
|
-
scrollTop: scrollTop
|
|
20018
|
+
scrollTop: scrollTop,
|
|
20019
|
+
isCategoryVisible: visibleCategroies.includes(categoryConfig.category)
|
|
20001
20020
|
}),
|
|
20002
20021
|
virtualizedCounter = _useEmojiVirtualizati.virtualizedCounter,
|
|
20003
20022
|
emojis = _useEmojiVirtualizati.emojis,
|
|
@@ -20623,7 +20642,9 @@ function categoryNameFromDom($category) {
|
|
|
20623
20642
|
return (_$category$getAttribu = $category == null ? void 0 : $category.getAttribute('data-name')) != null ? _$category$getAttribu : null;
|
|
20624
20643
|
}
|
|
20625
20644
|
|
|
20626
|
-
function useActiveCategoryScrollDetection(
|
|
20645
|
+
function useActiveCategoryScrollDetection(_ref) {
|
|
20646
|
+
var setActiveCategory = _ref.setActiveCategory,
|
|
20647
|
+
setVisibleCategories = _ref.setVisibleCategories;
|
|
20627
20648
|
var BodyRef = useBodyRef();
|
|
20628
20649
|
useEffect(function () {
|
|
20629
20650
|
var visibleCategories = new Map();
|
|
@@ -20635,9 +20656,19 @@ function useActiveCategoryScrollDetection(setActiveCategory) {
|
|
|
20635
20656
|
for (var _iterator = _createForOfIteratorHelperLoose(entries), _step; !(_step = _iterator()).done;) {
|
|
20636
20657
|
var entry = _step.value;
|
|
20637
20658
|
var _id = categoryNameFromDom(entry.target);
|
|
20659
|
+
if (!_id) {
|
|
20660
|
+
continue;
|
|
20661
|
+
}
|
|
20638
20662
|
visibleCategories.set(_id, entry.intersectionRatio);
|
|
20639
20663
|
}
|
|
20640
20664
|
var ratios = Array.from(visibleCategories);
|
|
20665
|
+
setVisibleCategories(ratios.filter(function (_ref2) {
|
|
20666
|
+
var ratio = _ref2[1];
|
|
20667
|
+
return ratio > 0;
|
|
20668
|
+
}).map(function (_ref3) {
|
|
20669
|
+
var id = _ref3[0];
|
|
20670
|
+
return id;
|
|
20671
|
+
}));
|
|
20641
20672
|
var lastCategory = ratios[ratios.length - 1];
|
|
20642
20673
|
if (lastCategory[1] == 1) {
|
|
20643
20674
|
return setActiveCategory(lastCategory[0]);
|
|
@@ -20657,7 +20688,7 @@ function useActiveCategoryScrollDetection(setActiveCategory) {
|
|
|
20657
20688
|
bodyRef == null ? void 0 : bodyRef.querySelectorAll(asSelectors(ClassNames.category)).forEach(function (el) {
|
|
20658
20689
|
observer.observe(el);
|
|
20659
20690
|
});
|
|
20660
|
-
}, [BodyRef, setActiveCategory]);
|
|
20691
|
+
}, [BodyRef, setActiveCategory, setVisibleCategories]);
|
|
20661
20692
|
}
|
|
20662
20693
|
|
|
20663
20694
|
function useScrollCategoryIntoView() {
|
|
@@ -20780,8 +20811,13 @@ function CategoryNavigation() {
|
|
|
20780
20811
|
var _useState = useState(null),
|
|
20781
20812
|
activeCategory = _useState[0],
|
|
20782
20813
|
setActiveCategory = _useState[1];
|
|
20814
|
+
var _useVisibleCategories = useVisibleCategoriesState(),
|
|
20815
|
+
setVisibleCategories = _useVisibleCategories[1];
|
|
20783
20816
|
var scrollCategoryIntoView = useScrollCategoryIntoView();
|
|
20784
|
-
useActiveCategoryScrollDetection(
|
|
20817
|
+
useActiveCategoryScrollDetection({
|
|
20818
|
+
setActiveCategory: setActiveCategory,
|
|
20819
|
+
setVisibleCategories: setVisibleCategories
|
|
20820
|
+
});
|
|
20785
20821
|
var isSearchMode = useIsSearchMode();
|
|
20786
20822
|
var categoriesConfig = useCategoriesConfig();
|
|
20787
20823
|
var CategoryNavigationRef = useCategoryNavigationRef();
|