emoji-picker-react 4.8.0 → 4.9.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/README.md CHANGED
@@ -89,6 +89,7 @@ The following props are accepted by them picker:
89
89
  | reactions | string[] | - | Controls the reactions to display in the reactions picker. Takes unified emoji ids |
90
90
  | 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. |
91
91
  | allowExpandReactions | `boolean` | `true` | Controls whether the reactions picker can be expanded to the main picker. |
92
+ | onSkinToneChange | `Function` | - | Callback function that is called when a skin tone is changed. The function receives new picked skin tone as a parameter. |
92
93
 
93
94
  ## Full details
94
95
 
@@ -140,6 +141,8 @@ The skin tones typescript enum can be imported directly from the package:
140
141
  import { SkinTones } from 'emoji-picker-react';
141
142
  ```
142
143
 
144
+ - `onSkinToneChange`: `(skinTone: SkinTones) => void` - Callback function when a skin tone is changed.
145
+
143
146
  - `searchDisabled`: `boolean` - Whether to disable the search input. Defaults to `false`. When disabled, the skin tone picker will be shown in the preview component.
144
147
 
145
148
  - `skinTonesDisabled`: `boolean` - Whether to disable the skin tone selection. Defaults to `false`.
@@ -46,8 +46,10 @@ declare type ConfigExternal = {
46
46
  previewConfig: Partial<PreviewConfig>;
47
47
  onEmojiClick: MouseDownEvent;
48
48
  onReactionClick: MouseDownEvent;
49
+ onSkinToneChange: OnSkinToneChange;
49
50
  } & Omit<PickerConfigInternal, 'previewConfig' | 'unicodeToHide'>;
50
51
  export declare type PickerConfig = Partial<ConfigExternal>;
51
52
  export declare type PickerDimensions = string | number;
52
53
  export declare type MouseDownEvent = (emoji: EmojiClickData, event: MouseEvent) => void;
54
+ export declare type OnSkinToneChange = (emoji: SkinTones) => void;
53
55
  export {};
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import { MouseDownEvent } from './config';
2
+ import { MouseDownEvent, OnSkinToneChange } from './config';
3
3
  export declare type MutableConfig = {
4
4
  onEmojiClick?: MouseDownEvent;
5
5
  onReactionClick?: MouseDownEvent;
6
+ onSkinToneChange?: OnSkinToneChange;
6
7
  };
7
8
  export declare const MutableConfigContext: React.Context<React.MutableRefObject<MutableConfig>>;
8
9
  export declare function useMutableConfig(): React.MutableRefObject<MutableConfig>;
@@ -17,6 +17,7 @@ export declare function useCategoriesConfig(): CategoriesConfig;
17
17
  export declare function useCustomEmojisConfig(): CustomEmoji[];
18
18
  export declare function useOpenConfig(): boolean;
19
19
  export declare function useOnEmojiClickConfig(mouseEventSource: MOUSE_EVENT_SOURCE): (emoji: EmojiClickData, event: MouseEvent) => void;
20
+ export declare function useOnSkinToneChangeConfig(): (skinTone: SkinTones) => void;
20
21
  export declare function usePreviewConfig(): PreviewConfig;
21
22
  export declare function useThemeConfig(): Theme;
22
23
  export declare function useSuggestedEmojisModeConfig(): SuggestionMode;
@@ -16893,12 +16893,16 @@ function useMutableConfig() {
16893
16893
  function useDefineMutableConfig(config) {
16894
16894
  var MutableConfigRef = React__default.useRef({
16895
16895
  onEmojiClick: config.onEmojiClick || emptyFunc,
16896
- onReactionClick: config.onReactionClick || config.onEmojiClick
16896
+ onReactionClick: config.onReactionClick || config.onEmojiClick,
16897
+ onSkinToneChange: config.onSkinToneChange || emptyFunc
16897
16898
  });
16898
16899
  React__default.useEffect(function () {
16899
16900
  MutableConfigRef.current.onEmojiClick = config.onEmojiClick || emptyFunc;
16900
16901
  MutableConfigRef.current.onReactionClick = config.onReactionClick || config.onEmojiClick;
16901
16902
  }, [config.onEmojiClick, config.onReactionClick]);
16903
+ React__default.useEffect(function () {
16904
+ MutableConfigRef.current.onSkinToneChange = config.onSkinToneChange || emptyFunc;
16905
+ }, [config.onSkinToneChange]);
16902
16906
  return MutableConfigRef;
16903
16907
  }
16904
16908
  function emptyFunc() {}
@@ -16964,6 +16968,11 @@ function useOnEmojiClickConfig(mouseEventSource) {
16964
16968
  var handler = (_ref = mouseEventSource === MOUSE_EVENT_SOURCE.REACTIONS ? current.onReactionClick : current.onEmojiClick) != null ? _ref : current.onEmojiClick;
16965
16969
  return handler || function () {};
16966
16970
  }
16971
+ function useOnSkinToneChangeConfig() {
16972
+ var _useMutableConfig2 = useMutableConfig(),
16973
+ current = _useMutableConfig2.current;
16974
+ return current.onSkinToneChange || function () {};
16975
+ }
16967
16976
  function usePreviewConfig() {
16968
16977
  var _usePickerConfig10 = usePickerConfig(),
16969
16978
  previewConfig = _usePickerConfig10.previewConfig;
@@ -19787,6 +19796,7 @@ function SkinTonePicker(_ref) {
19787
19796
  var _useActiveSkinToneSta = useActiveSkinToneState(),
19788
19797
  activeSkinTone = _useActiveSkinToneSta[0],
19789
19798
  setActiveSkinTone = _useActiveSkinToneSta[1];
19799
+ var onSkinToneChange = useOnSkinToneChangeConfig();
19790
19800
  var closeAllOpenToggles = useCloseAllOpenToggles();
19791
19801
  var focusSearchInput = useFocusSearchInput();
19792
19802
  if (isDisabled) {
@@ -19819,6 +19829,7 @@ function SkinTonePicker(_ref) {
19819
19829
  onClick: function onClick() {
19820
19830
  if (isOpen) {
19821
19831
  setActiveSkinTone(skinToneVariation);
19832
+ onSkinToneChange(skinToneVariation);
19822
19833
  focusSearchInput();
19823
19834
  } else {
19824
19835
  setIsOpen(true);
@@ -20513,7 +20524,8 @@ function ExportedEmoji(_ref) {
20513
20524
  function EmojiPicker$1(props) {
20514
20525
  var MutableConfigRef = useDefineMutableConfig({
20515
20526
  onEmojiClick: props.onEmojiClick,
20516
- onReactionClick: props.onReactionClick
20527
+ onReactionClick: props.onReactionClick,
20528
+ onSkinToneChange: props.onSkinToneChange
20517
20529
  });
20518
20530
  return React.createElement(ErrorBoundary, null, React.createElement(MutableConfigContext.Provider, {
20519
20531
  value: MutableConfigRef