emoji-picker-react 4.12.3 → 4.13.0

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.12.3",
2
+ "version": "4.13.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -8,6 +8,7 @@ import {
8
8
  } from '../../config/useConfig';
9
9
  import { emojiByUnified } from '../../dataUtils/emojiSelectors';
10
10
  import { getSuggested } from '../../dataUtils/suggested';
11
+ import { useIsEmojiDisallowed } from '../../hooks/useDisallowedEmojis';
11
12
  import { useIsEverMounted } from '../../hooks/useIsEverMounted';
12
13
  import { useUpdateSuggested } from '../context/PickerContext';
13
14
  import { ClickableEmoji } from '../emoji/Emoji';
@@ -29,6 +30,7 @@ export function Suggested({ categoryConfig }: Props) {
29
30
  [suggestedUpdated, suggestedEmojisModeConfig]
30
31
  );
31
32
  const emojiStyle = useEmojiStyleConfig();
33
+ const isEmojiDisallowed = useIsEmojiDisallowed();
32
34
 
33
35
  if (!isMounted) {
34
36
  return null;
@@ -47,6 +49,10 @@ export function Suggested({ categoryConfig }: Props) {
47
49
  return null;
48
50
  }
49
51
 
52
+ if (isEmojiDisallowed(emoji)) {
53
+ return null;
54
+ }
55
+
50
56
  return (
51
57
  <ClickableEmoji
52
58
  showVariations={false}
@@ -20,13 +20,17 @@ import { useEmojiPreviewEvents } from '../../hooks/useEmojiPreviewEvents';
20
20
  import { useIsSkinToneInPreview } from '../../hooks/useShouldShowSkinTonePicker';
21
21
  import Flex from '../Layout/Flex';
22
22
  import Space from '../Layout/Space';
23
- import { useEmojiVariationPickerState } from '../context/PickerContext';
23
+ import {
24
+ useEmojiVariationPickerState,
25
+ useReactionsModeState
26
+ } from '../context/PickerContext';
24
27
  import { ViewOnlyEmoji } from '../emoji/ViewOnlyEmoji';
25
28
  import { SkinTonePickerMenu } from '../header/SkinTonePicker/SkinTonePicker';
26
29
 
27
30
  export function Preview() {
28
31
  const previewConfig = usePreviewConfig();
29
32
  const isSkinToneInPreview = useIsSkinToneInPreview();
33
+ const [reactionsOpen] = useReactionsModeState();
30
34
 
31
35
  if (!previewConfig.showPreview) {
32
36
  return null;
@@ -34,7 +38,11 @@ export function Preview() {
34
38
 
35
39
  return (
36
40
  <Flex
37
- className={cx(styles.preview, commonInteractionStyles.hiddenOnReactions)}
41
+ className={cx(
42
+ styles.preview,
43
+ commonInteractionStyles.hiddenOnReactions,
44
+ reactionsOpen && styles.hideOnReactions
45
+ )}
38
46
  >
39
47
  <PreviewBody />
40
48
  <Space />
@@ -123,5 +131,9 @@ const styles = stylesheet.create({
123
131
  },
124
132
  emoji: {
125
133
  padding: '0'
134
+ },
135
+ hideOnReactions: {
136
+ opacity: '0',
137
+ transition: 'opacity 0.5s ease-in-out'
126
138
  }
127
139
  });
@@ -151,5 +151,13 @@ export type PickerConfig = Partial<ConfigExternal>;
151
151
 
152
152
  export type PickerDimensions = string | number;
153
153
 
154
- export type MouseDownEvent = (emoji: EmojiClickData, event: MouseEvent) => void;
154
+ export type MouseDownEvent = (
155
+ emoji: EmojiClickData,
156
+ event: MouseEvent,
157
+ api: OnEmojiClickApi
158
+ ) => void;
155
159
  export type OnSkinToneChange = (emoji: SkinTones) => void;
160
+
161
+ type OnEmojiClickApi = {
162
+ collapseToReactions: () => void;
163
+ };
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { usePickerConfig } from '../components/context/PickerConfigContext';
4
+ import { useReactionsModeState } from '../components/context/PickerContext';
4
5
  import {
5
6
  EmojiClickData,
6
7
  EmojiStyle,
@@ -80,17 +81,30 @@ export function useOnEmojiClickConfig(
80
81
  mouseEventSource: MOUSE_EVENT_SOURCE
81
82
  ): (emoji: EmojiClickData, event: MouseEvent) => void {
82
83
  const { current } = useMutableConfig();
84
+ const [, setReactionsOpen] = useReactionsModeState();
85
+
86
+ const handler = current.onEmojiClick || (() => {});
87
+ const { onReactionClick } = current;
88
+
89
+ if (mouseEventSource === MOUSE_EVENT_SOURCE.REACTIONS && onReactionClick) {
90
+ return (...args) =>
91
+ onReactionClick(...args, {
92
+ collapseToReactions: () => {
93
+ setReactionsOpen(o => o);
94
+ }
95
+ });
96
+ }
83
97
 
84
- const handler =
85
- (mouseEventSource === MOUSE_EVENT_SOURCE.REACTIONS
86
- ? current.onReactionClick
87
- : current.onEmojiClick) ?? current.onEmojiClick;
88
-
89
- return handler || (() => {});
98
+ return (...args) => {
99
+ handler(...args, {
100
+ collapseToReactions: () => {
101
+ setReactionsOpen(true);
102
+ }
103
+ });
104
+ };
90
105
  }
91
106
 
92
- export function useOnSkinToneChangeConfig(
93
- ): (skinTone: SkinTones) => void {
107
+ export function useOnSkinToneChangeConfig(): (skinTone: SkinTones) => void {
94
108
  const { current } = useMutableConfig();
95
109
 
96
110
  return current.onSkinToneChange || (() => {});