emoji-picker-react 4.20.0 → 4.20.2
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/README.md +55 -230
- package/dist/Stylesheet/stylesheet.d.ts +16 -4
- package/dist/dataUtils/emojiSelectors.d.ts +0 -2
- package/dist/emoji-picker-react.cjs.development.js +96 -114
- 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 +97 -115
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/llms.txt +425 -0
- package/package.json +11 -8
- package/src/components/body/EmojiList.tsx +15 -16
- package/src/components/body/EmojiVariationPicker.tsx +1 -1
- package/src/components/body/MeasureEmoji.tsx +4 -5
- package/src/components/context/PickerDataContext.tsx +9 -1
- package/src/components/emoji/Emoji.tsx +1 -1
- package/src/components/footer/Preview.tsx +1 -1
- package/src/dataUtils/emojiSelectors.ts +4 -31
- package/src/dataUtils/suggested.ts +7 -4
- package/src/hooks/useDebouncedState.ts +2 -2
- package/src/hooks/useIsomorphicLayoutEffect.ts +6 -0
- package/src/hooks/useMouseDownHandlers.ts +3 -3
- package/src/hooks/useOnFocus.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SkinTones, SuggestionMode } from '../types/exposedTypes';
|
|
2
2
|
|
|
3
3
|
import { DataEmoji } from './DataTypes';
|
|
4
|
-
import { emojiUnified } from './
|
|
4
|
+
import { emojiUnified } from './emojiUtils';
|
|
5
5
|
|
|
6
6
|
const SUGGESTED_LS_KEY = 'epr_suggested';
|
|
7
7
|
|
|
@@ -15,11 +15,11 @@ type Suggested = SuggestedItem[];
|
|
|
15
15
|
|
|
16
16
|
export function getSuggested(mode?: SuggestionMode): Suggested {
|
|
17
17
|
try {
|
|
18
|
-
if (!window
|
|
18
|
+
if (typeof window === 'undefined' || !window.localStorage) {
|
|
19
19
|
return [];
|
|
20
20
|
}
|
|
21
21
|
const recent = JSON.parse(
|
|
22
|
-
window
|
|
22
|
+
window.localStorage.getItem(SUGGESTED_LS_KEY) ?? '[]',
|
|
23
23
|
) as Suggested;
|
|
24
24
|
|
|
25
25
|
if (mode === SuggestionMode.FREQUENT) {
|
|
@@ -58,7 +58,10 @@ export function setSuggested(emoji: DataEmoji, skinTone: SkinTones) {
|
|
|
58
58
|
nextList.length = Math.min(nextList.length, 14);
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
|
-
|
|
61
|
+
if (typeof window === 'undefined') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
window.localStorage.setItem(SUGGESTED_LS_KEY, JSON.stringify(nextList));
|
|
62
65
|
// Prevents the change from being seen immediately.
|
|
63
66
|
} catch {
|
|
64
67
|
// ignore
|
|
@@ -5,7 +5,7 @@ export function useDebouncedState<T>(
|
|
|
5
5
|
delay: number = 0,
|
|
6
6
|
): [T, (value: T) => Promise<T>] {
|
|
7
7
|
const [state, setState] = useState<T>(initialValue);
|
|
8
|
-
const timer = useRef<
|
|
8
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
9
9
|
|
|
10
10
|
function debouncedSetState(value: T) {
|
|
11
11
|
return new Promise<T>((resolve) => {
|
|
@@ -13,7 +13,7 @@ export function useDebouncedState<T>(
|
|
|
13
13
|
clearTimeout(timer.current);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
timer.current =
|
|
16
|
+
timer.current = setTimeout(() => {
|
|
17
17
|
setState(value);
|
|
18
18
|
resolve(value);
|
|
19
19
|
}, delay);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
// `useLayoutEffect` warns during SSR since it never runs on the server.
|
|
4
|
+
// Fall back to `useEffect` there: measurement only matters on the client.
|
|
5
|
+
export const useIsomorphicLayoutEffect =
|
|
6
|
+
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
emojiHasVariations,
|
|
27
27
|
emojiNames,
|
|
28
28
|
emojiUnified,
|
|
29
|
-
} from '../dataUtils/
|
|
29
|
+
} from '../dataUtils/emojiUtils';
|
|
30
30
|
import { parseNativeEmoji } from '../dataUtils/parseNativeEmoji';
|
|
31
31
|
import { setSuggested } from '../dataUtils/suggested';
|
|
32
32
|
import { isCustomEmoji } from '../typeRefinements/typeRefinements';
|
|
@@ -39,7 +39,7 @@ export function useMouseDownHandlers(
|
|
|
39
39
|
ContainerRef: React.MutableRefObject<NullableElement>,
|
|
40
40
|
mouseEventSource: MOUSE_EVENT_SOURCE,
|
|
41
41
|
) {
|
|
42
|
-
const mouseDownTimerRef = useRef<
|
|
42
|
+
const mouseDownTimerRef = useRef<ReturnType<typeof setTimeout>>();
|
|
43
43
|
const setVariationPicker = useSetVariationPicker();
|
|
44
44
|
const disallowClickRef = useDisallowClickRef();
|
|
45
45
|
const [, setEmojiVariationPicker] = useEmojiVariationPickerState();
|
|
@@ -99,7 +99,7 @@ export function useMouseDownHandlers(
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
mouseDownTimerRef.current =
|
|
102
|
+
mouseDownTimerRef.current = setTimeout(() => {
|
|
103
103
|
disallowClickRef.current = true;
|
|
104
104
|
mouseDownTimerRef.current = undefined;
|
|
105
105
|
closeAllOpenToggles();
|
package/src/hooks/useOnFocus.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import { buttonFromTarget, emojiFromElement } from '../DomUtils/selectors';
|
|
4
4
|
import { useBodyRef } from '../components/context/ElementRefContext';
|
|
5
5
|
import { useEmojiStyleConfig, useGetEmojiUrlConfig } from '../config/useConfig';
|
|
6
|
-
import { emojiHasVariations } from '../dataUtils/
|
|
6
|
+
import { emojiHasVariations } from '../dataUtils/emojiUtils';
|
|
7
7
|
import { EmojiStyle } from '../types/exposedTypes';
|
|
8
8
|
|
|
9
9
|
import { preloadEmoji } from './preloadEmoji';
|