emoji-picker-react 4.20.6 → 4.20.8
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/emoji-picker-react.cjs.development.js +50 -34
- 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 +50 -34
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/DomUtils/focusElement.ts +9 -1
- package/src/hooks/useEmojiPreviewEvents.ts +36 -27
- package/src/hooks/useSetVariationPicker.ts +17 -2
|
@@ -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
|
}
|
|
@@ -27865,9 +27870,20 @@ function useSetVariationPicker() {
|
|
|
27865
27870
|
var setAnchoredEmojiRef = useSetAnchoredEmojiRef();
|
|
27866
27871
|
var _useEmojiVariationPic = useEmojiVariationPickerState(),
|
|
27867
27872
|
setEmojiVariationPicker = _useEmojiVariationPic[1];
|
|
27873
|
+
// Context-aware lookup: respects the `emojiData` prop (e.g. translations).
|
|
27874
|
+
// The legacy global lookup only knows the default English dataset.
|
|
27875
|
+
// https://github.com/ealush/emoji-picker-react/issues/503
|
|
27876
|
+
var _usePickerDataContext = usePickerDataContext(),
|
|
27877
|
+
emojiByUnified = _usePickerDataContext.emojiByUnified;
|
|
27868
27878
|
return function setVariationPicker(element) {
|
|
27869
|
-
var
|
|
27870
|
-
|
|
27879
|
+
var _allUnifiedFromEmojiE = allUnifiedFromEmojiElement(element),
|
|
27880
|
+
unified = _allUnifiedFromEmojiE.unified,
|
|
27881
|
+
originalUnified = _allUnifiedFromEmojiE.originalUnified;
|
|
27882
|
+
var resolvedUnified = unified != null ? unified : originalUnified;
|
|
27883
|
+
if (!resolvedUnified) {
|
|
27884
|
+
return;
|
|
27885
|
+
}
|
|
27886
|
+
var emoji = emojiByUnified(resolvedUnified);
|
|
27871
27887
|
if (emoji) {
|
|
27872
27888
|
setAnchoredEmojiRef(element);
|
|
27873
27889
|
setEmojiVariationPicker(emoji);
|
|
@@ -29954,18 +29970,9 @@ var styles$a = /*#__PURE__*/stylesheet.create({
|
|
|
29954
29970
|
}
|
|
29955
29971
|
});
|
|
29956
29972
|
|
|
29957
|
-
function detectEmojyPartiallyBelowFold(button, bodyRef) {
|
|
29958
|
-
if (!button || !bodyRef) {
|
|
29959
|
-
return 0;
|
|
29960
|
-
}
|
|
29961
|
-
var buttonRect = button.getBoundingClientRect();
|
|
29962
|
-
var bodyRect = bodyRef.getBoundingClientRect();
|
|
29963
|
-
// If the element is obscured by at least half of its size
|
|
29964
|
-
return bodyRect.height - (buttonRect.y - bodyRect.y);
|
|
29965
|
-
}
|
|
29966
|
-
|
|
29967
29973
|
function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
29968
29974
|
var BodyRef = useBodyRef();
|
|
29975
|
+
var PickerMainRef = usePickerMainRef();
|
|
29969
29976
|
var isMouseDisallowed = useIsMouseDisallowed();
|
|
29970
29977
|
var allowMouseMove = useAllowMouseMove();
|
|
29971
29978
|
useEffect(function () {
|
|
@@ -30017,15 +30024,38 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
30017
30024
|
return;
|
|
30018
30025
|
}
|
|
30019
30026
|
var button = buttonFromTarget(e.target);
|
|
30020
|
-
if (button) {
|
|
30021
|
-
|
|
30022
|
-
|
|
30023
|
-
|
|
30024
|
-
|
|
30025
|
-
|
|
30026
|
-
|
|
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;
|
|
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
|
+
});
|
|
30027
30049
|
}
|
|
30028
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));
|
|
30058
|
+
}
|
|
30029
30059
|
return function () {
|
|
30030
30060
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('mouseover', onMouseOver);
|
|
30031
30061
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('mouseout', onLeave);
|
|
@@ -30035,20 +30065,6 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
30035
30065
|
};
|
|
30036
30066
|
}, [BodyRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
30037
30067
|
}
|
|
30038
|
-
function handlePartiallyVisibleElementFocus(button, setPreviewEmoji) {
|
|
30039
|
-
var _document$activeEleme;
|
|
30040
|
-
var _allUnifiedFromEmojiE2 = allUnifiedFromEmojiElement(button),
|
|
30041
|
-
unified = _allUnifiedFromEmojiE2.unified,
|
|
30042
|
-
originalUnified = _allUnifiedFromEmojiE2.originalUnified;
|
|
30043
|
-
if (!unified || !originalUnified) {
|
|
30044
|
-
return;
|
|
30045
|
-
}
|
|
30046
|
-
(_document$activeEleme = document.activeElement) == null ? void 0 : _document$activeEleme.blur == null ? void 0 : _document$activeEleme.blur();
|
|
30047
|
-
setPreviewEmoji({
|
|
30048
|
-
unified: unified,
|
|
30049
|
-
originalUnified: originalUnified
|
|
30050
|
-
});
|
|
30051
|
-
}
|
|
30052
30068
|
|
|
30053
30069
|
var _stylesheet$create;
|
|
30054
30070
|
var FlexDirection;
|