emoji-picker-react 4.7.18 → 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 +4 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/config/mutableConfig.d.ts +2 -1
- package/dist/config/useConfig.d.ts +2 -0
- package/dist/emoji-picker-react.cjs.development.js +79 -47
- 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 +79 -47
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/EmojiPickerReact.tsx +23 -9
- package/src/components/Reactions/Reactions.tsx +8 -4
- package/src/components/context/PickerConfigContext.tsx +2 -1
- package/src/components/header/SkinTonePicker/SkinTonePicker.tsx +3 -1
- package/src/config/config.ts +5 -1
- package/src/config/mutableConfig.ts +8 -2
- package/src/config/useConfig.ts +12 -0
- package/src/index.tsx +2 -1
package/README.md
CHANGED
|
@@ -88,6 +88,8 @@ The following props are accepted by them picker:
|
|
|
88
88
|
| reactionsDefaultOpen | `boolean` | `false` | Controls whether the reactions picker is on the initial mount instead of the main picker component. |
|
|
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
|
+
| 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. |
|
|
91
93
|
|
|
92
94
|
## Full details
|
|
93
95
|
|
|
@@ -139,6 +141,8 @@ The skin tones typescript enum can be imported directly from the package:
|
|
|
139
141
|
import { SkinTones } from 'emoji-picker-react';
|
|
140
142
|
```
|
|
141
143
|
|
|
144
|
+
- `onSkinToneChange`: `(skinTone: SkinTones) => void` - Callback function when a skin tone is changed.
|
|
145
|
+
|
|
142
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.
|
|
143
147
|
|
|
144
148
|
- `skinTonesDisabled`: `boolean` - Whether to disable the skin tone selection. Defaults to `false`.
|
package/dist/config/config.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare type PickerConfigInternal = {
|
|
|
35
35
|
reactionsDefaultOpen: boolean;
|
|
36
36
|
reactions: string[];
|
|
37
37
|
open: boolean;
|
|
38
|
+
allowExpandReactions: boolean;
|
|
38
39
|
};
|
|
39
40
|
export declare type PreviewConfig = {
|
|
40
41
|
defaultEmoji: string;
|
|
@@ -45,8 +46,10 @@ declare type ConfigExternal = {
|
|
|
45
46
|
previewConfig: Partial<PreviewConfig>;
|
|
46
47
|
onEmojiClick: MouseDownEvent;
|
|
47
48
|
onReactionClick: MouseDownEvent;
|
|
49
|
+
onSkinToneChange: OnSkinToneChange;
|
|
48
50
|
} & Omit<PickerConfigInternal, 'previewConfig' | 'unicodeToHide'>;
|
|
49
51
|
export declare type PickerConfig = Partial<ConfigExternal>;
|
|
50
52
|
export declare type PickerDimensions = string | number;
|
|
51
53
|
export declare type MouseDownEvent = (emoji: EmojiClickData, event: MouseEvent) => void;
|
|
54
|
+
export declare type OnSkinToneChange = (emoji: SkinTones) => void;
|
|
52
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>;
|
|
@@ -9,6 +9,7 @@ export declare enum MOUSE_EVENT_SOURCE {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function useSearchPlaceHolderConfig(): string;
|
|
11
11
|
export declare function useDefaultSkinToneConfig(): SkinTones;
|
|
12
|
+
export declare function useAllowExpandReactions(): boolean;
|
|
12
13
|
export declare function useSkinTonesDisabledConfig(): boolean;
|
|
13
14
|
export declare function useEmojiStyleConfig(): EmojiStyle;
|
|
14
15
|
export declare function useAutoFocusSearchConfig(): boolean;
|
|
@@ -16,6 +17,7 @@ export declare function useCategoriesConfig(): CategoriesConfig;
|
|
|
16
17
|
export declare function useCustomEmojisConfig(): CustomEmoji[];
|
|
17
18
|
export declare function useOpenConfig(): boolean;
|
|
18
19
|
export declare function useOnEmojiClickConfig(mouseEventSource: MOUSE_EVENT_SOURCE): (emoji: EmojiClickData, event: MouseEvent) => void;
|
|
20
|
+
export declare function useOnSkinToneChangeConfig(): (skinTone: SkinTones) => void;
|
|
19
21
|
export declare function usePreviewConfig(): PreviewConfig;
|
|
20
22
|
export declare function useThemeConfig(): Theme;
|
|
21
23
|
export declare function useSuggestedEmojisModeConfig(): SuggestionMode;
|
|
@@ -16844,7 +16844,8 @@ function basePickerConfig() {
|
|
|
16844
16844
|
width: 350,
|
|
16845
16845
|
reactionsDefaultOpen: false,
|
|
16846
16846
|
reactions: DEFAULT_REACTIONS,
|
|
16847
|
-
open: true
|
|
16847
|
+
open: true,
|
|
16848
|
+
allowExpandReactions: true
|
|
16848
16849
|
};
|
|
16849
16850
|
}
|
|
16850
16851
|
var basePreviewConfig = {
|
|
@@ -16877,7 +16878,7 @@ function useSetConfig(config) {
|
|
|
16877
16878
|
setMergedConfig(mergeConfig(config));
|
|
16878
16879
|
// not gonna...
|
|
16879
16880
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16880
|
-
}, [(_config$customEmojis = config.customEmojis) == null ? void 0 : _config$customEmojis.length, config.open, config.emojiVersion, config.reactionsDefaultOpen, config.searchPlaceHolder, config.searchPlaceholder, config.defaultSkinTone, config.skinTonesDisabled, config.autoFocusSearch, config.emojiStyle, config.theme, config.suggestedEmojisMode, config.lazyLoadEmojis, config.className, config.height, config.width, config.searchDisabled, config.skinTonePickerLocation]);
|
|
16881
|
+
}, [(_config$customEmojis = config.customEmojis) == null ? void 0 : _config$customEmojis.length, config.open, config.emojiVersion, config.reactionsDefaultOpen, config.searchPlaceHolder, config.searchPlaceholder, config.defaultSkinTone, config.skinTonesDisabled, config.autoFocusSearch, config.emojiStyle, config.theme, config.suggestedEmojisMode, config.lazyLoadEmojis, config.className, config.height, config.width, config.searchDisabled, config.skinTonePickerLocation, config.allowExpandReactions]);
|
|
16881
16882
|
return mergedConfig;
|
|
16882
16883
|
}
|
|
16883
16884
|
function usePickerConfig() {
|
|
@@ -16892,12 +16893,16 @@ function useMutableConfig() {
|
|
|
16892
16893
|
function useDefineMutableConfig(config) {
|
|
16893
16894
|
var MutableConfigRef = React__default.useRef({
|
|
16894
16895
|
onEmojiClick: config.onEmojiClick || emptyFunc,
|
|
16895
|
-
onReactionClick: config.onReactionClick || config.onEmojiClick
|
|
16896
|
+
onReactionClick: config.onReactionClick || config.onEmojiClick,
|
|
16897
|
+
onSkinToneChange: config.onSkinToneChange || emptyFunc
|
|
16896
16898
|
});
|
|
16897
16899
|
React__default.useEffect(function () {
|
|
16898
16900
|
MutableConfigRef.current.onEmojiClick = config.onEmojiClick || emptyFunc;
|
|
16899
16901
|
MutableConfigRef.current.onReactionClick = config.onReactionClick || config.onEmojiClick;
|
|
16900
16902
|
}, [config.onEmojiClick, config.onReactionClick]);
|
|
16903
|
+
React__default.useEffect(function () {
|
|
16904
|
+
MutableConfigRef.current.onSkinToneChange = config.onSkinToneChange || emptyFunc;
|
|
16905
|
+
}, [config.onSkinToneChange]);
|
|
16901
16906
|
return MutableConfigRef;
|
|
16902
16907
|
}
|
|
16903
16908
|
function emptyFunc() {}
|
|
@@ -16921,34 +16926,39 @@ function useDefaultSkinToneConfig() {
|
|
|
16921
16926
|
defaultSkinTone = _usePickerConfig2.defaultSkinTone;
|
|
16922
16927
|
return defaultSkinTone;
|
|
16923
16928
|
}
|
|
16924
|
-
function
|
|
16929
|
+
function useAllowExpandReactions() {
|
|
16925
16930
|
var _usePickerConfig3 = usePickerConfig(),
|
|
16926
|
-
|
|
16931
|
+
allowExpandReactions = _usePickerConfig3.allowExpandReactions;
|
|
16932
|
+
return allowExpandReactions;
|
|
16933
|
+
}
|
|
16934
|
+
function useSkinTonesDisabledConfig() {
|
|
16935
|
+
var _usePickerConfig4 = usePickerConfig(),
|
|
16936
|
+
skinTonesDisabled = _usePickerConfig4.skinTonesDisabled;
|
|
16927
16937
|
return skinTonesDisabled;
|
|
16928
16938
|
}
|
|
16929
16939
|
function useEmojiStyleConfig() {
|
|
16930
|
-
var
|
|
16931
|
-
emojiStyle =
|
|
16940
|
+
var _usePickerConfig5 = usePickerConfig(),
|
|
16941
|
+
emojiStyle = _usePickerConfig5.emojiStyle;
|
|
16932
16942
|
return emojiStyle;
|
|
16933
16943
|
}
|
|
16934
16944
|
function useAutoFocusSearchConfig() {
|
|
16935
|
-
var
|
|
16936
|
-
autoFocusSearch =
|
|
16945
|
+
var _usePickerConfig6 = usePickerConfig(),
|
|
16946
|
+
autoFocusSearch = _usePickerConfig6.autoFocusSearch;
|
|
16937
16947
|
return autoFocusSearch;
|
|
16938
16948
|
}
|
|
16939
16949
|
function useCategoriesConfig() {
|
|
16940
|
-
var
|
|
16941
|
-
categories =
|
|
16950
|
+
var _usePickerConfig7 = usePickerConfig(),
|
|
16951
|
+
categories = _usePickerConfig7.categories;
|
|
16942
16952
|
return categories;
|
|
16943
16953
|
}
|
|
16944
16954
|
function useCustomEmojisConfig() {
|
|
16945
|
-
var
|
|
16946
|
-
customEmojis =
|
|
16955
|
+
var _usePickerConfig8 = usePickerConfig(),
|
|
16956
|
+
customEmojis = _usePickerConfig8.customEmojis;
|
|
16947
16957
|
return customEmojis;
|
|
16948
16958
|
}
|
|
16949
16959
|
function useOpenConfig() {
|
|
16950
|
-
var
|
|
16951
|
-
open =
|
|
16960
|
+
var _usePickerConfig9 = usePickerConfig(),
|
|
16961
|
+
open = _usePickerConfig9.open;
|
|
16952
16962
|
return open;
|
|
16953
16963
|
}
|
|
16954
16964
|
function useOnEmojiClickConfig(mouseEventSource) {
|
|
@@ -16958,74 +16968,79 @@ function useOnEmojiClickConfig(mouseEventSource) {
|
|
|
16958
16968
|
var handler = (_ref = mouseEventSource === MOUSE_EVENT_SOURCE.REACTIONS ? current.onReactionClick : current.onEmojiClick) != null ? _ref : current.onEmojiClick;
|
|
16959
16969
|
return handler || function () {};
|
|
16960
16970
|
}
|
|
16971
|
+
function useOnSkinToneChangeConfig() {
|
|
16972
|
+
var _useMutableConfig2 = useMutableConfig(),
|
|
16973
|
+
current = _useMutableConfig2.current;
|
|
16974
|
+
return current.onSkinToneChange || function () {};
|
|
16975
|
+
}
|
|
16961
16976
|
function usePreviewConfig() {
|
|
16962
|
-
var
|
|
16963
|
-
previewConfig =
|
|
16977
|
+
var _usePickerConfig10 = usePickerConfig(),
|
|
16978
|
+
previewConfig = _usePickerConfig10.previewConfig;
|
|
16964
16979
|
return previewConfig;
|
|
16965
16980
|
}
|
|
16966
16981
|
function useThemeConfig() {
|
|
16967
|
-
var
|
|
16968
|
-
theme =
|
|
16982
|
+
var _usePickerConfig11 = usePickerConfig(),
|
|
16983
|
+
theme = _usePickerConfig11.theme;
|
|
16969
16984
|
return theme;
|
|
16970
16985
|
}
|
|
16971
16986
|
function useSuggestedEmojisModeConfig() {
|
|
16972
|
-
var
|
|
16973
|
-
suggestedEmojisMode =
|
|
16987
|
+
var _usePickerConfig12 = usePickerConfig(),
|
|
16988
|
+
suggestedEmojisMode = _usePickerConfig12.suggestedEmojisMode;
|
|
16974
16989
|
return suggestedEmojisMode;
|
|
16975
16990
|
}
|
|
16976
16991
|
function useLazyLoadEmojisConfig() {
|
|
16977
|
-
var
|
|
16978
|
-
lazyLoadEmojis =
|
|
16992
|
+
var _usePickerConfig13 = usePickerConfig(),
|
|
16993
|
+
lazyLoadEmojis = _usePickerConfig13.lazyLoadEmojis;
|
|
16979
16994
|
return lazyLoadEmojis;
|
|
16980
16995
|
}
|
|
16981
16996
|
function useClassNameConfig() {
|
|
16982
|
-
var
|
|
16983
|
-
className =
|
|
16997
|
+
var _usePickerConfig14 = usePickerConfig(),
|
|
16998
|
+
className = _usePickerConfig14.className;
|
|
16984
16999
|
return className;
|
|
16985
17000
|
}
|
|
16986
17001
|
function useStyleConfig() {
|
|
16987
|
-
var
|
|
16988
|
-
height =
|
|
16989
|
-
width =
|
|
16990
|
-
style =
|
|
17002
|
+
var _usePickerConfig15 = usePickerConfig(),
|
|
17003
|
+
height = _usePickerConfig15.height,
|
|
17004
|
+
width = _usePickerConfig15.width,
|
|
17005
|
+
style = _usePickerConfig15.style;
|
|
16991
17006
|
return _extends({
|
|
16992
17007
|
height: getDimension(height),
|
|
16993
17008
|
width: getDimension(width)
|
|
16994
17009
|
}, style);
|
|
16995
17010
|
}
|
|
16996
17011
|
function useReactionsOpenConfig() {
|
|
16997
|
-
var
|
|
16998
|
-
reactionsDefaultOpen =
|
|
17012
|
+
var _usePickerConfig16 = usePickerConfig(),
|
|
17013
|
+
reactionsDefaultOpen = _usePickerConfig16.reactionsDefaultOpen;
|
|
16999
17014
|
return reactionsDefaultOpen;
|
|
17000
17015
|
}
|
|
17001
17016
|
function useEmojiVersionConfig() {
|
|
17002
|
-
var
|
|
17003
|
-
emojiVersion =
|
|
17017
|
+
var _usePickerConfig17 = usePickerConfig(),
|
|
17018
|
+
emojiVersion = _usePickerConfig17.emojiVersion;
|
|
17004
17019
|
return emojiVersion;
|
|
17005
17020
|
}
|
|
17006
17021
|
function useSearchDisabledConfig() {
|
|
17007
|
-
var
|
|
17008
|
-
searchDisabled =
|
|
17022
|
+
var _usePickerConfig18 = usePickerConfig(),
|
|
17023
|
+
searchDisabled = _usePickerConfig18.searchDisabled;
|
|
17009
17024
|
return searchDisabled;
|
|
17010
17025
|
}
|
|
17011
17026
|
function useSkinTonePickerLocationConfig() {
|
|
17012
|
-
var
|
|
17013
|
-
skinTonePickerLocation =
|
|
17027
|
+
var _usePickerConfig19 = usePickerConfig(),
|
|
17028
|
+
skinTonePickerLocation = _usePickerConfig19.skinTonePickerLocation;
|
|
17014
17029
|
return skinTonePickerLocation;
|
|
17015
17030
|
}
|
|
17016
17031
|
function useUnicodeToHide() {
|
|
17017
|
-
var
|
|
17018
|
-
unicodeToHide =
|
|
17032
|
+
var _usePickerConfig20 = usePickerConfig(),
|
|
17033
|
+
unicodeToHide = _usePickerConfig20.unicodeToHide;
|
|
17019
17034
|
return unicodeToHide;
|
|
17020
17035
|
}
|
|
17021
17036
|
function useReactionsConfig() {
|
|
17022
|
-
var
|
|
17023
|
-
reactions =
|
|
17037
|
+
var _usePickerConfig21 = usePickerConfig(),
|
|
17038
|
+
reactions = _usePickerConfig21.reactions;
|
|
17024
17039
|
return reactions;
|
|
17025
17040
|
}
|
|
17026
17041
|
function useGetEmojiUrlConfig() {
|
|
17027
|
-
var
|
|
17028
|
-
getEmojiUrl =
|
|
17042
|
+
var _usePickerConfig22 = usePickerConfig(),
|
|
17043
|
+
getEmojiUrl = _usePickerConfig22.getEmojiUrl;
|
|
17029
17044
|
return getEmojiUrl;
|
|
17030
17045
|
}
|
|
17031
17046
|
function getDimension(dimensionConfig) {
|
|
@@ -19090,6 +19105,7 @@ function Reactions() {
|
|
|
19090
19105
|
var reactions = useReactionsConfig();
|
|
19091
19106
|
useMouseDownHandlers(ReactionsRef, MOUSE_EVENT_SOURCE.REACTIONS);
|
|
19092
19107
|
var emojiStyle = useEmojiStyleConfig();
|
|
19108
|
+
var allowExpandReactions = useAllowExpandReactions();
|
|
19093
19109
|
if (!reactionsOpen) {
|
|
19094
19110
|
return null;
|
|
19095
19111
|
}
|
|
@@ -19107,7 +19123,7 @@ function Reactions() {
|
|
|
19107
19123
|
className: flairup.cx(styles$6.emojiButton),
|
|
19108
19124
|
noBackground: true
|
|
19109
19125
|
}));
|
|
19110
|
-
}), React.createElement("li", null, React.createElement(BtnPlus, null)));
|
|
19126
|
+
}), allowExpandReactions ? React.createElement("li", null, React.createElement(BtnPlus, null)) : null);
|
|
19111
19127
|
}
|
|
19112
19128
|
var styles$6 = /*#__PURE__*/stylesheet.create({
|
|
19113
19129
|
list: {
|
|
@@ -19780,6 +19796,7 @@ function SkinTonePicker(_ref) {
|
|
|
19780
19796
|
var _useActiveSkinToneSta = useActiveSkinToneState(),
|
|
19781
19797
|
activeSkinTone = _useActiveSkinToneSta[0],
|
|
19782
19798
|
setActiveSkinTone = _useActiveSkinToneSta[1];
|
|
19799
|
+
var onSkinToneChange = useOnSkinToneChangeConfig();
|
|
19783
19800
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
19784
19801
|
var focusSearchInput = useFocusSearchInput();
|
|
19785
19802
|
if (isDisabled) {
|
|
@@ -19812,6 +19829,7 @@ function SkinTonePicker(_ref) {
|
|
|
19812
19829
|
onClick: function onClick() {
|
|
19813
19830
|
if (isOpen) {
|
|
19814
19831
|
setActiveSkinTone(skinToneVariation);
|
|
19832
|
+
onSkinToneChange(skinToneVariation);
|
|
19815
19833
|
focusSearchInput();
|
|
19816
19834
|
} else {
|
|
19817
19835
|
setIsOpen(true);
|
|
@@ -20420,19 +20438,32 @@ function EmojiPicker(props) {
|
|
|
20420
20438
|
function ContentControl() {
|
|
20421
20439
|
var _useReactionsModeStat = useReactionsModeState(),
|
|
20422
20440
|
reactionsDefaultOpen = _useReactionsModeStat[0];
|
|
20441
|
+
var allowExpandReactions = useAllowExpandReactions();
|
|
20423
20442
|
var _React$useState = React.useState(!reactionsDefaultOpen),
|
|
20424
20443
|
renderAll = _React$useState[0],
|
|
20425
20444
|
setRenderAll = _React$useState[1];
|
|
20426
20445
|
var isOpen = useOpenConfig();
|
|
20427
20446
|
React.useEffect(function () {
|
|
20447
|
+
if (reactionsDefaultOpen && !allowExpandReactions) {
|
|
20448
|
+
return;
|
|
20449
|
+
}
|
|
20428
20450
|
if (!renderAll) {
|
|
20429
20451
|
setRenderAll(true);
|
|
20430
20452
|
}
|
|
20431
|
-
}, [renderAll]);
|
|
20453
|
+
}, [renderAll, allowExpandReactions, reactionsDefaultOpen]);
|
|
20432
20454
|
if (!isOpen) {
|
|
20433
20455
|
return null;
|
|
20434
20456
|
}
|
|
20435
|
-
return React.createElement(PickerMain, null, React.createElement(Reactions, null),
|
|
20457
|
+
return React.createElement(PickerMain, null, React.createElement(Reactions, null), React.createElement(ExpandedPickerContent, {
|
|
20458
|
+
renderAll: renderAll
|
|
20459
|
+
}));
|
|
20460
|
+
}
|
|
20461
|
+
function ExpandedPickerContent(_ref) {
|
|
20462
|
+
var renderAll = _ref.renderAll;
|
|
20463
|
+
if (!renderAll) {
|
|
20464
|
+
return null;
|
|
20465
|
+
}
|
|
20466
|
+
return React.createElement(React.Fragment, null, React.createElement(Header, null), React.createElement(Body, null), React.createElement(Preview, null));
|
|
20436
20467
|
}
|
|
20437
20468
|
// eslint-disable-next-line complexity
|
|
20438
20469
|
var EmojiPickerReact = /*#__PURE__*/React.memo(EmojiPicker, compareConfig);
|
|
@@ -20493,7 +20524,8 @@ function ExportedEmoji(_ref) {
|
|
|
20493
20524
|
function EmojiPicker$1(props) {
|
|
20494
20525
|
var MutableConfigRef = useDefineMutableConfig({
|
|
20495
20526
|
onEmojiClick: props.onEmojiClick,
|
|
20496
|
-
onReactionClick: props.onReactionClick
|
|
20527
|
+
onReactionClick: props.onReactionClick,
|
|
20528
|
+
onSkinToneChange: props.onSkinToneChange
|
|
20497
20529
|
});
|
|
20498
20530
|
return React.createElement(ErrorBoundary, null, React.createElement(MutableConfigContext.Provider, {
|
|
20499
20531
|
value: MutableConfigRef
|