emoji-picker-react 4.7.0 → 4.7.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 CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ![image](https://github.com/ealush/emoji-picker-react/assets/11255103/48901306-e7fd-49cd-8f1e-9b214083a61d)
8
8
 
9
+ ![reactions](https://github.com/ealush/emoji-picker-react/assets/11255103/38a9c652-ee2e-43d4-b0e6-33735f1bcbe7)
10
+
9
11
  ---
10
12
 
11
13
  _If you enjoy using emoji-picker-react<br/>
@@ -62,30 +64,31 @@ function App() {
62
64
 
63
65
  The following props are accepted by them picker:
64
66
 
65
- | Prop | Type | Default | Description |
66
- | ---------------------- | ------------------------------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
67
- | onEmojiClick | function | | Callback function that is called when an emoji is clicked. The function receives the emoji object as a parameter. |
68
- | autoFocusSearch | boolean | `true` | Controls the auto focus of the search input. |
69
- | Theme | string | `light` | Controls the theme of the picker. Possible values are `light`, `dark` and `auto`. |
70
- | emojiStyle | string | `apple` | Controls the emoji style. Possible values are `google`, `apple`, `facebook`, `twitter` and `native`. |
71
- | defaultSkinTone | string | `neutral` | Controls the default skin tone. |
72
- | lazyLoadEmojis | boolean | `false` | Controls whether the emojis are loaded lazily or not. |
73
- | previewConfig | object | `{}` | Controls the preview of the emoji. See below for more information. |
74
- | searchPlaceholder | string | `Search` | Controls the placeholder of the search input. |
75
- | suggestedEmojisMode | string | `frequent` | Controls the suggested emojis mode. Possible values are `frequent` and `recent`. |
76
- | skinTonesDisabled | boolean | `false` | Controls whether the skin tones are disabled or not. |
77
- | searchDisabled | boolean | `false` | Controls whether the search is disabled or not. When disabled, the skin tone picker will be shown in the preview component. |
78
- | skinTonePickerLocation | string | `SEARCH` | Controls the location of the skin tone picker. Possible values are `SEARCH` and `PREVIEW`. |
79
- | emojiVersion | `string` | - | Allows displaying emojis up to a certain version for compatibility. |
80
- | `className` | `string` | - | Adds a class name to the root element of the picker. |
81
- | `width` | `number`/`string` | `350` | Controls the width of the picker. You can provide a number that will be treated as pixel size, or your any accepted css width as string. |
82
- | `height` | `number`/`string` | `450` | Controls the height of the picker. You can provide a number that will be treated as pixel size, or your any accepted css height as string. |
83
- | `style` | `React.CSSProperties` | `{}` | Adds inline style to the root element of the picker. |
84
- | getEmojiUrl | `Function` | - | Allows to customize the emoji url and provide your own image host. |
85
- | categories | `Array` | - | Allows full config over ordering, naming and display of categories. |
86
- | customEmojis | `Array<{names: string[], imgUrl: string, id: string}>` | - | Allows adding custom emojis to the picker. |
87
- | reactionsDefaultOpen | `boolean` | `false` | Controls whether the reactions picker is on the initial mount instead of the main picker component. |
88
- | reactions | string[] | - | Controls the reactions to display in the reactions picker. Takes unified emoji ids |
67
+ | Prop | Type | Default | Description |
68
+ | ---------------------- | ------------------------------------------------------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
+ | onEmojiClick | function | | Callback function that is called when an emoji is clicked. The function receives the emoji object as a parameter. |
70
+ | autoFocusSearch | boolean | `true` | Controls the auto focus of the search input. |
71
+ | Theme | string | `light` | Controls the theme of the picker. Possible values are `light`, `dark` and `auto`. |
72
+ | emojiStyle | string | `apple` | Controls the emoji style. Possible values are `google`, `apple`, `facebook`, `twitter` and `native`. |
73
+ | defaultSkinTone | string | `neutral` | Controls the default skin tone. |
74
+ | lazyLoadEmojis | boolean | `false` | Controls whether the emojis are loaded lazily or not. |
75
+ | previewConfig | object | `{}` | Controls the preview of the emoji. See below for more information. |
76
+ | searchPlaceholder | string | `Search` | Controls the placeholder of the search input. |
77
+ | suggestedEmojisMode | string | `frequent` | Controls the suggested emojis mode. Possible values are `frequent` and `recent`. |
78
+ | skinTonesDisabled | boolean | `false` | Controls whether the skin tones are disabled or not. |
79
+ | searchDisabled | boolean | `false` | Controls whether the search is disabled or not. When disabled, the skin tone picker will be shown in the preview component. |
80
+ | skinTonePickerLocation | string | `SEARCH` | Controls the location of the skin tone picker. Possible values are `SEARCH` and `PREVIEW`. |
81
+ | emojiVersion | `string` | - | Allows displaying emojis up to a certain version for compatibility. |
82
+ | `className` | `string` | - | Adds a class name to the root element of the picker. |
83
+ | `width` | `number`/`string` | `350` | Controls the width of the picker. You can provide a number that will be treated as pixel size, or your any accepted css width as string. |
84
+ | `height` | `number`/`string` | `450` | Controls the height of the picker. You can provide a number that will be treated as pixel size, or your any accepted css height as string. |
85
+ | `style` | `React.CSSProperties` | `{}` | Adds inline style to the root element of the picker. |
86
+ | getEmojiUrl | `Function` | - | Allows to customize the emoji url and provide your own image host. |
87
+ | categories | `Array` | - | Allows full config over ordering, naming and display of categories. |
88
+ | customEmojis | `Array<{names: string[], imgUrl: string, id: string}>` | - | Allows adding custom emojis to the picker. |
89
+ | reactionsDefaultOpen | `boolean` | `false` | Controls whether the reactions picker is on the initial mount instead of the main picker component. |
90
+ | reactions | string[] | - | Controls the reactions to display in the reactions picker. Takes unified emoji ids |
91
+ | onReactionClick | `Function` | - | Callback function that is called when a reaction is clicked. The function receives the emoji object as a parameter. If not passed, onEmojiClicked is used. |
89
92
 
90
93
  ## Full details
91
94
 
@@ -118,9 +121,11 @@ The following props are accepted by them picker:
118
121
  import { EmojiStyle } from 'emoji-picker-react';
119
122
  ```
120
123
 
121
- - `autoFocusSearch`: `boolean` - Whether to focus the search input on mount. Defaults to `true`.
124
+ * `autoFocusSearch`: `boolean` - Whether to focus the search input on mount. Defaults to `true`.
122
125
 
123
- \*
126
+ * `lazyLoadEmojis`: `boolean` - Whether to lazy load the emojis. Defaults to `false`.
127
+
128
+ - `autoFocusSearch`: `boolean` - Whether to focus the search input on mount. Defaults to `true`.
124
129
 
125
130
  - `lazyLoadEmojis`: `boolean` - Whether to lazy load the emojis. Defaults to `false`.
126
131
 
@@ -268,7 +273,7 @@ To customize the reactions, you should pass an array of unified emoji ids to the
268
273
  The reactions picker uses the same event handlers, and the same css variables for customizations.
269
274
 
270
275
  ```jsx
271
- <Picker reactionsDefaultOpen />
276
+ <Picker reactionsDefaultOpen={true} onReactionClick={handleReaction} />
272
277
  ```
273
278
 
274
279
  # Customization
@@ -8,6 +8,7 @@ declare type ClickableEmojiButtonProps = Readonly<{
8
8
  hasVariations: boolean;
9
9
  unified?: string;
10
10
  round?: boolean;
11
+ className?: string;
11
12
  }>;
12
- export declare function ClickableEmojiButton({ emojiNames, unified, hidden, hiddenOnSearch, showVariations, hasVariations, children, round }: ClickableEmojiButtonProps): JSX.Element;
13
+ export declare function ClickableEmojiButton({ emojiNames, unified, hidden, hiddenOnSearch, showVariations, hasVariations, children, className, round }: ClickableEmojiButtonProps): JSX.Element;
13
14
  export {};
@@ -9,5 +9,5 @@ declare type ClickableEmojiProps = Readonly<BaseEmojiProps & {
9
9
  className?: string;
10
10
  round?: boolean;
11
11
  }>;
12
- export declare function ClickableEmoji({ emoji, unified, hidden, hiddenOnSearch, emojiStyle, showVariations, size, lazyLoad, getEmojiUrl, round }: ClickableEmojiProps): JSX.Element;
12
+ export declare function ClickableEmoji({ emoji, unified, hidden, hiddenOnSearch, emojiStyle, showVariations, size, lazyLoad, getEmojiUrl, className, round }: ClickableEmojiProps): JSX.Element;
13
13
  export {};
@@ -42,8 +42,10 @@ export declare type PreviewConfig = {
42
42
  };
43
43
  declare type ConfigExternal = {
44
44
  previewConfig: Partial<PreviewConfig>;
45
- onEmojiClick: (emoji: EmojiClickData, event: MouseEvent) => void;
45
+ onEmojiClick: MouseDownEvent;
46
+ onReactionClick: MouseDownEvent;
46
47
  } & Omit<PickerConfigInternal, 'previewConfig' | 'unicodeToHide'>;
47
48
  export declare type PickerConfig = Partial<ConfigExternal>;
48
49
  export declare type PickerDimensions = string | number;
50
+ export declare type MouseDownEvent = (emoji: EmojiClickData, event: MouseEvent) => void;
49
51
  export {};
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { EmojiClickData } from '../types/exposedTypes';
2
+ import { MouseDownEvent } from './config';
3
3
  export declare type MutableConfig = {
4
- onEmojiClick?: (emoji: EmojiClickData, event: MouseEvent) => void;
4
+ onEmojiClick?: MouseDownEvent;
5
+ onReactionClick?: MouseDownEvent;
5
6
  };
6
7
  export declare const MutableConfigContext: React.Context<React.MutableRefObject<MutableConfig>>;
7
8
  export declare function useMutableConfig(): React.MutableRefObject<MutableConfig>;
@@ -3,6 +3,10 @@ import { EmojiClickData, EmojiStyle, SkinTonePickerLocation, SkinTones, Suggesti
3
3
  import { CategoriesConfig } from './categoryConfig';
4
4
  import { PreviewConfig } from './config';
5
5
  import { CustomEmoji } from './customEmojiConfig';
6
+ export declare enum MOUSE_EVENT_SOURCE {
7
+ REACTIONS = "reactions",
8
+ PICKER = "picker"
9
+ }
6
10
  export declare function useSearchPlaceHolderConfig(): string;
7
11
  export declare function useDefaultSkinToneConfig(): SkinTones;
8
12
  export declare function useSkinTonesDisabledConfig(): boolean;
@@ -10,7 +14,7 @@ export declare function useEmojiStyleConfig(): EmojiStyle;
10
14
  export declare function useAutoFocusSearchConfig(): boolean;
11
15
  export declare function useCategoriesConfig(): CategoriesConfig;
12
16
  export declare function useCustomEmojisConfig(): CustomEmoji[];
13
- export declare function useOnEmojiClickConfig(): (emoji: EmojiClickData, event: MouseEvent) => void;
17
+ export declare function useOnEmojiClickConfig(mouseEventSource: MOUSE_EVENT_SOURCE): (emoji: EmojiClickData, event: MouseEvent) => void;
14
18
  export declare function usePreviewConfig(): PreviewConfig;
15
19
  export declare function useThemeConfig(): Theme;
16
20
  export declare function useSuggestedEmojisModeConfig(): SuggestionMode;
@@ -16887,7 +16887,8 @@ function useMutableConfig() {
16887
16887
  }
16888
16888
  function useDefineMutableConfig(config) {
16889
16889
  var MutableConfigRef = React__default.useRef({
16890
- onEmojiClick: config.onEmojiClick || emptyFunc
16890
+ onEmojiClick: config.onEmojiClick || emptyFunc,
16891
+ onReactionClick: config.onReactionClick || config.onEmojiClick
16891
16892
  });
16892
16893
  React__default.useEffect(function () {
16893
16894
  MutableConfigRef.current.onEmojiClick = config.onEmojiClick || emptyFunc;
@@ -16896,6 +16897,11 @@ function useDefineMutableConfig(config) {
16896
16897
  }
16897
16898
  function emptyFunc() {}
16898
16899
 
16900
+ var MOUSE_EVENT_SOURCE;
16901
+ (function (MOUSE_EVENT_SOURCE) {
16902
+ MOUSE_EVENT_SOURCE["REACTIONS"] = "reactions";
16903
+ MOUSE_EVENT_SOURCE["PICKER"] = "picker";
16904
+ })(MOUSE_EVENT_SOURCE || (MOUSE_EVENT_SOURCE = {}));
16899
16905
  function useSearchPlaceHolderConfig() {
16900
16906
  var _find;
16901
16907
  var _usePickerConfig = usePickerConfig(),
@@ -16935,10 +16941,12 @@ function useCustomEmojisConfig() {
16935
16941
  customEmojis = _usePickerConfig7.customEmojis;
16936
16942
  return customEmojis;
16937
16943
  }
16938
- function useOnEmojiClickConfig() {
16944
+ function useOnEmojiClickConfig(mouseEventSource) {
16945
+ var _ref;
16939
16946
  var _useMutableConfig = useMutableConfig(),
16940
16947
  current = _useMutableConfig.current;
16941
- return current.onEmojiClick || function () {};
16948
+ var handler = (_ref = mouseEventSource === MOUSE_EVENT_SOURCE.REACTIONS ? current.onReactionClick : current.onEmojiClick) != null ? _ref : current.onEmojiClick;
16949
+ return handler || function () {};
16942
16950
  }
16943
16951
  function usePreviewConfig() {
16944
16952
  var _usePickerConfig8 = usePickerConfig(),
@@ -17689,7 +17697,7 @@ function useSetVariationPicker() {
17689
17697
  };
17690
17698
  }
17691
17699
 
17692
- function useMouseDownHandlers(BodyRef) {
17700
+ function useMouseDownHandlers(ContainerRef, mouseEventSource) {
17693
17701
  var mouseDownTimerRef = React.useRef();
17694
17702
  var setVariationPicker = useSetVariationPicker();
17695
17703
  var disallowClickRef = useDisallowClickRef();
@@ -17698,7 +17706,7 @@ function useMouseDownHandlers(BodyRef) {
17698
17706
  var closeAllOpenToggles = useCloseAllOpenToggles();
17699
17707
  var _useActiveSkinToneSta = useActiveSkinToneState(),
17700
17708
  activeSkinTone = _useActiveSkinToneSta[0];
17701
- var onEmojiClick = useOnEmojiClickConfig();
17709
+ var onEmojiClick = useOnEmojiClickConfig(mouseEventSource);
17702
17710
  var _useUpdateSuggested = useUpdateSuggested(),
17703
17711
  updateSuggested = _useUpdateSuggested[1];
17704
17712
  var getEmojiUrl = useGetEmojiUrlConfig();
@@ -17753,25 +17761,25 @@ function useMouseDownHandlers(BodyRef) {
17753
17761
  }
17754
17762
  }, [disallowClickRef]);
17755
17763
  React.useEffect(function () {
17756
- if (!BodyRef.current) {
17764
+ if (!ContainerRef.current) {
17757
17765
  return;
17758
17766
  }
17759
- var bodyRef = BodyRef.current;
17760
- bodyRef.addEventListener('click', onClick, {
17767
+ var confainerRef = ContainerRef.current;
17768
+ confainerRef.addEventListener('click', onClick, {
17761
17769
  passive: true
17762
17770
  });
17763
- bodyRef.addEventListener('mousedown', onMouseDown, {
17771
+ confainerRef.addEventListener('mousedown', onMouseDown, {
17764
17772
  passive: true
17765
17773
  });
17766
- bodyRef.addEventListener('mouseup', onMouseUp, {
17774
+ confainerRef.addEventListener('mouseup', onMouseUp, {
17767
17775
  passive: true
17768
17776
  });
17769
17777
  return function () {
17770
- bodyRef == null ? void 0 : bodyRef.removeEventListener('click', onClick);
17771
- bodyRef == null ? void 0 : bodyRef.removeEventListener('mousedown', onMouseDown);
17772
- bodyRef == null ? void 0 : bodyRef.removeEventListener('mouseup', onMouseUp);
17778
+ confainerRef == null ? void 0 : confainerRef.removeEventListener('click', onClick);
17779
+ confainerRef == null ? void 0 : confainerRef.removeEventListener('mousedown', onMouseDown);
17780
+ confainerRef == null ? void 0 : confainerRef.removeEventListener('mouseup', onMouseUp);
17773
17781
  };
17774
- }, [BodyRef, onClick, onMouseDown, onMouseUp]);
17782
+ }, [ContainerRef, onClick, onMouseDown, onMouseUp]);
17775
17783
  }
17776
17784
  function emojiFromEvent(event) {
17777
17785
  var target = event == null ? void 0 : event.target;
@@ -17842,10 +17850,11 @@ function ClickableEmojiButton(_ref) {
17842
17850
  showVariations = _ref$showVariations === void 0 ? true : _ref$showVariations,
17843
17851
  hasVariations = _ref.hasVariations,
17844
17852
  children = _ref.children,
17853
+ className = _ref.className,
17845
17854
  _ref$round = _ref.round,
17846
17855
  round = _ref$round === void 0 ? false : _ref$round;
17847
17856
  return React.createElement(Button, {
17848
- className: flairup.cx(styles$1.emoji, hidden && commonStyles.hidden, hiddenOnSearch && commonInteractionStyles.hiddenOnSearch, (_cx = {}, _cx[ClassNames.visible] = !hidden && !hiddenOnSearch, _cx), !!(hasVariations && showVariations) && styles$1.hasVariations, round && styles$1.round),
17857
+ className: flairup.cx(styles$1.emoji, hidden && commonStyles.hidden, hiddenOnSearch && commonInteractionStyles.hiddenOnSearch, (_cx = {}, _cx[ClassNames.visible] = !hidden && !hiddenOnSearch, _cx), !!(hasVariations && showVariations) && styles$1.hasVariations, round && styles$1.round, className),
17849
17858
  "data-unified": unified,
17850
17859
  "aria-label": emojiNames[0],
17851
17860
  "data-full-name": emojiNames
@@ -18024,6 +18033,7 @@ function ClickableEmoji(_ref) {
18024
18033
  size = _ref.size,
18025
18034
  lazyLoad = _ref.lazyLoad,
18026
18035
  getEmojiUrl = _ref.getEmojiUrl,
18036
+ className = _ref.className,
18027
18037
  _ref$round = _ref.round,
18028
18038
  round = _ref$round === void 0 ? false : _ref$round;
18029
18039
  var hasVariations = emojiHasVariations(emoji);
@@ -18041,7 +18051,8 @@ function ClickableEmoji(_ref) {
18041
18051
  size: size,
18042
18052
  emojiStyle: emojiStyle,
18043
18053
  lazyLoad: lazyLoad,
18044
- getEmojiUrl: getEmojiUrl
18054
+ getEmojiUrl: getEmojiUrl,
18055
+ className: className
18045
18056
  }));
18046
18057
  }
18047
18058
 
@@ -18130,7 +18141,7 @@ function Reactions() {
18130
18141
  reactionsOpen = _useReactionsModeStat[0];
18131
18142
  var ReactionsRef = useReactionsRef();
18132
18143
  var reactions = useReactionsConfig();
18133
- useMouseDownHandlers(ReactionsRef);
18144
+ useMouseDownHandlers(ReactionsRef, MOUSE_EVENT_SOURCE.REACTIONS);
18134
18145
  var emojiStyle = useEmojiStyleConfig();
18135
18146
  if (!reactionsOpen) {
18136
18147
  return null;
@@ -18146,6 +18157,7 @@ function Reactions() {
18146
18157
  emojiStyle: emojiStyle,
18147
18158
  unified: reaction,
18148
18159
  showVariations: false,
18160
+ className: flairup.cx(styles$5.emojiButton),
18149
18161
  round: true
18150
18162
  }));
18151
18163
  }), React.createElement("li", null, React.createElement(BtnPlus, null)));
@@ -18159,6 +18171,12 @@ var styles$5 = /*#__PURE__*/stylesheet.create({
18159
18171
  justifyContent: 'space-between',
18160
18172
  alignItems: 'center',
18161
18173
  height: '100%'
18174
+ },
18175
+ emojiButton: {
18176
+ ':hover': {
18177
+ transform: 'scale(1.2)'
18178
+ },
18179
+ transition: 'transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.5)'
18162
18180
  }
18163
18181
  });
18164
18182
 
@@ -18886,7 +18904,7 @@ var styles$8 = /*#__PURE__*/stylesheet.create({
18886
18904
  function Body() {
18887
18905
  var BodyRef = useBodyRef();
18888
18906
  useOnScroll(BodyRef);
18889
- useMouseDownHandlers(BodyRef);
18907
+ useMouseDownHandlers(BodyRef, MOUSE_EVENT_SOURCE.PICKER);
18890
18908
  useOnMouseMove();
18891
18909
  return React.createElement("div", {
18892
18910
  className: flairup.cx(styles$9.body, commonInteractionStyles.hiddenOnReactions),
@@ -20458,7 +20476,8 @@ function ExportedEmoji(_ref) {
20458
20476
 
20459
20477
  function EmojiPicker$1(props) {
20460
20478
  var MutableConfigRef = useDefineMutableConfig({
20461
- onEmojiClick: props.onEmojiClick
20479
+ onEmojiClick: props.onEmojiClick,
20480
+ onReactionClick: props.onReactionClick
20462
20481
  });
20463
20482
  return React.createElement(ErrorBoundary, null, React.createElement(MutableConfigContext.Provider, {
20464
20483
  value: MutableConfigRef