emoji-picker-react 4.17.2 → 4.17.4
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/emoji-picker-react.cjs.development.js +23 -7
- 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 +23 -7
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/context/PickerDataContext.tsx +8 -1
- package/src/hooks/useMouseDownHandlers.ts +23 -5
package/package.json
CHANGED
|
@@ -131,7 +131,14 @@ export function useGetEmojisByCategory() {
|
|
|
131
131
|
const suggested = getSuggested(suggestedEmojisModeConfig) ?? [];
|
|
132
132
|
|
|
133
133
|
return suggested
|
|
134
|
-
.map((s) =>
|
|
134
|
+
.map((s) => {
|
|
135
|
+
const emoji = emojiByUnified(s.unified);
|
|
136
|
+
if (!emoji) return undefined;
|
|
137
|
+
return {
|
|
138
|
+
...emoji,
|
|
139
|
+
[Keys.unified]: s.unified,
|
|
140
|
+
};
|
|
141
|
+
})
|
|
135
142
|
.filter(Boolean) as DataEmojis;
|
|
136
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
137
144
|
}, [suggestedUpdated, suggestedEmojisModeConfig, emojiByUnified]);
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
allUnifiedFromEmojiElement,
|
|
6
6
|
isEmojiElement,
|
|
7
7
|
NullableElement
|
|
8
8
|
} from '../DomUtils/selectors';
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
useEmojiVariationPickerState,
|
|
13
13
|
useUpdateSuggested
|
|
14
14
|
} from '../components/context/PickerContext';
|
|
15
|
+
import { usePickerDataContext } from '../components/context/PickerDataContext';
|
|
15
16
|
import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
|
|
16
17
|
import {
|
|
17
18
|
MOUSE_EVENT_SOURCE,
|
|
@@ -48,6 +49,7 @@ export function useMouseDownHandlers(
|
|
|
48
49
|
const [, updateSuggested] = useUpdateSuggested();
|
|
49
50
|
const getEmojiUrl = useGetEmojiUrlConfig();
|
|
50
51
|
const activeEmojiStyle = useEmojiStyleConfig();
|
|
52
|
+
const { emojiByUnified } = usePickerDataContext();
|
|
51
53
|
|
|
52
54
|
const onClick = React.useCallback(
|
|
53
55
|
function onClick(event: MouseEvent) {
|
|
@@ -57,7 +59,7 @@ export function useMouseDownHandlers(
|
|
|
57
59
|
|
|
58
60
|
closeAllOpenToggles();
|
|
59
61
|
|
|
60
|
-
const [emoji, unified] = emojiFromEvent(event);
|
|
62
|
+
const [emoji, unified] = emojiFromEvent(event, emojiByUnified);
|
|
61
63
|
|
|
62
64
|
if (!emoji || !unified) {
|
|
63
65
|
return;
|
|
@@ -77,6 +79,7 @@ export function useMouseDownHandlers(
|
|
|
77
79
|
activeSkinTone,
|
|
78
80
|
closeAllOpenToggles,
|
|
79
81
|
disallowClickRef,
|
|
82
|
+
emojiByUnified,
|
|
80
83
|
onEmojiClick,
|
|
81
84
|
updateSuggested,
|
|
82
85
|
getEmojiUrl,
|
|
@@ -90,7 +93,7 @@ export function useMouseDownHandlers(
|
|
|
90
93
|
clearTimeout(mouseDownTimerRef.current);
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
const [emoji] = emojiFromEvent(event);
|
|
96
|
+
const [emoji] = emojiFromEvent(event, emojiByUnified);
|
|
94
97
|
|
|
95
98
|
if (!emoji || !emojiHasVariations(emoji)) {
|
|
96
99
|
return;
|
|
@@ -106,6 +109,7 @@ export function useMouseDownHandlers(
|
|
|
106
109
|
},
|
|
107
110
|
[
|
|
108
111
|
disallowClickRef,
|
|
112
|
+
emojiByUnified,
|
|
109
113
|
closeAllOpenToggles,
|
|
110
114
|
setVariationPicker,
|
|
111
115
|
setEmojiVariationPicker
|
|
@@ -155,13 +159,27 @@ export function useMouseDownHandlers(
|
|
|
155
159
|
}, [ContainerRef, onClick, onMouseDown, onMouseUp]);
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
function emojiFromEvent(
|
|
162
|
+
function emojiFromEvent(
|
|
163
|
+
event: MouseEvent,
|
|
164
|
+
lookupEmojiByUnified: (unified?: string) => DataEmoji | undefined
|
|
165
|
+
): [DataEmoji, string] | [] {
|
|
159
166
|
const target = event?.target as HTMLElement;
|
|
160
167
|
if (!isEmojiElement(target)) {
|
|
161
168
|
return [];
|
|
162
169
|
}
|
|
163
170
|
|
|
164
|
-
|
|
171
|
+
const { unified, originalUnified } = allUnifiedFromEmojiElement(target);
|
|
172
|
+
const resolvedUnified = unified ?? originalUnified;
|
|
173
|
+
if (!resolvedUnified) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const emoji = lookupEmojiByUnified(resolvedUnified);
|
|
178
|
+
if (!emoji) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return [emoji, unified ?? resolvedUnified];
|
|
165
183
|
}
|
|
166
184
|
|
|
167
185
|
function emojiClickOutput(
|