emoji-picker-react 4.0.0-rc.28 → 4.0.0-rc.29
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/classNames.d.ts +2 -1
- package/dist/components/context/PickerContext.d.ts +1 -0
- package/dist/emoji-picker-react.cjs.development.js +112 -39
- 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 +112 -39
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/hooks/useDisallowMouseMove.d.ts +4 -0
- package/package.json +1 -1
- package/src/DomUtils/classNames.ts +2 -1
- package/src/components/body/Body.tsx +3 -0
- package/src/components/body/EmojiVariationPicker.tsx +13 -2
- package/src/components/context/PickerContext.tsx +10 -1
- package/src/components/emoji/Emoji.tsx +1 -1
- package/src/hooks/useDisallowMouseMove.ts +47 -0
- package/src/hooks/useEmojiPreviewEvents.ts +23 -9
- package/src/hooks/useKeyboardNavigation.ts +22 -12
|
@@ -7,6 +7,7 @@ export declare enum ClassNames {
|
|
|
7
7
|
emoji = "epr-emoji",
|
|
8
8
|
category = "epr-emoji-category",
|
|
9
9
|
label = "epr-emoji-category-label",
|
|
10
|
-
categoryContent = "epr-emoji-category-content"
|
|
10
|
+
categoryContent = "epr-emoji-category-content",
|
|
11
|
+
emojiHasVariatios = "epr-emoji-has-variations"
|
|
11
12
|
}
|
|
12
13
|
export declare function asSelectors(...classNames: ClassNames[]): string;
|
|
@@ -9,6 +9,7 @@ declare type Props = Readonly<{
|
|
|
9
9
|
}>;
|
|
10
10
|
export declare function useFilterRef(): React.MutableRefObject<Record<string, Record<string, DataEmoji>>>;
|
|
11
11
|
export declare function useDisallowClickRef(): React.MutableRefObject<boolean>;
|
|
12
|
+
export declare function useDisallowMouseRef(): React.MutableRefObject<boolean>;
|
|
12
13
|
export declare function useSearchTermState(): [string, (term: string) => Promise<string>];
|
|
13
14
|
export declare function useActiveCategoryState(): [ActiveCategoryState, (nextActive: string) => void, (nextActive: string) => void];
|
|
14
15
|
export declare function useActiveSkinToneState(): [SkinTones, (skinTone: SkinTones) => void];
|
|
@@ -110,6 +110,7 @@ var ClassNames;
|
|
|
110
110
|
ClassNames["category"] = "epr-emoji-category";
|
|
111
111
|
ClassNames["label"] = "epr-emoji-category-label";
|
|
112
112
|
ClassNames["categoryContent"] = "epr-emoji-category-content";
|
|
113
|
+
ClassNames["emojiHasVariatios"] = "epr-emoji-has-variations";
|
|
113
114
|
})(ClassNames || (ClassNames = {}));
|
|
114
115
|
|
|
115
116
|
function asSelectors() {
|
|
@@ -15128,6 +15129,7 @@ function PickerContextProvider(_ref) {
|
|
|
15128
15129
|
|
|
15129
15130
|
var filterRef = React.useRef(alphaNumericEmojiIndex);
|
|
15130
15131
|
var disallowClickRef = React.useRef(false);
|
|
15132
|
+
var disallowMouseRef = React.useRef(false);
|
|
15131
15133
|
var suggestedUpdateState = useDebouncedState(Date.now(), 200);
|
|
15132
15134
|
var searchTerm = useDebouncedState('', 100);
|
|
15133
15135
|
var skinToneFanOpenState = React.useState(false);
|
|
@@ -15152,7 +15154,8 @@ function PickerContextProvider(_ref) {
|
|
|
15152
15154
|
isPastInitialLoad: isPastInitialLoad,
|
|
15153
15155
|
searchTerm: searchTerm,
|
|
15154
15156
|
skinToneFanOpenState: skinToneFanOpenState,
|
|
15155
|
-
suggestedUpdateState: suggestedUpdateState
|
|
15157
|
+
suggestedUpdateState: suggestedUpdateState,
|
|
15158
|
+
disallowMouseRef: disallowMouseRef
|
|
15156
15159
|
}
|
|
15157
15160
|
}, children);
|
|
15158
15161
|
}
|
|
@@ -15162,6 +15165,9 @@ var PickerContext = /*#__PURE__*/React.createContext({
|
|
|
15162
15165
|
disallowClickRef: {
|
|
15163
15166
|
current: false
|
|
15164
15167
|
},
|
|
15168
|
+
disallowMouseRef: {
|
|
15169
|
+
current: false
|
|
15170
|
+
},
|
|
15165
15171
|
emojiVariationPickerState: [null, function () {}],
|
|
15166
15172
|
emojisThatFailedToLoadState: [/*#__PURE__*/new Set(), function () {}],
|
|
15167
15173
|
filterRef: {
|
|
@@ -15188,15 +15194,21 @@ function useDisallowClickRef() {
|
|
|
15188
15194
|
|
|
15189
15195
|
return disallowClickRef;
|
|
15190
15196
|
}
|
|
15191
|
-
function
|
|
15197
|
+
function useDisallowMouseRef() {
|
|
15192
15198
|
var _React$useContext3 = React.useContext(PickerContext),
|
|
15193
|
-
|
|
15199
|
+
disallowMouseRef = _React$useContext3.disallowMouseRef;
|
|
15200
|
+
|
|
15201
|
+
return disallowMouseRef;
|
|
15202
|
+
}
|
|
15203
|
+
function useSearchTermState() {
|
|
15204
|
+
var _React$useContext4 = React.useContext(PickerContext),
|
|
15205
|
+
searchTerm = _React$useContext4.searchTerm;
|
|
15194
15206
|
|
|
15195
15207
|
return searchTerm;
|
|
15196
15208
|
}
|
|
15197
15209
|
function useActiveCategoryState() {
|
|
15198
|
-
var _React$
|
|
15199
|
-
activeCategoryState = _React$
|
|
15210
|
+
var _React$useContext5 = React.useContext(PickerContext),
|
|
15211
|
+
activeCategoryState = _React$useContext5.activeCategoryState;
|
|
15200
15212
|
|
|
15201
15213
|
var PickerMainRef = usePickerMainRef();
|
|
15202
15214
|
var activeCategory = activeCategoryState[0],
|
|
@@ -15213,38 +15225,38 @@ function useActiveCategoryState() {
|
|
|
15213
15225
|
}
|
|
15214
15226
|
}
|
|
15215
15227
|
function useActiveSkinToneState() {
|
|
15216
|
-
var _React$
|
|
15217
|
-
activeSkinTone = _React$
|
|
15228
|
+
var _React$useContext6 = React.useContext(PickerContext),
|
|
15229
|
+
activeSkinTone = _React$useContext6.activeSkinTone;
|
|
15218
15230
|
|
|
15219
15231
|
return activeSkinTone;
|
|
15220
15232
|
}
|
|
15221
15233
|
function useEmojisThatFailedToLoadState() {
|
|
15222
|
-
var _React$
|
|
15223
|
-
emojisThatFailedToLoadState = _React$
|
|
15234
|
+
var _React$useContext7 = React.useContext(PickerContext),
|
|
15235
|
+
emojisThatFailedToLoadState = _React$useContext7.emojisThatFailedToLoadState;
|
|
15224
15236
|
|
|
15225
15237
|
return emojisThatFailedToLoadState;
|
|
15226
15238
|
}
|
|
15227
15239
|
function useIsPastInitialLoad() {
|
|
15228
|
-
var _React$
|
|
15229
|
-
isPastInitialLoad = _React$
|
|
15240
|
+
var _React$useContext8 = React.useContext(PickerContext),
|
|
15241
|
+
isPastInitialLoad = _React$useContext8.isPastInitialLoad;
|
|
15230
15242
|
|
|
15231
15243
|
return isPastInitialLoad;
|
|
15232
15244
|
}
|
|
15233
15245
|
function useEmojiVariationPickerState() {
|
|
15234
|
-
var _React$
|
|
15235
|
-
emojiVariationPickerState = _React$
|
|
15246
|
+
var _React$useContext9 = React.useContext(PickerContext),
|
|
15247
|
+
emojiVariationPickerState = _React$useContext9.emojiVariationPickerState;
|
|
15236
15248
|
|
|
15237
15249
|
return emojiVariationPickerState;
|
|
15238
15250
|
}
|
|
15239
15251
|
function useSkinToneFanOpenState() {
|
|
15240
|
-
var _React$
|
|
15241
|
-
skinToneFanOpenState = _React$
|
|
15252
|
+
var _React$useContext10 = React.useContext(PickerContext),
|
|
15253
|
+
skinToneFanOpenState = _React$useContext10.skinToneFanOpenState;
|
|
15242
15254
|
|
|
15243
15255
|
return skinToneFanOpenState;
|
|
15244
15256
|
}
|
|
15245
15257
|
function useUpdateSuggested() {
|
|
15246
|
-
var _React$
|
|
15247
|
-
suggestedUpdateState = _React$
|
|
15258
|
+
var _React$useContext11 = React.useContext(PickerContext),
|
|
15259
|
+
suggestedUpdateState = _React$useContext11.suggestedUpdateState;
|
|
15248
15260
|
|
|
15249
15261
|
var suggestedUpdated = suggestedUpdateState[0],
|
|
15250
15262
|
setsuggestedUpdate = suggestedUpdateState[1];
|
|
@@ -15302,6 +15314,46 @@ function useActiveCategoryScrollDetection(bodyRef) {
|
|
|
15302
15314
|
}, [bodyRef, setActiveCategory]);
|
|
15303
15315
|
}
|
|
15304
15316
|
|
|
15317
|
+
function useDisallowMouseMove() {
|
|
15318
|
+
var DisallowMouseRef = useDisallowMouseRef();
|
|
15319
|
+
return function disallowMouseMove() {
|
|
15320
|
+
DisallowMouseRef.current = true;
|
|
15321
|
+
};
|
|
15322
|
+
}
|
|
15323
|
+
function useAllowMouseMove() {
|
|
15324
|
+
var DisallowMouseRef = useDisallowMouseRef();
|
|
15325
|
+
return function allowMouseMove() {
|
|
15326
|
+
DisallowMouseRef.current = false;
|
|
15327
|
+
};
|
|
15328
|
+
}
|
|
15329
|
+
function useIsMouseDisallowed() {
|
|
15330
|
+
var DisallowMouseRef = useDisallowMouseRef();
|
|
15331
|
+
return function isMouseDisallowed() {
|
|
15332
|
+
return DisallowMouseRef.current;
|
|
15333
|
+
};
|
|
15334
|
+
}
|
|
15335
|
+
function useOnMouseMove() {
|
|
15336
|
+
var BodyRef = useBodyRef();
|
|
15337
|
+
var allowMouseMove = useAllowMouseMove();
|
|
15338
|
+
var isMouseDisallowed = useIsMouseDisallowed();
|
|
15339
|
+
React.useEffect(function () {
|
|
15340
|
+
var bodyRef = BodyRef.current;
|
|
15341
|
+
bodyRef == null ? void 0 : bodyRef.addEventListener('mousemove', onMouseMove, {
|
|
15342
|
+
passive: true
|
|
15343
|
+
});
|
|
15344
|
+
|
|
15345
|
+
function onMouseMove() {
|
|
15346
|
+
if (isMouseDisallowed()) {
|
|
15347
|
+
allowMouseMove();
|
|
15348
|
+
}
|
|
15349
|
+
}
|
|
15350
|
+
|
|
15351
|
+
return function () {
|
|
15352
|
+
bodyRef == null ? void 0 : bodyRef.removeEventListener('mousemove', onMouseMove);
|
|
15353
|
+
};
|
|
15354
|
+
}, [BodyRef, allowMouseMove, isMouseDisallowed]);
|
|
15355
|
+
}
|
|
15356
|
+
|
|
15305
15357
|
function elementCountInRow(parent, element) {
|
|
15306
15358
|
if (!parent || !element) {
|
|
15307
15359
|
return 0;
|
|
@@ -16277,7 +16329,7 @@ function ClickableEmoji(_ref) {
|
|
|
16277
16329
|
lazyLoad = _ref.lazyLoad;
|
|
16278
16330
|
var hasVariations = emojiHasVariations(emoji);
|
|
16279
16331
|
return React.createElement("button", {
|
|
16280
|
-
className: clsx(ClassNames.emoji, (_clsx = {}, _clsx[ClassNames.hidden] = hidden, _clsx[ClassNames.hiddenOnSearch] = hiddenOnSearch, _clsx[ClassNames.visible] = !hidden, _clsx[
|
|
16332
|
+
className: clsx(ClassNames.emoji, (_clsx = {}, _clsx[ClassNames.hidden] = hidden, _clsx[ClassNames.hiddenOnSearch] = hiddenOnSearch, _clsx[ClassNames.visible] = !hidden, _clsx[ClassNames.emojiHasVariatios] = hasVariations && showVariations, _clsx)),
|
|
16281
16333
|
"data-unified": unified,
|
|
16282
16334
|
// @ts-ignore - let's ignore the fact this is not a real react ref, ok?
|
|
16283
16335
|
ref: emojiRef,
|
|
@@ -16490,6 +16542,7 @@ var Direction;
|
|
|
16490
16542
|
})(Direction || (Direction = {}));
|
|
16491
16543
|
|
|
16492
16544
|
function EmojiVariationPicker() {
|
|
16545
|
+
var AnchoredEmojiRef = useAnchoredEmojiRef();
|
|
16493
16546
|
var VariationPickerRef = useVariationPickerRef();
|
|
16494
16547
|
|
|
16495
16548
|
var _useEmojiVariationPic = useEmojiVariationPickerState(),
|
|
@@ -16503,10 +16556,12 @@ function EmojiVariationPicker() {
|
|
|
16503
16556
|
|
|
16504
16557
|
var setAnchoredEmojiRef = useSetAnchoredEmojiRef();
|
|
16505
16558
|
var getPointerStyle = usePointerStyle(VariationPickerRef);
|
|
16506
|
-
var
|
|
16559
|
+
var button = buttonFromTarget(AnchoredEmojiRef.current);
|
|
16560
|
+
var visible = emoji && button && emojiHasVariations(emoji) && button.classList.contains(ClassNames.emojiHasVariatios);
|
|
16507
16561
|
var top, pointerStyle;
|
|
16508
16562
|
|
|
16509
|
-
if (!visible) {
|
|
16563
|
+
if (!visible && AnchoredEmojiRef.current) {
|
|
16564
|
+
focusElement(AnchoredEmojiRef.current);
|
|
16510
16565
|
setAnchoredEmojiRef(null);
|
|
16511
16566
|
} else {
|
|
16512
16567
|
top = getTop();
|
|
@@ -16609,6 +16664,7 @@ function Body() {
|
|
|
16609
16664
|
useActiveCategoryScrollDetection(BodyRef);
|
|
16610
16665
|
useOnScroll(BodyRef);
|
|
16611
16666
|
useMouseDownHandlers(BodyRef);
|
|
16667
|
+
useOnMouseMove();
|
|
16612
16668
|
return React.createElement("div", {
|
|
16613
16669
|
className: "epr-body",
|
|
16614
16670
|
ref: BodyRef
|
|
@@ -16617,6 +16673,8 @@ function Body() {
|
|
|
16617
16673
|
|
|
16618
16674
|
function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
16619
16675
|
var BodyRef = useBodyRef();
|
|
16676
|
+
var isMouseDisallowed = useIsMouseDisallowed();
|
|
16677
|
+
var allowMouseMove = useAllowMouseMove();
|
|
16620
16678
|
React.useEffect(function () {
|
|
16621
16679
|
if (!allow) {
|
|
16622
16680
|
return;
|
|
@@ -16671,6 +16729,18 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
16671
16729
|
}
|
|
16672
16730
|
}
|
|
16673
16731
|
|
|
16732
|
+
function onMouseOver(e) {
|
|
16733
|
+
if (isMouseDisallowed()) {
|
|
16734
|
+
return;
|
|
16735
|
+
}
|
|
16736
|
+
|
|
16737
|
+
var button = buttonFromTarget(e.target);
|
|
16738
|
+
|
|
16739
|
+
if (button) {
|
|
16740
|
+
focusElement(button);
|
|
16741
|
+
}
|
|
16742
|
+
}
|
|
16743
|
+
|
|
16674
16744
|
return function () {
|
|
16675
16745
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('mouseover', onMouseOver);
|
|
16676
16746
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('mouseout', onLeave);
|
|
@@ -16678,15 +16748,7 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
16678
16748
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('blur', onLeave, true);
|
|
16679
16749
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('keydown', onEscape);
|
|
16680
16750
|
};
|
|
16681
|
-
}, [BodyRef, allow, setPreviewEmoji]);
|
|
16682
|
-
|
|
16683
|
-
function onMouseOver(e) {
|
|
16684
|
-
var button = buttonFromTarget(e.target);
|
|
16685
|
-
|
|
16686
|
-
if (button) {
|
|
16687
|
-
focusElement(button);
|
|
16688
|
-
}
|
|
16689
|
-
}
|
|
16751
|
+
}, [BodyRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
16690
16752
|
}
|
|
16691
16753
|
|
|
16692
16754
|
var FlexDirection;
|
|
@@ -16965,25 +17027,36 @@ function usePickerMainKeyboardEvents() {
|
|
|
16965
17027
|
var SearchInputRef = useSearchInputRef();
|
|
16966
17028
|
var focusSearchInput = useFocusSearchInput();
|
|
16967
17029
|
var hasOpenToggles = useHasOpenToggles();
|
|
17030
|
+
var disallowMouseMove = useDisallowMouseMove();
|
|
16968
17031
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
16969
17032
|
var onKeyDown = React.useMemo(function () {
|
|
16970
17033
|
return function onKeyDown(event) {
|
|
16971
17034
|
var key = event.key;
|
|
16972
17035
|
|
|
16973
|
-
|
|
16974
|
-
|
|
17036
|
+
switch (key) {
|
|
17037
|
+
case KeyboardEvents.ArrowDown:
|
|
17038
|
+
case KeyboardEvents.ArrowUp:
|
|
17039
|
+
case KeyboardEvents.ArrowLeft:
|
|
17040
|
+
case KeyboardEvents.ArrowRight:
|
|
17041
|
+
disallowMouseMove();
|
|
17042
|
+
break;
|
|
17043
|
+
// eslint-disable-next-line no-fallthrough
|
|
17044
|
+
|
|
17045
|
+
case KeyboardEvents.Escape:
|
|
17046
|
+
event.preventDefault();
|
|
16975
17047
|
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
17048
|
+
if (hasOpenToggles()) {
|
|
17049
|
+
closeAllOpenToggles();
|
|
17050
|
+
return;
|
|
17051
|
+
}
|
|
16980
17052
|
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
17053
|
+
clearSearch();
|
|
17054
|
+
scrollTo(0);
|
|
17055
|
+
focusSearchInput();
|
|
17056
|
+
break;
|
|
16984
17057
|
}
|
|
16985
17058
|
};
|
|
16986
|
-
}, [scrollTo, clearSearch, closeAllOpenToggles, focusSearchInput, hasOpenToggles]);
|
|
17059
|
+
}, [scrollTo, clearSearch, closeAllOpenToggles, focusSearchInput, hasOpenToggles, disallowMouseMove]);
|
|
16987
17060
|
React.useEffect(function () {
|
|
16988
17061
|
var current = PickerMainRef.current;
|
|
16989
17062
|
|