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
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useMemo } from 'react';
3
3
  import { hasNextElementSibling } from '../DomUtils/elementPositionInRow';
4
4
  import {
5
5
  focusNextElementSibling,
6
- focusPrevElementSibling
6
+ focusPrevElementSibling,
7
7
  } from '../DomUtils/focusElement';
8
8
  import { getActiveElement } from '../DomUtils/getActiveElement';
9
9
  import {
@@ -12,7 +12,7 @@ import {
12
12
  focusNextVisibleEmoji,
13
13
  focusPrevVisibleEmoji,
14
14
  focusVisibleEmojiOneRowDown,
15
- focusVisibleEmojiOneRowUp
15
+ focusVisibleEmojiOneRowUp,
16
16
  } from '../DomUtils/keyboardNavigation';
17
17
  import { useScrollTo } from '../DomUtils/scrollTo';
18
18
  import { buttonFromTarget } from '../DomUtils/selectors';
@@ -21,27 +21,27 @@ import {
21
21
  useCategoryNavigationRef,
22
22
  usePickerMainRef,
23
23
  useSearchInputRef,
24
- useSkinTonePickerRef
24
+ useSkinTonePickerRef,
25
25
  } from '../components/context/ElementRefContext';
26
26
  import { useSkinToneFanOpenState } from '../components/context/PickerContext';
27
27
  import { useSearchDisabledConfig } from '../config/useConfig';
28
28
 
29
29
  import {
30
30
  useCloseAllOpenToggles,
31
- useHasOpenToggles
31
+ useHasOpenToggles,
32
32
  } from './useCloseAllOpenToggles';
33
33
  import { useDisallowMouseMove } from './useDisallowMouseMove';
34
34
  import { useAppendSearch, useClearSearch } from './useFilter';
35
35
  import {
36
36
  useFocusCategoryNavigation,
37
37
  useFocusSearchInput,
38
- useFocusSkinTonePicker
38
+ useFocusSkinTonePicker,
39
39
  } from './useFocus';
40
40
  import useIsSearchMode from './useIsSearchMode';
41
41
  import useSetVariationPicker from './useSetVariationPicker';
42
42
  import {
43
43
  useIsSkinToneInPreview,
44
- useIsSkinToneInSearch
44
+ useIsSkinToneInSearch,
45
45
  } from './useShouldShowSkinTonePicker';
46
46
 
47
47
  enum KeyboardEvents {
@@ -51,7 +51,7 @@ enum KeyboardEvents {
51
51
  ArrowRight = 'ArrowRight',
52
52
  Escape = 'Escape',
53
53
  Enter = 'Enter',
54
- Space = ' '
54
+ Space = ' ',
55
55
  }
56
56
 
57
57
  export function useKeyboardNavigation() {
@@ -99,8 +99,8 @@ function usePickerMainKeyboardEvents() {
99
99
  closeAllOpenToggles,
100
100
  focusSearchInput,
101
101
  hasOpenToggles,
102
- disallowMouseMove
103
- ]
102
+ disallowMouseMove,
103
+ ],
104
104
  );
105
105
 
106
106
  useEffect(() => {
@@ -156,8 +156,8 @@ function useSearchInputKeyboardEvents() {
156
156
  goDownFromSearchInput,
157
157
  setSkinToneFanOpenState,
158
158
  BodyRef,
159
- isSkinToneInSearch
160
- ]
159
+ isSkinToneInSearch,
160
+ ],
161
161
  );
162
162
 
163
163
  useEffect(() => {
@@ -249,8 +249,8 @@ function useSkinTonePickerKeyboardEvents() {
249
249
  goDownFromSearchInput,
250
250
  onType,
251
251
  isSkinToneInPreview,
252
- isSkinToneInSearch
253
- ]
252
+ isSkinToneInSearch,
253
+ ],
254
254
  );
255
255
 
256
256
  useEffect(() => {
@@ -301,7 +301,7 @@ function useCategoryNavigationKeyboardEvents() {
301
301
  break;
302
302
  }
303
303
  },
304
- [BodyRef, focusSearchInput, onType]
304
+ [BodyRef, focusSearchInput, onType],
305
305
  );
306
306
 
307
307
  useEffect(() => {
@@ -375,8 +375,8 @@ function useBodyKeyboardEvents() {
375
375
  onType,
376
376
  setVariationPicker,
377
377
  hasOpenToggles,
378
- closeAllOpenToggles
379
- ]
378
+ closeAllOpenToggles,
379
+ ],
380
380
  );
381
381
 
382
382
  useEffect(() => {
@@ -406,7 +406,7 @@ function useGoDownFromSearchInput() {
406
406
  }
407
407
  return focusCategoryNavigation();
408
408
  },
409
- [BodyRef, focusCategoryNavigation, isSearchMode]
409
+ [BodyRef, focusCategoryNavigation, isSearchMode],
410
410
  );
411
411
  }
412
412
 
@@ -422,7 +422,7 @@ function useGoUpFromBody() {
422
422
  }
423
423
  return focusCategoryNavigation();
424
424
  },
425
- [focusSearchInput, isSearchMode, focusCategoryNavigation]
425
+ [focusSearchInput, isSearchMode, focusCategoryNavigation],
426
426
  );
427
427
  }
428
428
 
@@ -4,13 +4,13 @@ import { useEffect, useRef } from 'react';
4
4
  import {
5
5
  allUnifiedFromEmojiElement,
6
6
  isEmojiElement,
7
- NullableElement
7
+ NullableElement,
8
8
  } from '../DomUtils/selectors';
9
9
  import {
10
10
  useActiveSkinToneState,
11
11
  useDisallowClickRef,
12
12
  useEmojiVariationPickerState,
13
- useUpdateSuggested
13
+ useUpdateSuggested,
14
14
  } from '../components/context/PickerContext';
15
15
  import { usePickerDataContext } from '../components/context/PickerDataContext';
16
16
  import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
@@ -18,14 +18,14 @@ import {
18
18
  MOUSE_EVENT_SOURCE,
19
19
  useEmojiStyleConfig,
20
20
  useGetEmojiUrlConfig,
21
- useOnEmojiClickConfig
21
+ useOnEmojiClickConfig,
22
22
  } from '../config/useConfig';
23
23
  import { DataEmoji } from '../dataUtils/DataTypes';
24
24
  import {
25
25
  activeVariationFromUnified,
26
26
  emojiHasVariations,
27
27
  emojiNames,
28
- emojiUnified
28
+ emojiUnified,
29
29
  } from '../dataUtils/emojiSelectors';
30
30
  import { parseNativeEmoji } from '../dataUtils/parseNativeEmoji';
31
31
  import { setSuggested } from '../dataUtils/suggested';
@@ -37,7 +37,7 @@ import useSetVariationPicker from './useSetVariationPicker';
37
37
 
38
38
  export function useMouseDownHandlers(
39
39
  ContainerRef: React.MutableRefObject<NullableElement>,
40
- mouseEventSource: MOUSE_EVENT_SOURCE
40
+ mouseEventSource: MOUSE_EVENT_SOURCE,
41
41
  ) {
42
42
  const mouseDownTimerRef = useRef<undefined | number>();
43
43
  const setVariationPicker = useSetVariationPicker();
@@ -72,7 +72,7 @@ export function useMouseDownHandlers(
72
72
  setSuggested(emoji, skinToneToUse);
73
73
  onEmojiClick(
74
74
  emojiClickOutput(emoji, skinToneToUse, activeEmojiStyle, getEmojiUrl),
75
- event
75
+ event,
76
76
  );
77
77
  },
78
78
  [
@@ -83,8 +83,8 @@ export function useMouseDownHandlers(
83
83
  onEmojiClick,
84
84
  updateSuggested,
85
85
  getEmojiUrl,
86
- activeEmojiStyle
87
- ]
86
+ activeEmojiStyle,
87
+ ],
88
88
  );
89
89
 
90
90
  const onMouseDown = React.useCallback(
@@ -112,8 +112,8 @@ export function useMouseDownHandlers(
112
112
  emojiByUnified,
113
113
  closeAllOpenToggles,
114
114
  setVariationPicker,
115
- setEmojiVariationPicker
116
- ]
115
+ setEmojiVariationPicker,
116
+ ],
117
117
  );
118
118
  const onMouseUp = React.useCallback(
119
119
  function onMouseUp() {
@@ -132,7 +132,7 @@ export function useMouseDownHandlers(
132
132
  });
133
133
  }
134
134
  },
135
- [disallowClickRef]
135
+ [disallowClickRef],
136
136
  );
137
137
 
138
138
  useEffect(() => {
@@ -141,14 +141,14 @@ export function useMouseDownHandlers(
141
141
  }
142
142
  const confainerRef = ContainerRef.current;
143
143
  confainerRef.addEventListener('click', onClick, {
144
- passive: true
144
+ passive: true,
145
145
  });
146
146
 
147
147
  confainerRef.addEventListener('mousedown', onMouseDown, {
148
- passive: true
148
+ passive: true,
149
149
  });
150
150
  confainerRef.addEventListener('mouseup', onMouseUp, {
151
- passive: true
151
+ passive: true,
152
152
  });
153
153
 
154
154
  return () => {
@@ -161,7 +161,7 @@ export function useMouseDownHandlers(
161
161
 
162
162
  function emojiFromEvent(
163
163
  event: MouseEvent,
164
- lookupEmojiByUnified: (unified?: string) => DataEmoji | undefined
164
+ lookupEmojiByUnified: (unified?: string) => DataEmoji | undefined,
165
165
  ): [DataEmoji, string] | [] {
166
166
  const target = event?.target as HTMLElement;
167
167
  if (!isEmojiElement(target)) {
@@ -186,7 +186,7 @@ function emojiClickOutput(
186
186
  emoji: DataEmoji,
187
187
  activeSkinTone: SkinTones,
188
188
  activeEmojiStyle: EmojiStyle,
189
- getEmojiUrl: GetEmojiUrl
189
+ getEmojiUrl: GetEmojiUrl,
190
190
  ): EmojiClickData {
191
191
  const names = emojiNames(emoji);
192
192
 
@@ -202,7 +202,7 @@ function emojiClickOutput(
202
202
  isCustom: true,
203
203
  names,
204
204
  unified,
205
- unifiedWithoutSkinTone: unified
205
+ unifiedWithoutSkinTone: unified,
206
206
  };
207
207
  }
208
208
  const unified = emojiUnified(emoji, activeSkinTone);
@@ -217,6 +217,6 @@ function emojiClickOutput(
217
217
  isCustom: false,
218
218
  names,
219
219
  unified,
220
- unifiedWithoutSkinTone: emojiUnified(emoji)
220
+ unifiedWithoutSkinTone: emojiUnified(emoji),
221
221
  };
222
222
  }
@@ -15,7 +15,7 @@ export function useOnScroll(BodyRef: ElementRef) {
15
15
  }
16
16
 
17
17
  bodyRef.addEventListener('scroll', onScroll, {
18
- passive: true
18
+ passive: true,
19
19
  });
20
20
 
21
21
  function onScroll() {
@@ -2,7 +2,7 @@ import { scrollTo } from '../DomUtils/scrollTo';
2
2
  import { NullableElement } from '../DomUtils/selectors';
3
3
  import {
4
4
  useBodyRef,
5
- usePickerMainRef
5
+ usePickerMainRef,
6
6
  } from '../components/context/ElementRefContext';
7
7
 
8
8
  export function useScrollCategoryIntoView() {
@@ -14,7 +14,7 @@ export function useScrollCategoryIntoView() {
14
14
  return;
15
15
  }
16
16
  const $category = BodyRef.current?.querySelector(
17
- `[data-name="${category}"]`
17
+ `[data-name="${category}"]`,
18
18
  ) as NullableElement;
19
19
 
20
20
  if (!$category) {
package/src/index.tsx CHANGED
@@ -5,7 +5,7 @@ import ErrorBoundary from './components/ErrorBoundary';
5
5
  import { PickerConfig } from './config/config';
6
6
  import {
7
7
  MutableConfigContext,
8
- useDefineMutableConfig
8
+ useDefineMutableConfig,
9
9
  } from './config/mutableConfig';
10
10
 
11
11
  export { ExportedEmoji as Emoji } from './components/emoji/ExportedEmoji';
@@ -17,12 +17,15 @@ export {
17
17
  Categories,
18
18
  EmojiClickData,
19
19
  SuggestionMode,
20
- SkinTonePickerLocation
20
+ SkinTonePickerLocation,
21
+ CategoryIcons,
22
+ CategoryConfig,
21
23
  } from './types/exposedTypes';
22
24
 
23
25
  export { emojiByUnified } from './dataUtils/emojiSelectors';
24
26
 
25
27
  export interface PickerProps extends PickerConfig {}
28
+ export type Props = PickerProps;
26
29
 
27
30
  export default function EmojiPicker(props: PickerProps) {
28
31
  const MutableConfigRef = useDefineMutableConfig({
@@ -1,10 +1,10 @@
1
1
  import { Categories, CustomCategoryConfig } from '../config/categoryConfig';
2
2
  import { CustomEmoji } from '../config/customEmojiConfig';
3
- import { CategoryConfig } from '../types/exposedTypes';
4
3
  import { DataEmoji } from '../dataUtils/DataTypes';
4
+ import { CategoryConfig } from '../types/exposedTypes';
5
5
 
6
6
  export function isCustomCategory(
7
- category: CategoryConfig | CustomCategoryConfig
7
+ category: CategoryConfig | CustomCategoryConfig,
8
8
  ): category is CustomCategoryConfig {
9
9
  return category.category === Categories.CUSTOM;
10
10
  }
@@ -1,3 +1,5 @@
1
+ import * as React from 'react';
2
+
1
3
  export type EmojiClickData = {
2
4
  activeSkinTone: SkinTones;
3
5
  unified: string;
@@ -12,8 +14,11 @@ export type EmojiClickData = {
12
14
  export type CategoryConfig = {
13
15
  category: Categories;
14
16
  name: string;
17
+ icon?: React.ReactNode;
15
18
  };
16
19
 
20
+ export type CategoryIcons = Partial<Record<Categories, React.ReactNode>>;
21
+
17
22
  export type EmojiData = {
18
23
  categories: Partial<Record<Categories, CategoryConfig>>;
19
24
  emojis: Record<string, DataEmoji[]>;
@@ -28,7 +33,7 @@ export interface DataEmoji {
28
33
 
29
34
  export enum SuggestionMode {
30
35
  RECENT = 'recent',
31
- FREQUENT = 'frequent'
36
+ FREQUENT = 'frequent',
32
37
  }
33
38
 
34
39
  export enum EmojiStyle {
@@ -36,13 +41,13 @@ export enum EmojiStyle {
36
41
  APPLE = 'apple',
37
42
  TWITTER = 'twitter',
38
43
  GOOGLE = 'google',
39
- FACEBOOK = 'facebook'
44
+ FACEBOOK = 'facebook',
40
45
  }
41
46
 
42
47
  export enum Theme {
43
48
  DARK = 'dark',
44
49
  LIGHT = 'light',
45
- AUTO = 'auto'
50
+ AUTO = 'auto',
46
51
  }
47
52
 
48
53
  export enum SkinTones {
@@ -51,7 +56,7 @@ export enum SkinTones {
51
56
  MEDIUM_LIGHT = '1f3fc',
52
57
  MEDIUM = '1f3fd',
53
58
  MEDIUM_DARK = '1f3fe',
54
- DARK = '1f3ff'
59
+ DARK = '1f3ff',
55
60
  }
56
61
 
57
62
  export enum Categories {
@@ -64,10 +69,10 @@ export enum Categories {
64
69
  ACTIVITIES = 'activities',
65
70
  OBJECTS = 'objects',
66
71
  SYMBOLS = 'symbols',
67
- FLAGS = 'flags'
72
+ FLAGS = 'flags',
68
73
  }
69
74
 
70
75
  export enum SkinTonePickerLocation {
71
76
  SEARCH = 'SEARCH',
72
- PREVIEW = 'PREVIEW'
77
+ PREVIEW = 'PREVIEW',
73
78
  }
@@ -3,7 +3,7 @@ export function shouldVirtualize({
3
3
  clientHeight,
4
4
  topOffset,
5
5
  style,
6
- dimensions
6
+ dimensions,
7
7
  }: {
8
8
  scrollTop: number;
9
9
  clientHeight: number;
@@ -29,7 +29,7 @@ export function getEmojiPositionStyle(dimensions: Dimensions, index: number) {
29
29
  return dimensions
30
30
  ? {
31
31
  top: Math.floor(index / dimensions.emojisPerRow) * dimensions.emojiSize,
32
- left: (index % dimensions.emojisPerRow) * dimensions.emojiSize
32
+ left: (index % dimensions.emojisPerRow) * dimensions.emojiSize,
33
33
  }
34
34
  : undefined;
35
35
  }