emoji-picker-react 4.7.11 → 4.7.12
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 +2 -2
- package/dist/config/config.d.ts +1 -0
- package/dist/config/useConfig.d.ts +1 -0
- package/dist/emoji-picker-react.cjs.development.js +53 -38
- 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 +54 -39
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/EmojiPickerReact.tsx +9 -0
- package/src/components/context/PickerConfigContext.tsx +11 -3
- package/src/components/main/PickerMain.tsx +1 -2
- package/src/config/config.ts +3 -1
- package/src/config/mutableConfig.ts +3 -1
- package/src/config/useConfig.ts +5 -0
package/package.json
CHANGED
package/src/EmojiPickerReact.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
import { PickerStyleTag } from './Stylesheet/stylesheet';
|
|
3
4
|
import { Reactions } from './components/Reactions/Reactions';
|
|
4
5
|
import { Body } from './components/body/Body';
|
|
5
6
|
import { ElementRefContextProvider } from './components/context/ElementRefContext';
|
|
@@ -8,12 +9,14 @@ import { useReactionsModeState } from './components/context/PickerContext';
|
|
|
8
9
|
import { Preview } from './components/footer/Preview';
|
|
9
10
|
import { Header } from './components/header/Header';
|
|
10
11
|
import PickerMain from './components/main/PickerMain';
|
|
12
|
+
import { useOpenConfig } from './config/useConfig';
|
|
11
13
|
|
|
12
14
|
import { PickerProps } from './index';
|
|
13
15
|
|
|
14
16
|
function EmojiPicker(props: PickerProps) {
|
|
15
17
|
return (
|
|
16
18
|
<ElementRefContextProvider>
|
|
19
|
+
<PickerStyleTag />
|
|
17
20
|
<PickerConfigProvider {...props}>
|
|
18
21
|
<ContentControl />
|
|
19
22
|
</PickerConfigProvider>
|
|
@@ -24,6 +27,7 @@ function EmojiPicker(props: PickerProps) {
|
|
|
24
27
|
function ContentControl() {
|
|
25
28
|
const [reactionsDefaultOpen] = useReactionsModeState();
|
|
26
29
|
const [renderAll, setRenderAll] = React.useState(!reactionsDefaultOpen);
|
|
30
|
+
const isOpen = useOpenConfig();
|
|
27
31
|
|
|
28
32
|
React.useEffect(() => {
|
|
29
33
|
if (!renderAll) {
|
|
@@ -31,6 +35,10 @@ function ContentControl() {
|
|
|
31
35
|
}
|
|
32
36
|
}, [renderAll]);
|
|
33
37
|
|
|
38
|
+
if (!isOpen) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
return (
|
|
35
43
|
<PickerMain>
|
|
36
44
|
<Reactions />
|
|
@@ -50,6 +58,7 @@ export default React.memo(EmojiPicker, (prev, next) => {
|
|
|
50
58
|
const prevCustomEmojis = prev.customEmojis ?? [];
|
|
51
59
|
const nextCustomEmojis = next.customEmojis ?? [];
|
|
52
60
|
return (
|
|
61
|
+
prev.open === next.open &&
|
|
53
62
|
prev.emojiVersion === next.emojiVersion &&
|
|
54
63
|
prev.reactionsDefaultOpen === next.reactionsDefaultOpen &&
|
|
55
64
|
prev.searchPlaceHolder === next.searchPlaceHolder &&
|
|
@@ -32,12 +32,13 @@ export function useSetConfig(config: PickerConfig) {
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
React.useEffect(() => {
|
|
35
|
-
if (config
|
|
36
|
-
|
|
35
|
+
if (avoidRefresh(config as Props, (mergedConfig as unknown) as Props)) {
|
|
36
|
+
return;
|
|
37
37
|
}
|
|
38
|
+
setMergedConfig(mergeConfig(config));
|
|
38
39
|
// not gonna...
|
|
39
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
}, [config.customEmojis?.length]);
|
|
41
|
+
}, [config.customEmojis?.length, config.open]);
|
|
41
42
|
|
|
42
43
|
return mergedConfig;
|
|
43
44
|
}
|
|
@@ -45,3 +46,10 @@ export function useSetConfig(config: PickerConfig) {
|
|
|
45
46
|
export function usePickerConfig() {
|
|
46
47
|
return React.useContext(ConfigContext);
|
|
47
48
|
}
|
|
49
|
+
|
|
50
|
+
function avoidRefresh(prev: Props, next: Props) {
|
|
51
|
+
return (
|
|
52
|
+
prev.customEmojis?.length === next.customEmojis?.length &&
|
|
53
|
+
prev.open === next.open
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -2,7 +2,7 @@ import { cx } from 'flairup';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { ClassNames } from '../../DomUtils/classNames';
|
|
5
|
-
import {
|
|
5
|
+
import { stylesheet } from '../../Stylesheet/stylesheet';
|
|
6
6
|
import {
|
|
7
7
|
useClassNameConfig,
|
|
8
8
|
useStyleConfig,
|
|
@@ -25,7 +25,6 @@ type Props = Readonly<{
|
|
|
25
25
|
export default function PickerMain({ children }: Props) {
|
|
26
26
|
return (
|
|
27
27
|
<PickerContextProvider>
|
|
28
|
-
<PickerStyleTag />
|
|
29
28
|
<PickerRootElement>{children}</PickerRootElement>
|
|
30
29
|
</PickerContextProvider>
|
|
31
30
|
);
|
package/src/config/config.ts
CHANGED
|
@@ -88,7 +88,8 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
88
88
|
unicodeToHide: new Set<string>(KNOWN_FAILING_EMOJIS),
|
|
89
89
|
width: 350,
|
|
90
90
|
reactionsDefaultOpen: false,
|
|
91
|
-
reactions: DEFAULT_REACTIONS
|
|
91
|
+
reactions: DEFAULT_REACTIONS,
|
|
92
|
+
open: true
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -116,6 +117,7 @@ export type PickerConfigInternal = {
|
|
|
116
117
|
customEmojis: CustomEmoji[];
|
|
117
118
|
reactionsDefaultOpen: boolean;
|
|
118
119
|
reactions: string[];
|
|
120
|
+
open: boolean;
|
|
119
121
|
};
|
|
120
122
|
|
|
121
123
|
export type PreviewConfig = {
|
|
@@ -26,7 +26,9 @@ export function useDefineMutableConfig(
|
|
|
26
26
|
|
|
27
27
|
React.useEffect(() => {
|
|
28
28
|
MutableConfigRef.current.onEmojiClick = config.onEmojiClick || emptyFunc;
|
|
29
|
-
|
|
29
|
+
MutableConfigRef.current.onReactionClick =
|
|
30
|
+
config.onReactionClick || config.onEmojiClick;
|
|
31
|
+
}, [config.onEmojiClick, config.onReactionClick]);
|
|
30
32
|
|
|
31
33
|
return MutableConfigRef;
|
|
32
34
|
}
|
package/src/config/useConfig.ts
CHANGED
|
@@ -66,6 +66,11 @@ export function useCustomEmojisConfig(): CustomEmoji[] {
|
|
|
66
66
|
return customEmojis;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
export function useOpenConfig(): boolean {
|
|
70
|
+
const { open } = usePickerConfig();
|
|
71
|
+
return open;
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
export function useOnEmojiClickConfig(
|
|
70
75
|
mouseEventSource: MOUSE_EVENT_SOURCE
|
|
71
76
|
): (emoji: EmojiClickData, event: MouseEvent) => void {
|