emoji-picker-react 4.17.5 → 4.19.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.
Files changed (101) hide show
  1. package/README.md +51 -6
  2. package/dist/Stylesheet/stylesheet.d.ts +3 -1
  3. package/dist/components/Layout/Flex.d.ts +1 -1
  4. package/dist/components/body/EmojiCategory.d.ts +1 -1
  5. package/dist/components/context/ElementRefContext.d.ts +1 -1
  6. package/dist/components/emoji/ClickableEmojiButton.d.ts +1 -1
  7. package/dist/components/emoji/Emoji.d.ts +1 -1
  8. package/dist/components/emoji/EmojiImg.d.ts +1 -1
  9. package/dist/components/emoji/ExportedEmoji.d.ts +1 -1
  10. package/dist/components/emoji/NativeEmoji.d.ts +1 -1
  11. package/dist/components/emoji/ViewOnlyEmoji.d.ts +1 -1
  12. package/dist/components/header/SkinTonePicker/BtnSkinToneVariation.d.ts +1 -1
  13. package/dist/components/header/SkinTonePicker/SkinTonePicker.d.ts +1 -1
  14. package/dist/components/navigation/CategoryButton.d.ts +3 -2
  15. package/dist/config/config.d.ts +3 -1
  16. package/dist/config/useConfig.d.ts +1 -0
  17. package/dist/data/groups.js +1 -1
  18. package/dist/data/groups.ts +1 -1
  19. package/dist/data/skinToneVariations.js +2 -2
  20. package/dist/data/skinToneVariations.ts +10 -12
  21. package/dist/emoji-picker-react.cjs.development.js +114 -91
  22. package/dist/emoji-picker-react.cjs.development.js.map +1 -1
  23. package/dist/emoji-picker-react.cjs.production.min.js +1 -1
  24. package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
  25. package/dist/emoji-picker-react.esm.js +114 -91
  26. package/dist/emoji-picker-react.esm.js.map +1 -1
  27. package/dist/hooks/useActiveCategoryScrollDetection.d.ts +1 -1
  28. package/dist/hooks/useEmojiVirtualization.d.ts +1 -1
  29. package/dist/index.d.ts +2 -1
  30. package/dist/typeRefinements/typeRefinements.d.ts +1 -1
  31. package/dist/types/exposedTypes.d.ts +3 -0
  32. package/dist/virtualization/virtualizationHelpers.d.ts +1 -1
  33. package/package.json +1 -1
  34. package/src/DomUtils/classNames.ts +2 -2
  35. package/src/DomUtils/detectEmojyPartiallyBelowFold.ts +1 -1
  36. package/src/DomUtils/elementPositionInRow.ts +3 -3
  37. package/src/DomUtils/keyboardNavigation.ts +2 -2
  38. package/src/DomUtils/scrollTo.ts +2 -2
  39. package/src/DomUtils/selectors.ts +18 -17
  40. package/src/EmojiPickerReact.tsx +1 -1
  41. package/src/Stylesheet/stylesheet.tsx +28 -23
  42. package/src/components/Layout/Flex.tsx +6 -6
  43. package/src/components/Layout/Space.tsx +0 -1
  44. package/src/components/Reactions/BtnPlus.tsx +8 -8
  45. package/src/components/Reactions/DEFAULT_REACTIONS.ts +1 -1
  46. package/src/components/atoms/Button.tsx +6 -7
  47. package/src/components/body/Body.tsx +3 -3
  48. package/src/components/body/EmojiCategory.tsx +8 -8
  49. package/src/components/body/EmojiList.tsx +9 -9
  50. package/src/components/body/EmojiVariationPicker.tsx +22 -23
  51. package/src/components/body/MeasureEmoji.tsx +10 -11
  52. package/src/components/context/ElementRefContext.tsx +5 -6
  53. package/src/components/context/PickerConfigContext.tsx +5 -6
  54. package/src/components/context/PickerContext.tsx +8 -8
  55. package/src/components/context/PickerDataContext.tsx +2 -3
  56. package/src/components/emoji/ClickableEmojiButton.tsx +15 -14
  57. package/src/components/emoji/Emoji.tsx +1 -1
  58. package/src/components/emoji/EmojiImg.tsx +10 -5
  59. package/src/components/emoji/ExportedEmoji.tsx +1 -1
  60. package/src/components/emoji/NativeEmoji.tsx +4 -4
  61. package/src/components/emoji/ViewOnlyEmoji.tsx +2 -3
  62. package/src/components/emoji/emojiStyles.ts +3 -3
  63. package/src/components/footer/Preview.tsx +10 -10
  64. package/src/components/header/Search/BtnClearSearch.tsx +13 -13
  65. package/src/components/header/Search/IcnSearch.tsx +3 -3
  66. package/src/components/header/Search/Search.tsx +18 -18
  67. package/src/components/header/SkinTonePicker/BtnSkinToneVariation.tsx +15 -14
  68. package/src/components/header/SkinTonePicker/SkinTonePicker.tsx +15 -15
  69. package/src/components/main/PickerMain.tsx +16 -16
  70. package/src/components/navigation/CategoryButton.tsx +41 -26
  71. package/src/components/navigation/CategoryNavigation.tsx +14 -8
  72. package/src/config/config.ts +5 -0
  73. package/src/config/mutableConfig.ts +2 -2
  74. package/src/config/useConfig.ts +15 -10
  75. package/src/data/groups.ts +1 -1
  76. package/src/data/skinToneVariations.ts +10 -12
  77. package/src/dataUtils/DataTypes.ts +1 -1
  78. package/src/dataUtils/alphaNumericEmojiIndex.ts +1 -1
  79. package/src/dataUtils/parseNativeEmoji.ts +1 -1
  80. package/src/dataUtils/suggested.ts +3 -3
  81. package/src/hooks/preloadEmoji.ts +3 -3
  82. package/src/hooks/useActiveCategoryScrollDetection.ts +9 -7
  83. package/src/hooks/useCloseAllOpenToggles.ts +2 -2
  84. package/src/hooks/useDebouncedState.ts +2 -2
  85. package/src/hooks/useDisallowMouseMove.ts +1 -1
  86. package/src/hooks/useDisallowedEmojis.ts +2 -2
  87. package/src/hooks/useEmojiPreviewEvents.ts +8 -8
  88. package/src/hooks/useEmojiVirtualization.tsx +9 -9
  89. package/src/hooks/useFilter.ts +16 -16
  90. package/src/hooks/useFocus.ts +1 -1
  91. package/src/hooks/useHideEmojisByUniocode.ts +4 -4
  92. package/src/hooks/useInitialLoad.ts +1 -1
  93. package/src/hooks/useIsEmojiHidden.ts +1 -1
  94. package/src/hooks/useKeyboardNavigation.ts +18 -18
  95. package/src/hooks/useMouseDownHandlers.ts +18 -18
  96. package/src/hooks/useOnScroll.ts +1 -1
  97. package/src/hooks/useScrollCategoryIntoView.ts +2 -2
  98. package/src/index.tsx +5 -2
  99. package/src/typeRefinements/typeRefinements.ts +2 -2
  100. package/src/types/exposedTypes.ts +11 -6
  101. package/src/virtualization/virtualizationHelpers.ts +2 -2
package/README.md CHANGED
@@ -98,12 +98,13 @@ The following is a complete list of all props accepted by `EmojiPicker`.
98
98
 
99
99
  ### 🦄 Customization & Advanced
100
100
 
101
- | Prop | Type | Default | Description |
102
- | --------------- | ------------------------------------------------ | ----------------------- | --------------------------------------------------------------- |
103
- | `customEmojis` | `CustomEmoji[]` | `[]` | Array of custom image-based emojis to inject. |
104
- | `hiddenEmojis` | `string[]` | `[]` | Array of unified IDs (e.g., `'1f921'`) to hide from the picker. |
105
- | `previewConfig` | `PreviewConfig` | `{ showPreview: true }` | configuration for the bottom preview bar. |
106
- | `getEmojiUrl` | `(unified: string, style: EmojiStyle) => string` | - | Function to override the default CDN URL for emoji images. |
101
+ | Prop | Type | Default | Description |
102
+ | --------------- | ------------------------------------------------ | ----------------------- | ------------------------------------------------------------------------ |
103
+ | `customEmojis` | `CustomEmoji[]` | `[]` | Array of custom image-based emojis to inject. |
104
+ | `hiddenEmojis` | `string[]` | `[]` | Array of unified IDs (e.g., `'1f921'`) to hide from the picker. |
105
+ | `previewConfig` | `PreviewConfig` | `{ showPreview: true }` | Configuration for the bottom preview bar. |
106
+ | `getEmojiUrl` | `(unified: string, style: EmojiStyle) => string` | - | Function to override the default CDN URL for emoji images. |
107
+ | `categoryIcons` | `CategoryIcons` | `{}` | Map `Categories` enum values to custom React nodes for navigation icons. |
107
108
 
108
109
  ### ❤️ Reactions Picker Mode
109
110
 
@@ -152,6 +153,50 @@ Control the footer preview area using `previewConfig`:
152
153
  }
153
154
  ```
154
155
 
156
+ ### Custom Category Icons
157
+
158
+ You can customize the navigation icons using one of two methods.
159
+
160
+ **Method 1: The `categoryIcons` prop**
161
+
162
+ Map `Categories` enum values to valid React nodes:
163
+
164
+ ```tsx
165
+ import EmojiPicker, { Categories } from 'emoji-picker-react';
166
+
167
+ <EmojiPicker
168
+ categoryIcons={{
169
+ [Categories.SUGGESTED]: <img src="recent.png" alt="Recent" />,
170
+ [Categories.SMILEYS_PEOPLE]: <MyCustomFaceIcon />,
171
+ }}
172
+ />;
173
+ ```
174
+
175
+ **Method 2: The `categories` configuration array**
176
+
177
+ Define the icon directly within the category configuration object:
178
+
179
+ ```tsx
180
+ import EmojiPicker, { Categories } from 'emoji-picker-react';
181
+
182
+ <EmojiPicker
183
+ categories={[
184
+ {
185
+ category: Categories.SUGGESTED,
186
+ name: 'Recently Used',
187
+ icon: <img src="recent.png" alt="Recent" />,
188
+ },
189
+ {
190
+ category: Categories.SMILEYS_PEOPLE,
191
+ name: 'Smileys & People',
192
+ icon: <MyCustomFaceIcon />,
193
+ },
194
+ ]}
195
+ />;
196
+ ```
197
+
198
+ > **Note:** If both methods are used for the same category, the icon from the `categories` configuration takes precedence over the `categoryIcons` prop.
199
+
155
200
  ---
156
201
 
157
202
  ## 🌍 Internationalization (i18n)
@@ -9,7 +9,9 @@ export declare const stylesheet: {
9
9
  isApplied: () => boolean;
10
10
  };
11
11
  export declare const commonStyles: Record<never, Set<string>>;
12
- export declare const PickerStyleTag: React.NamedExoticComponent<object>;
12
+ export declare const PickerStyleTag: React.NamedExoticComponent<{
13
+ nonce?: string | undefined;
14
+ }>;
13
15
  export declare const commonInteractionStyles: Record<never, Set<string>>;
14
16
  export declare function darkMode(key: string, value: Styles): {
15
17
  '.epr-dark-theme': {
@@ -9,5 +9,5 @@ declare type Props = Readonly<{
9
9
  style?: React.CSSProperties;
10
10
  direction?: FlexDirection;
11
11
  }>;
12
- export default function Flex({ children, className, style, direction }: Props): JSX.Element;
12
+ export default function Flex({ children, className, style, direction, }: Props): JSX.Element;
13
13
  export {};
@@ -7,5 +7,5 @@ declare type Props = Readonly<{
7
7
  hiddenOnSearch?: boolean;
8
8
  height?: number;
9
9
  }>;
10
- export declare function EmojiCategory({ categoryConfig, children, hidden, hiddenOnSearch, height }: Props): JSX.Element;
10
+ export declare function EmojiCategory({ categoryConfig, children, hidden, hiddenOnSearch, height, }: Props): JSX.Element;
11
11
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { NullableElement } from '../../DomUtils/selectors';
3
- export declare function ElementRefContextProvider({ children }: {
3
+ export declare function ElementRefContextProvider({ children, }: {
4
4
  children: React.ReactNode;
5
5
  }): JSX.Element;
6
6
  export declare type ElementRef<E extends HTMLElement = HTMLElement> = React.MutableRefObject<E | null>;
@@ -11,5 +11,5 @@ declare type ClickableEmojiButtonProps = Readonly<{
11
11
  className?: string;
12
12
  style?: React.CSSProperties;
13
13
  }>;
14
- export declare function ClickableEmojiButton({ emojiNames, unified, hidden, hiddenOnSearch, showVariations, hasVariations, children, className, noBackground, style }: ClickableEmojiButtonProps): JSX.Element;
14
+ export declare function ClickableEmojiButton({ emojiNames, unified, hidden, hiddenOnSearch, showVariations, hasVariations, children, className, noBackground, style, }: ClickableEmojiButtonProps): JSX.Element;
15
15
  export {};
@@ -10,5 +10,5 @@ declare type ClickableEmojiProps = Readonly<BaseEmojiProps & {
10
10
  noBackground?: boolean;
11
11
  style?: React.CSSProperties;
12
12
  }>;
13
- export declare function ClickableEmoji({ emoji, unified, hidden, hiddenOnSearch, emojiStyle, showVariations, size, lazyLoad, getEmojiUrl, className, noBackground, style }: ClickableEmojiProps): JSX.Element;
13
+ export declare function ClickableEmoji({ emoji, unified, hidden, hiddenOnSearch, emojiStyle, showVariations, size, lazyLoad, getEmojiUrl, className, noBackground, style, }: ClickableEmojiProps): JSX.Element;
14
14
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { EmojiStyle } from '../../types/exposedTypes';
3
- export declare function EmojiImg({ emojiName, style, lazyLoad, imgUrl, onError, className }: {
3
+ export declare function EmojiImg({ emojiName, style, lazyLoad, imgUrl, onError, className, }: {
4
4
  emojiName: string;
5
5
  emojiStyle: EmojiStyle;
6
6
  style: React.CSSProperties;
@@ -1,7 +1,7 @@
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, emojiUrl }: {
4
+ export declare function ExportedEmoji({ unified, size, emojiStyle, lazyLoad, getEmojiUrl, emojiUrl, }: {
5
5
  unified: string;
6
6
  emojiStyle?: EmojiStyle;
7
7
  size?: number;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export declare function NativeEmoji({ unified, style, className }: {
2
+ export declare function NativeEmoji({ unified, style, className, }: {
3
3
  unified: string;
4
4
  style: React.CSSProperties;
5
5
  className?: string;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { BaseEmojiProps } from './BaseEmojiProps';
3
- export declare function ViewOnlyEmoji({ emoji, unified, emojiStyle, size, lazyLoad, getEmojiUrl, className }: BaseEmojiProps): JSX.Element | null;
3
+ export declare function ViewOnlyEmoji({ emoji, unified, emojiStyle, size, lazyLoad, getEmojiUrl, className, }: BaseEmojiProps): JSX.Element | null;
@@ -7,5 +7,5 @@ declare type Props = {
7
7
  skinToneVariation: SkinTones;
8
8
  style?: React.CSSProperties;
9
9
  };
10
- export declare function BtnSkinToneVariation({ isOpen, onClick, isActive, skinToneVariation, style }: Props): JSX.Element;
10
+ export declare function BtnSkinToneVariation({ isOpen, onClick, isActive, skinToneVariation, style, }: Props): JSX.Element;
11
11
  export {};
@@ -3,7 +3,7 @@ declare type Props = {
3
3
  direction?: SkinTonePickerDirection;
4
4
  };
5
5
  export declare function SkinTonePickerMenu(): JSX.Element;
6
- export declare function SkinTonePicker({ direction }: Props): JSX.Element | null;
6
+ export declare function SkinTonePicker({ direction, }: Props): JSX.Element | null;
7
7
  export declare enum SkinTonePickerDirection {
8
8
  VERTICAL = "epr-vertical",
9
9
  HORIZONTAL = "epr-horizontal"
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { CategoryConfig } from '../../types/exposedTypes';
3
3
  declare type Props = {
4
4
  isActiveCategory: boolean;
@@ -6,6 +6,7 @@ declare type Props = {
6
6
  allowNavigation: boolean;
7
7
  onClick: () => void;
8
8
  categoryConfig: CategoryConfig;
9
+ customIcon?: React.ReactNode;
9
10
  };
10
- export declare function CategoryButton({ isActiveCategory, category, allowNavigation, categoryConfig, onClick }: Props): JSX.Element;
11
+ export declare function CategoryButton({ isActiveCategory, category, allowNavigation, categoryConfig, onClick, customIcon, }: Props): JSX.Element;
11
12
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
3
- import { EmojiClickData, EmojiData, EmojiStyle, SkinTonePickerLocation, SkinTones, SuggestionMode, Theme } from '../types/exposedTypes';
3
+ import { CategoryIcons, EmojiClickData, EmojiData, EmojiStyle, SkinTonePickerLocation, SkinTones, SuggestionMode, Theme } from '../types/exposedTypes';
4
4
  import { CategoriesConfig } from './categoryConfig';
5
5
  import { CustomEmoji } from './customEmojiConfig';
6
6
  export declare const DEFAULT_SEARCH_PLACEHOLDER = "Search";
@@ -40,6 +40,8 @@ export declare type PickerConfigInternal = {
40
40
  allowExpandReactions: boolean;
41
41
  hiddenEmojis: string[];
42
42
  emojiData?: EmojiData;
43
+ categoryIcons: CategoryIcons;
44
+ nonce?: string;
43
45
  };
44
46
  export declare type PreviewConfig = {
45
47
  defaultEmoji: string;
@@ -15,6 +15,7 @@ export declare function useSkinTonesDisabledConfig(): boolean;
15
15
  export declare function useEmojiStyleConfig(): EmojiStyle;
16
16
  export declare function useAutoFocusSearchConfig(): boolean;
17
17
  export declare function useCategoriesConfig(): CategoriesConfig;
18
+ export declare function useCategoryIconsConfig(): Partial<Record<import("./categoryConfig").Categories, React.ReactNode>>;
18
19
  export declare function useCustomEmojisConfig(): CustomEmoji[];
19
20
  export declare function useOpenConfig(): boolean;
20
21
  export declare function useOnEmojiClickConfig(mouseEventSource: MOUSE_EVENT_SOURCE): (emoji: EmojiClickData, event: MouseEvent) => void;
@@ -6,6 +6,6 @@ const groups = [
6
6
  'activities',
7
7
  'objects',
8
8
  'symbols',
9
- 'flags'
9
+ 'flags',
10
10
  ];
11
11
  export default groups;
@@ -6,7 +6,7 @@ const groups = [
6
6
  'activities',
7
7
  'objects',
8
8
  'symbols',
9
- 'flags'
9
+ 'flags',
10
10
  ];
11
11
 
12
12
  export default groups;
@@ -5,13 +5,13 @@ const skinToneVariations = [
5
5
  SkinTones.MEDIUM_LIGHT,
6
6
  SkinTones.MEDIUM,
7
7
  SkinTones.MEDIUM_DARK,
8
- SkinTones.DARK
8
+ SkinTones.DARK,
9
9
  ];
10
10
  export const skinTonesNamed = Object.entries(SkinTones).reduce((acc, [key, value]) => {
11
11
  acc[value] = key;
12
12
  return acc;
13
13
  }, {});
14
14
  export const skinTonesMapped = skinToneVariations.reduce((mapped, skinTone) => Object.assign(mapped, {
15
- [skinTone]: skinTone
15
+ [skinTone]: skinTone,
16
16
  }), {});
17
17
  export default skinToneVariations;
@@ -6,7 +6,7 @@ const skinToneVariations = [
6
6
  SkinTones.MEDIUM_LIGHT,
7
7
  SkinTones.MEDIUM,
8
8
  SkinTones.MEDIUM_DARK,
9
- SkinTones.DARK
9
+ SkinTones.DARK,
10
10
  ];
11
11
 
12
12
  export const skinTonesNamed = Object.entries(SkinTones).reduce(
@@ -14,18 +14,16 @@ export const skinTonesNamed = Object.entries(SkinTones).reduce(
14
14
  acc[value] = key;
15
15
  return acc;
16
16
  },
17
- {} as Record<string, string>
17
+ {} as Record<string, string>,
18
18
  );
19
19
 
20
- export const skinTonesMapped: Record<
21
- string,
22
- string
23
- > = skinToneVariations.reduce(
24
- (mapped, skinTone) =>
25
- Object.assign(mapped, {
26
- [skinTone]: skinTone
27
- }),
28
- {}
29
- );
20
+ export const skinTonesMapped: Record<string, string> =
21
+ skinToneVariations.reduce(
22
+ (mapped, skinTone) =>
23
+ Object.assign(mapped, {
24
+ [skinTone]: skinTone,
25
+ }),
26
+ {},
27
+ );
30
28
 
31
29
  export default skinToneVariations;