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