emoji-picker-react 4.5.0 → 4.5.1

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
@@ -36,6 +36,7 @@ function App() {
36
36
  ## Features
37
37
 
38
38
  - Custom click handler
39
+ - Custom Emojis Support
39
40
  - Dark mode
40
41
  - Customizable styles via css variables
41
42
  - Default skin tone selection
@@ -78,9 +79,11 @@ The following props are accepted by them picker:
78
79
  activeSkinTone: SkinTones;
79
80
  unified: string;
80
81
  unifiedWithoutSkinTone: string;
81
- emoji: string;
82
+ emoji: string; // the emoji character, for example: '😀'. Emoji ID in custom emojis
83
+ isCustom: boolean; // whether the emoji is a custom emoji or not
82
84
  names: string[];
83
- getImageUrl: (emojiStyle: EmojiStyle) => string;
85
+ imageUrl: string; // the url of the emoji image with the current emoji style applied
86
+ getImageUrl: (emojiStyle: EmojiStyle) => string; // a function that receives an emoji style and returns the url of the emoji image with the provided style applied
84
87
  }
85
88
  ```
86
89
 
@@ -199,20 +202,70 @@ imgUrl: URL for the emoji image
199
202
  <Picker
200
203
  customEmojis={[
201
204
  {
202
- names: ['Film'],
203
- imgUrl: 'https://cdn.jsdelivr.net/npm/eva-icons/fill/svg/film.svg',
204
- id: 'film'
205
+ names: ['Alice', 'alice in wonderland'],
206
+ imgUrl:
207
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/alice.png',
208
+ id: 'alice'
209
+ },
210
+ {
211
+ names: ['Dog'],
212
+ imgUrl:
213
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/dog.png',
214
+ id: 'dog'
215
+ },
216
+ {
217
+ names: ['Hat'],
218
+ imgUrl:
219
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/hat.png',
220
+ id: 'hat'
221
+ },
222
+ {
223
+ names: ['Kid'],
224
+ imgUrl:
225
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/kid.png',
226
+ id: 'kid'
227
+ },
228
+ {
229
+ names: ['Mic'],
230
+ imgUrl:
231
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/mic.png',
232
+ id: 'mic'
205
233
  },
206
234
  {
207
- names: ['Bar Chart'],
208
- imgUrl: 'https://cdn.jsdelivr.net/npm/eva-icons/fill/svg/bar-chart.svg',
209
- id: 'bar_chart'
235
+ names: ['Moab', 'desert'],
236
+ imgUrl:
237
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/moab.png',
238
+ id: 'moab'
239
+ },
240
+ {
241
+ names: ['Potter', 'harry', 'harry potter'],
242
+ imgUrl:
243
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/potter.png',
244
+ id: 'potter'
245
+ },
246
+ {
247
+ names: ['Shroom', 'mushroom'],
248
+ imgUrl:
249
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/shroom.png',
250
+ id: 'shroom'
251
+ },
252
+ {
253
+ names: ['Smily'],
254
+ imgUrl:
255
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/smily.png',
256
+ id: 'smily'
257
+ },
258
+ {
259
+ names: ['Tabby', 'cat'],
260
+ imgUrl:
261
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/tabby.png',
262
+ id: 'tabby'
210
263
  },
211
264
  {
212
- names: ['champagne', 'bottle', 'sparkling wine'],
265
+ names: ['Vest'],
213
266
  imgUrl:
214
- 'https://cdn.jsdelivr.net/gh/hfg-gmuend/openmoji/src/food-drink/drink/1F37E.svg',
215
- id: 'champagne'
267
+ 'https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/vest.png',
268
+ id: 'vest'
216
269
  }
217
270
  ]}
218
271
  />
@@ -265,7 +318,8 @@ The picker exports an `Emoji` component. The emoji component is the same used wi
265
318
  | `size` | number | 32 | The size of the emoji. |
266
319
  | `emojiStyle` | `EmojiStyle` | `EmojiStyle.APPLE` | The emoji style to use. Can be either `apple`, `google`, `facebook`, `twitter` or `native`. |
267
320
  | `lazyLoad` | boolean | `false` | Whether to lazy load the emoji. image |
268
- | `getEmojiUrl` | Function | - | Allows to customize the emoji url and provide your own image host. |
321
+ | `emojiUrl` | string | - | The url of the emoji image to render. Useful for custom emojis. |
322
+ | `getEmojiUrl` | Function | - | Allows to customize the emoji url and provide your own image host for dynamic resolution. |
269
323
 
270
324
  ```js
271
325
  import { Emoji, EmojiStyle } from 'emoji-picker-react';
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { EmojiStyle } from '../../types/exposedTypes';
3
3
  import { GetEmojiUrl } from './BaseEmojiProps';
4
- export declare function ExportedEmoji({ unified, size, emojiStyle, lazyLoad, getEmojiUrl }: {
4
+ export declare function ExportedEmoji({ unified, size, emojiStyle, lazyLoad, getEmojiUrl, emojiUrl }: {
5
5
  unified: string;
6
6
  emojiStyle?: EmojiStyle;
7
7
  size?: number;
8
8
  lazyLoad?: boolean;
9
9
  getEmojiUrl?: GetEmojiUrl;
10
+ emojiUrl?: string;
10
11
  }): JSX.Element | null;
@@ -17703,6 +17703,13 @@ function setSuggested(emoji, skinTone) {
17703
17703
  }
17704
17704
  }
17705
17705
 
17706
+ function isCustomCategory(category) {
17707
+ return category.category === exports.Categories.CUSTOM;
17708
+ }
17709
+ function isCustomEmoji(emoji) {
17710
+ return emoji.imgUrl !== undefined;
17711
+ }
17712
+
17706
17713
  function useCloseAllOpenToggles() {
17707
17714
  var _useEmojiVariationPic = useEmojiVariationPickerState(),
17708
17715
  variationPicker = _useEmojiVariationPic[0],
@@ -17771,6 +17778,7 @@ function useMouseDownHandlers(BodyRef) {
17771
17778
  updateSuggested = _useUpdateSuggested[1];
17772
17779
 
17773
17780
  var getEmojiUrl = useGetEmojiUrlConfig();
17781
+ var activeEmojiStyle = useEmojiStyleConfig();
17774
17782
  var onClick = React.useCallback(function onClick(event) {
17775
17783
  if (disallowClickRef.current) {
17776
17784
  return;
@@ -17789,8 +17797,8 @@ function useMouseDownHandlers(BodyRef) {
17789
17797
  var skinToneToUse = activeVariationFromUnified(unified) || activeSkinTone;
17790
17798
  updateSuggested();
17791
17799
  setSuggested(emoji, skinToneToUse);
17792
- onEmojiClick(emojiClickOutput(emoji, skinToneToUse, getEmojiUrl), event);
17793
- }, [activeSkinTone, closeAllOpenToggles, disallowClickRef, onEmojiClick, updateSuggested, getEmojiUrl]);
17800
+ onEmojiClick(emojiClickOutput(emoji, skinToneToUse, activeEmojiStyle, getEmojiUrl), event);
17801
+ }, [activeSkinTone, closeAllOpenToggles, disallowClickRef, onEmojiClick, updateSuggested, getEmojiUrl, activeEmojiStyle]);
17794
17802
  var onMouseDown = React.useCallback(function onMouseDown(event) {
17795
17803
  var _window;
17796
17804
 
@@ -17861,15 +17869,40 @@ function emojiFromEvent(event) {
17861
17869
  return emojiFromElement(target);
17862
17870
  }
17863
17871
 
17864
- function emojiClickOutput(emoji, activeSkinTone, getEmojiUrl) {
17872
+ function emojiClickOutput(emoji, activeSkinTone, activeEmojiStyle, getEmojiUrl) {
17873
+ var names = emojiNames(emoji);
17874
+
17875
+ if (isCustomEmoji(emoji)) {
17876
+ var _unified = emojiUnified(emoji);
17877
+
17878
+ return {
17879
+ activeSkinTone: activeSkinTone,
17880
+ emoji: _unified,
17881
+ getImageUrl: function getImageUrl() {
17882
+ return emoji.imgUrl;
17883
+ },
17884
+ imageUrl: emoji.imgUrl,
17885
+ isCustom: true,
17886
+ names: names,
17887
+ unified: _unified,
17888
+ unifiedWithoutSkinTone: _unified
17889
+ };
17890
+ }
17891
+
17865
17892
  var unified = emojiUnified(emoji, activeSkinTone);
17866
17893
  return {
17867
17894
  activeSkinTone: activeSkinTone,
17868
17895
  emoji: parseNativeEmoji(unified),
17869
17896
  getImageUrl: function getImageUrl(emojiStyle) {
17897
+ if (emojiStyle === void 0) {
17898
+ emojiStyle = activeEmojiStyle != null ? activeEmojiStyle : exports.EmojiStyle.APPLE;
17899
+ }
17900
+
17870
17901
  return getEmojiUrl(unified, emojiStyle);
17871
17902
  },
17872
- names: emojiNames(emoji),
17903
+ imageUrl: getEmojiUrl(unified, activeEmojiStyle != null ? activeEmojiStyle : exports.EmojiStyle.APPLE),
17904
+ isCustom: false,
17905
+ names: names,
17873
17906
  unified: unified,
17874
17907
  unifiedWithoutSkinTone: emojiUnified(emoji)
17875
17908
  };
@@ -18181,13 +18214,6 @@ function ClickableEmojiButton(_ref) {
18181
18214
  }, children);
18182
18215
  }
18183
18216
 
18184
- function isCustomCategory(category) {
18185
- return category.category === exports.Categories.CUSTOM;
18186
- }
18187
- function isCustomEmoji(emoji) {
18188
- return emoji.imgUrl !== undefined;
18189
- }
18190
-
18191
18217
  function EmojiImg(_ref) {
18192
18218
  var emojiName = _ref.emojiName,
18193
18219
  style = _ref.style,
@@ -18243,7 +18269,7 @@ function ViewOnlyEmoji(_ref) {
18243
18269
  return React.createElement(EmojiImg, {
18244
18270
  style: style,
18245
18271
  emojiName: unified,
18246
- emojiStyle: emojiStyle,
18272
+ emojiStyle: exports.EmojiStyle.NATIVE,
18247
18273
  lazyLoad: lazyLoad,
18248
18274
  imgUrl: emojiToRender.imgUrl,
18249
18275
  onError: onError
@@ -19745,9 +19771,10 @@ function ExportedEmoji(_ref) {
19745
19771
  emojiStyle = _ref$emojiStyle === void 0 ? exports.EmojiStyle.APPLE : _ref$emojiStyle,
19746
19772
  _ref$lazyLoad = _ref.lazyLoad,
19747
19773
  lazyLoad = _ref$lazyLoad === void 0 ? false : _ref$lazyLoad,
19748
- getEmojiUrl = _ref.getEmojiUrl;
19774
+ getEmojiUrl = _ref.getEmojiUrl,
19775
+ emojiUrl = _ref.emojiUrl;
19749
19776
 
19750
- if (!unified) {
19777
+ if (!unified && !emojiUrl && !getEmojiUrl) {
19751
19778
  return null;
19752
19779
  }
19753
19780
 
@@ -19756,7 +19783,9 @@ function ExportedEmoji(_ref) {
19756
19783
  size: size,
19757
19784
  emojiStyle: emojiStyle,
19758
19785
  lazyLoad: lazyLoad,
19759
- getEmojiUrl: getEmojiUrl
19786
+ getEmojiUrl: emojiUrl ? function () {
19787
+ return emojiUrl;
19788
+ } : getEmojiUrl
19760
19789
  });
19761
19790
  }
19762
19791