emoji-picker-react 4.20.7 → 4.20.9
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/focusElement.d.ts +1 -1
- package/dist/components/navigation/CategoryNavigation.d.ts +1 -1
- package/dist/emoji-picker-react.cjs.development.js +46 -36
- 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 +46 -36
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/DomUtils/focusElement.ts +9 -1
- package/src/components/navigation/CategoryNavigation.tsx +12 -5
- package/src/hooks/useEmojiPreviewEvents.ts +36 -27
|
@@ -27362,11 +27362,16 @@ function useIsSearchMode() {
|
|
|
27362
27362
|
return !!searchTerm;
|
|
27363
27363
|
}
|
|
27364
27364
|
|
|
27365
|
-
function focusElement(element) {
|
|
27365
|
+
function focusElement(element, shouldFocus) {
|
|
27366
27366
|
if (!element) {
|
|
27367
27367
|
return;
|
|
27368
27368
|
}
|
|
27369
27369
|
requestAnimationFrame(function () {
|
|
27370
|
+
// Rechecked here rather than at call time: focus may have moved in the
|
|
27371
|
+
// meantime (e.g. hover scheduled focus, then the user tabbed out).
|
|
27372
|
+
if (shouldFocus && !shouldFocus()) {
|
|
27373
|
+
return;
|
|
27374
|
+
}
|
|
27370
27375
|
element.focus();
|
|
27371
27376
|
});
|
|
27372
27377
|
}
|
|
@@ -29965,18 +29970,9 @@ var styles$a = /*#__PURE__*/stylesheet.create({
|
|
|
29965
29970
|
}
|
|
29966
29971
|
});
|
|
29967
29972
|
|
|
29968
|
-
function detectEmojyPartiallyBelowFold(button, bodyRef) {
|
|
29969
|
-
if (!button || !bodyRef) {
|
|
29970
|
-
return 0;
|
|
29971
|
-
}
|
|
29972
|
-
var buttonRect = button.getBoundingClientRect();
|
|
29973
|
-
var bodyRect = bodyRef.getBoundingClientRect();
|
|
29974
|
-
// If the element is obscured by at least half of its size
|
|
29975
|
-
return bodyRect.height - (buttonRect.y - bodyRect.y);
|
|
29976
|
-
}
|
|
29977
|
-
|
|
29978
29973
|
function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
29979
29974
|
var BodyRef = useBodyRef();
|
|
29975
|
+
var PickerMainRef = usePickerMainRef();
|
|
29980
29976
|
var isMouseDisallowed = useIsMouseDisallowed();
|
|
29981
29977
|
var allowMouseMove = useAllowMouseMove();
|
|
29982
29978
|
useEffect(function () {
|
|
@@ -30028,14 +30024,37 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
30028
30024
|
return;
|
|
30029
30025
|
}
|
|
30030
30026
|
var button = buttonFromTarget(e.target);
|
|
30031
|
-
if (button) {
|
|
30032
|
-
|
|
30033
|
-
|
|
30034
|
-
|
|
30035
|
-
|
|
30036
|
-
|
|
30037
|
-
|
|
30027
|
+
if (!button) {
|
|
30028
|
+
return;
|
|
30029
|
+
}
|
|
30030
|
+
var _allUnifiedFromEmojiE2 = allUnifiedFromEmojiElement(button),
|
|
30031
|
+
unified = _allUnifiedFromEmojiE2.unified,
|
|
30032
|
+
originalUnified = _allUnifiedFromEmojiE2.originalUnified;
|
|
30033
|
+
if (!unified || !originalUnified) {
|
|
30034
|
+
return;
|
|
30038
30035
|
}
|
|
30036
|
+
setPreviewEmoji({
|
|
30037
|
+
unified: unified,
|
|
30038
|
+
originalUnified: originalUnified
|
|
30039
|
+
});
|
|
30040
|
+
// Let arrow-key navigation continue from the hovered emoji, but only
|
|
30041
|
+
// when focus is already inside the picker (or nowhere meaningful).
|
|
30042
|
+
// Pulling focus out of an external element steals the caret from
|
|
30043
|
+
// host-app inputs (issue #320). The guard runs again inside the
|
|
30044
|
+
// deferred callback in case focus moved out after this event.
|
|
30045
|
+
if (!isExternalElementFocused()) {
|
|
30046
|
+
focusElement(button, function () {
|
|
30047
|
+
return !isExternalElementFocused();
|
|
30048
|
+
});
|
|
30049
|
+
}
|
|
30050
|
+
}
|
|
30051
|
+
function isExternalElementFocused() {
|
|
30052
|
+
var _PickerMainRef$curren;
|
|
30053
|
+
var active = document.activeElement;
|
|
30054
|
+
if (!active || active === document.body || active === document.documentElement) {
|
|
30055
|
+
return false;
|
|
30056
|
+
}
|
|
30057
|
+
return !((_PickerMainRef$curren = PickerMainRef.current) != null && _PickerMainRef$curren.contains(active));
|
|
30039
30058
|
}
|
|
30040
30059
|
return function () {
|
|
30041
30060
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('mouseover', onMouseOver);
|
|
@@ -30046,20 +30065,6 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
30046
30065
|
};
|
|
30047
30066
|
}, [BodyRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
30048
30067
|
}
|
|
30049
|
-
function handlePartiallyVisibleElementFocus(button, setPreviewEmoji) {
|
|
30050
|
-
var _document$activeEleme;
|
|
30051
|
-
var _allUnifiedFromEmojiE2 = allUnifiedFromEmojiElement(button),
|
|
30052
|
-
unified = _allUnifiedFromEmojiE2.unified,
|
|
30053
|
-
originalUnified = _allUnifiedFromEmojiE2.originalUnified;
|
|
30054
|
-
if (!unified || !originalUnified) {
|
|
30055
|
-
return;
|
|
30056
|
-
}
|
|
30057
|
-
(_document$activeEleme = document.activeElement) == null ? void 0 : _document$activeEleme.blur == null ? void 0 : _document$activeEleme.blur();
|
|
30058
|
-
setPreviewEmoji({
|
|
30059
|
-
unified: unified,
|
|
30060
|
-
originalUnified: originalUnified
|
|
30061
|
-
});
|
|
30062
|
-
}
|
|
30063
30068
|
|
|
30064
30069
|
var _stylesheet$create;
|
|
30065
30070
|
var FlexDirection;
|
|
@@ -30593,18 +30598,23 @@ function CategoryNavigation() {
|
|
|
30593
30598
|
var categoryIcons = useCategoryIconsConfig();
|
|
30594
30599
|
var CategoryNavigationRef = useCategoryNavigationRef();
|
|
30595
30600
|
var hideCustomCategory = useShouldHideCustomEmojis();
|
|
30601
|
+
var visibleCategories = categoriesConfig.filter(function (categoryConfig) {
|
|
30602
|
+
return !(isCustomCategory(categoryConfig) && hideCustomCategory);
|
|
30603
|
+
});
|
|
30604
|
+
// A single tab navigates nowhere — hide the bar to reclaim its space.
|
|
30605
|
+
// https://github.com/ealush/emoji-picker-react/issues/396
|
|
30606
|
+
if (visibleCategories.length <= 1) {
|
|
30607
|
+
return null;
|
|
30608
|
+
}
|
|
30596
30609
|
return createElement("div", {
|
|
30597
30610
|
className: cx(styles$g.nav),
|
|
30598
30611
|
role: "tablist",
|
|
30599
30612
|
"aria-label": "Category navigation",
|
|
30600
30613
|
id: "epr-category-nav-id",
|
|
30601
30614
|
ref: CategoryNavigationRef
|
|
30602
|
-
},
|
|
30615
|
+
}, visibleCategories.map(function (categoryConfig) {
|
|
30603
30616
|
var category = categoryFromCategoryConfig(categoryConfig);
|
|
30604
30617
|
var isActiveCategory = category === activeCategory;
|
|
30605
|
-
if (isCustomCategory(categoryConfig) && hideCustomCategory) {
|
|
30606
|
-
return null;
|
|
30607
|
-
}
|
|
30608
30618
|
var allowNavigation = !isSearchMode && !isActiveCategory;
|
|
30609
30619
|
return createElement(CategoryButton, {
|
|
30610
30620
|
key: category,
|