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