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
|
@@ -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,10 @@ 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) {
|
|
19874
19890
|
return accumulator;
|
|
19875
19891
|
}
|
|
19876
19892
|
accumulator.push(React.createElement(ClickableEmoji, {
|
|
@@ -19994,11 +20010,14 @@ function RenderCategory(_ref2) {
|
|
|
19994
20010
|
topOffset = _ref2.topOffset,
|
|
19995
20011
|
onHeightReady = _ref2.onHeightReady,
|
|
19996
20012
|
scrollTop = _ref2.scrollTop;
|
|
20013
|
+
var _useVisibleCategories = useVisibleCategoriesState(),
|
|
20014
|
+
visibleCategroies = _useVisibleCategories[0];
|
|
19997
20015
|
var _useEmojiVirtualizati = useEmojiVirtualization({
|
|
19998
20016
|
categoryEmojis: categoryEmojis,
|
|
19999
20017
|
topOffset: topOffset,
|
|
20000
20018
|
onHeightReady: onHeightReady,
|
|
20001
|
-
scrollTop: scrollTop
|
|
20019
|
+
scrollTop: scrollTop,
|
|
20020
|
+
isCategoryVisible: visibleCategroies.includes(categoryConfig.category)
|
|
20002
20021
|
}),
|
|
20003
20022
|
virtualizedCounter = _useEmojiVirtualizati.virtualizedCounter,
|
|
20004
20023
|
emojis = _useEmojiVirtualizati.emojis,
|
|
@@ -20624,7 +20643,9 @@ function categoryNameFromDom($category) {
|
|
|
20624
20643
|
return (_$category$getAttribu = $category == null ? void 0 : $category.getAttribute('data-name')) != null ? _$category$getAttribu : null;
|
|
20625
20644
|
}
|
|
20626
20645
|
|
|
20627
|
-
function useActiveCategoryScrollDetection(
|
|
20646
|
+
function useActiveCategoryScrollDetection(_ref) {
|
|
20647
|
+
var setActiveCategory = _ref.setActiveCategory,
|
|
20648
|
+
setVisibleCategories = _ref.setVisibleCategories;
|
|
20628
20649
|
var BodyRef = useBodyRef();
|
|
20629
20650
|
React.useEffect(function () {
|
|
20630
20651
|
var visibleCategories = new Map();
|
|
@@ -20636,9 +20657,19 @@ function useActiveCategoryScrollDetection(setActiveCategory) {
|
|
|
20636
20657
|
for (var _iterator = _createForOfIteratorHelperLoose(entries), _step; !(_step = _iterator()).done;) {
|
|
20637
20658
|
var entry = _step.value;
|
|
20638
20659
|
var _id = categoryNameFromDom(entry.target);
|
|
20660
|
+
if (!_id) {
|
|
20661
|
+
continue;
|
|
20662
|
+
}
|
|
20639
20663
|
visibleCategories.set(_id, entry.intersectionRatio);
|
|
20640
20664
|
}
|
|
20641
20665
|
var ratios = Array.from(visibleCategories);
|
|
20666
|
+
setVisibleCategories(ratios.filter(function (_ref2) {
|
|
20667
|
+
var ratio = _ref2[1];
|
|
20668
|
+
return ratio > 0;
|
|
20669
|
+
}).map(function (_ref3) {
|
|
20670
|
+
var id = _ref3[0];
|
|
20671
|
+
return id;
|
|
20672
|
+
}));
|
|
20642
20673
|
var lastCategory = ratios[ratios.length - 1];
|
|
20643
20674
|
if (lastCategory[1] == 1) {
|
|
20644
20675
|
return setActiveCategory(lastCategory[0]);
|
|
@@ -20658,7 +20689,7 @@ function useActiveCategoryScrollDetection(setActiveCategory) {
|
|
|
20658
20689
|
bodyRef == null ? void 0 : bodyRef.querySelectorAll(asSelectors(ClassNames.category)).forEach(function (el) {
|
|
20659
20690
|
observer.observe(el);
|
|
20660
20691
|
});
|
|
20661
|
-
}, [BodyRef, setActiveCategory]);
|
|
20692
|
+
}, [BodyRef, setActiveCategory, setVisibleCategories]);
|
|
20662
20693
|
}
|
|
20663
20694
|
|
|
20664
20695
|
function useScrollCategoryIntoView() {
|
|
@@ -20781,8 +20812,13 @@ function CategoryNavigation() {
|
|
|
20781
20812
|
var _useState = React.useState(null),
|
|
20782
20813
|
activeCategory = _useState[0],
|
|
20783
20814
|
setActiveCategory = _useState[1];
|
|
20815
|
+
var _useVisibleCategories = useVisibleCategoriesState(),
|
|
20816
|
+
setVisibleCategories = _useVisibleCategories[1];
|
|
20784
20817
|
var scrollCategoryIntoView = useScrollCategoryIntoView();
|
|
20785
|
-
useActiveCategoryScrollDetection(
|
|
20818
|
+
useActiveCategoryScrollDetection({
|
|
20819
|
+
setActiveCategory: setActiveCategory,
|
|
20820
|
+
setVisibleCategories: setVisibleCategories
|
|
20821
|
+
});
|
|
20786
20822
|
var isSearchMode = useIsSearchMode();
|
|
20787
20823
|
var categoriesConfig = useCategoriesConfig();
|
|
20788
20824
|
var CategoryNavigationRef = useCategoryNavigationRef();
|