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