emoji-picker-react 4.0.0-rc.8 → 4.0.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 (117) hide show
  1. package/README.md +176 -43
  2. package/dist/DomUtils/classNames.d.ts +9 -1
  3. package/dist/DomUtils/elementPositionInRow.d.ts +10 -0
  4. package/dist/DomUtils/focusElement.d.ts +5 -0
  5. package/dist/DomUtils/getActiveElement.d.ts +2 -0
  6. package/dist/DomUtils/isDarkTheme.d.ts +1 -0
  7. package/dist/DomUtils/keyboardNavigation.d.ts +8 -0
  8. package/dist/DomUtils/scrollTo.d.ts +3 -1
  9. package/dist/DomUtils/selectors.d.ts +24 -11
  10. package/dist/EmojiPickerReact.d.ts +6 -0
  11. package/dist/components/ErrorBoundary.d.ts +15 -0
  12. package/dist/components/body/{RecentlyUsed.d.ts → Suggested.d.ts} +1 -1
  13. package/dist/components/context/ElementRefContext.d.ts +10 -13
  14. package/dist/components/context/PickerContext.d.ts +3 -3
  15. package/dist/components/emoji/Emoji.d.ts +11 -7
  16. package/dist/components/emoji/ExportedEmoji.d.ts +8 -0
  17. package/dist/components/footer/Preview.d.ts +1 -1
  18. package/dist/config/categoryConfig.d.ts +7 -3
  19. package/dist/config/config.d.ts +18 -15
  20. package/dist/config/useConfig.d.ts +11 -4
  21. package/dist/data/skinToneVariations.d.ts +2 -0
  22. package/dist/dataUtils/emojiSelectors.d.ts +3 -2
  23. package/dist/dataUtils/suggested.d.ts +11 -0
  24. package/dist/emoji-picker-react.cjs.development.css +9 -9
  25. package/dist/emoji-picker-react.cjs.development.js +3774 -3070
  26. package/dist/emoji-picker-react.cjs.development.js.map +1 -1
  27. package/dist/emoji-picker-react.cjs.production.min.js +1 -1
  28. package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
  29. package/dist/emoji-picker-react.esm.js +3784 -3080
  30. package/dist/emoji-picker-react.esm.js.map +1 -1
  31. package/dist/hooks/preloadEmoji.d.ts +1 -1
  32. package/dist/hooks/useActiveCategoryScrollDetection.d.ts +1 -2
  33. package/dist/hooks/useCloseAllOpenToggles.d.ts +2 -4
  34. package/dist/hooks/useDebouncedState.d.ts +1 -1
  35. package/dist/hooks/useDisallowMouseMove.d.ts +4 -0
  36. package/dist/hooks/useEmojiPreviewEvents.d.ts +3 -0
  37. package/dist/hooks/useFilter.d.ts +3 -3
  38. package/dist/hooks/useFocus.d.ts +3 -0
  39. package/dist/hooks/useInitialLoad.d.ts +1 -1
  40. package/dist/hooks/useIsEmojiHidden.d.ts +7 -1
  41. package/dist/hooks/useKeyboardNavigation.d.ts +1 -0
  42. package/dist/hooks/useMouseDownHandlers.d.ts +3 -2
  43. package/dist/hooks/useOnFocus.d.ts +1 -0
  44. package/dist/hooks/useScrollCategoryIntoView.d.ts +1 -0
  45. package/dist/hooks/useSetVariationPicker.d.ts +2 -0
  46. package/dist/index.d.ts +2 -2
  47. package/dist/types/exposedTypes.d.ts +5 -1
  48. package/package.json +13 -5
  49. package/src/DomUtils/classNames.ts +12 -1
  50. package/src/DomUtils/elementPositionInRow.ts +167 -0
  51. package/src/DomUtils/focusElement.ts +35 -0
  52. package/src/DomUtils/getActiveElement.ts +5 -0
  53. package/src/DomUtils/isDarkTheme.ts +7 -0
  54. package/src/DomUtils/keyboardNavigation.ts +161 -0
  55. package/src/DomUtils/scrollTo.ts +22 -1
  56. package/src/DomUtils/selectors.ts +200 -41
  57. package/src/EmojiPickerReact.css +99 -48
  58. package/src/EmojiPickerReact.tsx +26 -0
  59. package/src/components/ErrorBoundary.tsx +28 -0
  60. package/src/components/body/Body.tsx +3 -2
  61. package/src/components/body/EmojiCategory.css +14 -28
  62. package/src/components/body/EmojiCategory.tsx +5 -4
  63. package/src/components/body/EmojiList.tsx +13 -13
  64. package/src/components/body/EmojiVariationPicker.css +13 -5
  65. package/src/components/body/EmojiVariationPicker.tsx +25 -17
  66. package/src/components/body/Suggested.tsx +54 -0
  67. package/src/components/context/ElementRefContext.tsx +54 -19
  68. package/src/components/context/PickerContext.tsx +36 -33
  69. package/src/components/emoji/Emoji.css +42 -12
  70. package/src/components/emoji/Emoji.tsx +73 -34
  71. package/src/components/emoji/ExportedEmoji.tsx +30 -0
  72. package/src/components/footer/Preview.css +1 -1
  73. package/src/components/footer/Preview.tsx +16 -23
  74. package/src/components/header/Search.css +7 -7
  75. package/src/components/header/Search.tsx +31 -7
  76. package/src/components/header/SkinTonePicker.css +15 -8
  77. package/src/components/header/SkinTonePicker.tsx +23 -5
  78. package/src/components/main/PickerMain.css +0 -2
  79. package/src/components/main/PickerMain.tsx +14 -1
  80. package/src/components/navigation/CategoryNavigation.css +41 -10
  81. package/src/components/navigation/CategoryNavigation.tsx +22 -10
  82. package/src/components/navigation/svg/CategoryNav.svg +343 -379
  83. package/src/config/categoryConfig.ts +40 -14
  84. package/src/config/config.ts +59 -13
  85. package/src/config/useConfig.ts +35 -7
  86. package/src/data/emojis.json +1 -1
  87. package/src/data/skinToneVariations.ts +19 -0
  88. package/src/dataUtils/emojiSelectors.ts +25 -5
  89. package/src/dataUtils/{recentlyUsed.ts → suggested.ts} +20 -18
  90. package/src/hooks/preloadEmoji.ts +13 -2
  91. package/src/hooks/useActiveCategoryScrollDetection.ts +10 -8
  92. package/src/hooks/useCloseAllOpenToggles.ts +15 -4
  93. package/src/hooks/useDebouncedState.ts +10 -7
  94. package/src/hooks/useDisallowMouseMove.ts +47 -0
  95. package/src/hooks/useEmojiPreviewEvents.ts +103 -0
  96. package/src/hooks/useFilter.ts +46 -47
  97. package/src/hooks/useFocus.ts +40 -0
  98. package/src/hooks/useInitialLoad.ts +1 -0
  99. package/src/hooks/useIsEmojiHidden.ts +16 -3
  100. package/src/hooks/useKeyboardNavigation.ts +438 -0
  101. package/src/hooks/useMouseDownHandlers.ts +97 -89
  102. package/src/hooks/useOnFocus.ts +46 -0
  103. package/src/hooks/useOnScroll.ts +2 -2
  104. package/src/hooks/useScrollCategoryIntoView.ts +28 -0
  105. package/src/hooks/useSetVariationPicker.ts +28 -0
  106. package/src/index.tsx +9 -17
  107. package/src/types/exposedTypes.ts +6 -1
  108. package/dist/DomUtils/emojiElementRef.d.ts +0 -10
  109. package/dist/DomUtils/scrollCategoryIntoView.d.ts +0 -1
  110. package/dist/dataUtils/recentlyUsed.d.ts +0 -11
  111. package/dist/hooks/useEmojiElements.d.ts +0 -1
  112. package/dist/hooks/useEmojiMouseEnter.d.ts +0 -3
  113. package/src/DomUtils/emojiElementRef.ts +0 -42
  114. package/src/DomUtils/scrollCategoryIntoView.ts +0 -18
  115. package/src/components/body/RecentlyUsed.tsx +0 -50
  116. package/src/hooks/useEmojiElements.ts +0 -7
  117. package/src/hooks/useEmojiMouseEnter.ts +0 -59
package/README.md CHANGED
@@ -6,7 +6,7 @@ An emoji picker component for React applications.
6
6
 
7
7
  ## What to know before using
8
8
 
9
- - This package assumes it runs in the browser. I have taken many steps to prevent it from failing on the server, but still, it is recommended to only render the component on the client.
9
+ - This package assumes it runs in the browser. I have taken many steps to prevent it from failing on the server, but still, it is recommended to only render the component on the client. See troubleshooting section for more information.
10
10
 
11
11
  ## Installation
12
12
 
@@ -14,6 +14,20 @@ An emoji picker component for React applications.
14
14
  npm install emoji-picker-react
15
15
  ```
16
16
 
17
+ ## Usage:
18
+
19
+ ```jsx
20
+ import EmojiPicker from 'emoji-picker-react';
21
+
22
+ function App() {
23
+ return (
24
+ <div>
25
+ <EmojiPicker />
26
+ </div>
27
+ );
28
+ }
29
+ ```
30
+
17
31
  ## Features
18
32
 
19
33
  - Custom click handler
@@ -23,47 +37,68 @@ npm install emoji-picker-react
23
37
  - Skin tone change
24
38
  - Different emoji sets (Google, Apple, Facebook, Twitter)
25
39
  - Native Emoji support
40
+ - Emoji Component To Render Emojis in your app
41
+
42
+ # Props
43
+
44
+ The following props are accepted by them picker:
26
45
 
27
- ## Config Props
46
+ | Prop | Type | Default | Description |
47
+ | ------------------- | -------- | ---------- | ----------------------------------------------------------------------------------------------------------------- |
48
+ | onEmojiClick | function | | Callback function that is called when an emoji is clicked. The function receives the emoji object as a parameter. |
49
+ | autoFocusSearch | boolean | `true` | Controls the auto focus of the search input. |
50
+ | Theme | string | `light` | Controls the theme of the picker. Possible values are `light`, `dark` and `auto`. |
51
+ | emojiStyle | string | `apple` | Controls the emoji style. Possible values are `google`, `apple`, `facebook`, `twitter` and `native`. |
52
+ | defaultSkinTone | string | `neutral` | Controls the default skin tone. |
53
+ | lazyLoadEmojis | boolean | `false` | Controls whether the emojis are loaded lazily or not. |
54
+ | previewConfig | object | `{}` | Controls the preview of the emoji. See below for more information. |
55
+ | searchPlaceholder | string | `Search` | Controls the placeholder of the search input. |
56
+ | suggestedEmojisMode | string | `frequent` | Controls the suggested emojis mode. Possible values are `frequent` and `recent`. |
57
+ | skinTonesDisabled | boolean | `false` | Controls whether the skin tones are disabled or not. |
58
+ | `width` | number | `350` | Controls the width of the picker. |
59
+ | `height` | number | `450` | Controls the height of the picker. |
28
60
 
29
- - _onEmojiClick_ `(event: MouseEvent, emoji: EmojiClickData) => void` - Callback function when an emoji is clicked. The callback receives the event and the emoji data. The emoji data is comprised of the following properties:
61
+ ## Full details
30
62
 
31
- ```ts{
32
- activeSkinTone: SkinTones;
33
- unified: string;
34
- unifiedWithoutSkinTone: string;
35
- emoji: string;
36
- names: string[];
37
- getImageUrl: (emojiStyle: EmojiStyle) => string;
63
+ - `onEmojiClick`: `(emojiData: EmojiClickData, event: MouseEvent) => void` - Callback function when an emoji is clicked. The callback receives the event and the emoji data. The emoji data is comprised of the following properties:
64
+
65
+ ```ts
66
+ {
67
+ activeSkinTone: SkinTones;
68
+ unified: string;
69
+ unifiedWithoutSkinTone: string;
70
+ emoji: string;
71
+ names: string[];
72
+ getImageUrl: (emojiStyle: EmojiStyle) => string;
38
73
  }
39
74
  ```
40
75
 
41
- - _theme_ `Theme` - The theme of the picker. Can be either `light` or `dark`. Default is `light`.
76
+ - `theme`: `Theme` - The theme of the picker. Can be `light`, `dark` or auto. Default is `light`.
42
77
  The `Theme` enum can be imported from the package.
43
78
 
44
79
  ```ts
45
80
  import { Theme } from 'emoji-picker-react';
46
81
  ```
47
82
 
48
- - _emojiStyle_ `EmojiStyle` - The emoji style to use. Can be either `apple`, `google`, `facebook`, `twitter` or `native`. Default is `apple`.
83
+ - `emojiStyle`: `EmojiStyle` - The emoji style to use. Can be either `apple`, `google`, `facebook`, `twitter` or `native`. Default is `apple`.
49
84
  The `EmojiStyle` enum can be imported from the package.
50
85
 
51
86
  ```ts
52
87
  import { EmojiStyle } from 'emoji-picker-react';
53
88
  ```
54
89
 
55
- * _autoFocusSearch_: `boolean` - Whether to focus the search input on mount. Defaults to `true`.
90
+ * `autoFocusSearch`: `boolean` - Whether to focus the search input on mount. Defaults to `true`.
91
+ *
92
+ * `lazyLoadEmojis`: `boolean` - Whether to lazy load the emojis. Defaults to `false`.
56
93
 
57
- * _defaultSkinTone_: `SkinTones` - The default skin tone to use when an emoji is clicked. Defaults to `SkinTones.Neutral`. Possible skin tones are:
94
+ * `defaultSkinTone`: `SkinTones` - The default skin tone to use when an emoji is clicked. Defaults to `SkinTones.Neutral`. Possible skin tones are:
58
95
 
59
- ```
60
- ✋ NEUTRAL = 'neutral'
61
- ✋🏻 LIGHT = '1f3fb'
62
- ✋🏼 MEDIUM_LIGHT = '1f3fc'
63
- ✋🏽 MEDIUM = '1f3fd'
64
- ✋🏾 MEDIUM_DARK = '1f3fe'
65
- ✋🏿 DARK = '1f3ff'
66
- ```
96
+ - ✋ 'neutral'
97
+ - ✋🏻 '1f3fb'
98
+ - ✋🏼 '1f3fc'
99
+ - ✋🏽 '1f3fd'
100
+ - ✋🏾 '1f3fe'
101
+ - ✋🏿 '1f3ff'
67
102
 
68
103
  The skin tones typescript enum can be imported directly from the package:
69
104
 
@@ -71,35 +106,133 @@ The skin tones typescript enum can be imported directly from the package:
71
106
  import { SkinTones } from 'emoji-picker-react';
72
107
  ```
73
108
 
74
- - _skinTonesDisabled_: `boolean` - Whether to disable the skin tone selection. Defaults to `false`.
109
+ - `skinTonesDisabled`: `boolean` - Whether to disable the skin tone selection. Defaults to `false`.
110
+
111
+ - `previewConfig`: `PreviewConfig` - Full control over the Preview component, either to show/hide it, change the default emoji or the default caption.
75
112
 
76
- - _showPreview_: `boolean` - Whether to show the preview of the selected emoji. Defaults to `true`.
113
+ ```ts
114
+ {
115
+ defaultEmoji: string; // defaults to: "1f60a"
116
+ defaultCaption: string; // defaults to: "What's your mood?"
117
+ showPreview: boolean; // defaults to: true
118
+ }
119
+ ```
77
120
 
78
- - _searchPlaceholder_: `string` - The placeholder text for the search input. Defaults to `Search`.
121
+ - `searchPlaceholder`: `string` - The placeholder text for the search input. Defaults to `Search`.
79
122
 
80
123
  - categories: Allows full config over ordering, naming and display of categories.
81
124
  To only sort/omit categories, you can simply pass an array of category names to display:
82
125
 
126
+ - 'suggested',
127
+ - 'smileys_people',
128
+ - 'animals_nature',
129
+ - 'food_drink',
130
+ - 'travel_places',
131
+ - 'activities',
132
+ - 'objects',
133
+ - 'symbols',
134
+ - 'flags'
135
+
136
+ For a more in-depth configuration, you can pass an array with category config:
137
+
138
+ ```ts
139
+ [
140
+ {
141
+ category: 'suggested',
142
+ name: 'Recently Used'
143
+ },
144
+ {
145
+ category: 'smileys_people',
146
+ name: 'Faces...'
147
+ }
148
+ ];
149
+ ```
150
+
151
+ - `suggestedEmojisMode`: `SuggestedEmojisMode` - The mode to use for the suggested emojis. Can be either `recent` or `frequent`. Defaults to `recent`.
152
+ The `SuggestionMode` enum can be imported from the package.
153
+
154
+ ```ts
155
+ import { SuggestionMode } from 'emoji-picker-react';
156
+ ```
157
+
158
+ # Customization
159
+
160
+ ## Custom Picker Width and Height
161
+
162
+ To customize the dimensions of the picker, use the `height` and `width` props:
163
+
164
+ ```jsx
165
+ <EmojiPicker height={500} width={400} />
83
166
  ```
84
- RECENTLY_USED = 'recently_used',
85
- SMILEYS_PEOPLE = 'smileys_people',
86
- ANIMALS_NATURE = 'animals_nature',
87
- FOOD_DRINK = 'food_drink',
88
- TRAVEL_PLACES = 'travel_places',
89
- ACTIVITIES = 'activities',
90
- OBJECTS = 'objects',
91
- SYMBOLS = 'symbols',
92
- FLAGS = 'flags'
167
+
168
+ ## CSS Variables
169
+
170
+ The picker can be customized via css variables. The root selector for the picker is `.EmojiPickerReact`, when overriding, make sure to provide a more specific selector.
171
+
172
+ In dark mode, the specific selector is `.EmojiPickerReact.epr-dark-theme`.
173
+
174
+ The list of possible variables is quite extensive, but the main ones you may want to override are:
175
+
176
+ - `--epr-emoji-size`: The size of the emojis.
177
+ - `--epr-emoji-gap`: The space between emojis.
178
+
179
+ - `--epr-hover-bg-color` Hovered emoji background color.
180
+ - `--epr-bg-color`: The background color of the picker. When changing it, you should also change `--epr-category-label-bg-color` as they are usually the same color.
181
+ - `--epr-text-color`: The text color in the picker.
182
+
183
+ # Rendering Output Emojis in Your App
184
+
185
+ The picker exports an `Emoji` component. The emoji component is the same used within the picker, so it will render the same way as the emojis in the picker. You can choose to render emojis either as native, or as images.
186
+
187
+ ## Props
188
+
189
+ | Name | Type | Default | Description |
190
+ | ------------ | ------------ | ------------------ | ------------------------------------------------------------------------------------------- |
191
+ | `unified` | string | "" | The unified code of the emoji. |
192
+ | `size` | number | 32 | The size of the emoji. |
193
+ | `emojiStyle` | `EmojiStyle` | `EmojiStyle.APPLE` | The emoji style to use. Can be either `apple`, `google`, `facebook`, `twitter` or `native`. |
194
+ | `lazyLoad` | boolean | `false` | Whether to lazy load the emoji. image |
195
+
196
+ ```js
197
+ import { Emoji, EmojiStyle } from 'emoji-picker-react';
198
+
199
+ export function MyApp() {
200
+ return (
201
+ <p>
202
+ My Favorite emoji is:
203
+ <Emoji unified="1f423" size="25" />
204
+ </p>
205
+ );
206
+ }
93
207
  ```
94
208
 
95
- For a more in-depth configuration, you can pass an array with category config:
209
+ # Troubleshooting
96
210
 
97
- ```ts
98
- [{
99
- category: Categories.RECENTLY_USED;
100
- name: "Recently Used";
101
- }, {
102
- category: Categories.SMILEYS_PEOPLE;
103
- name: "Faces...";
104
- }]
211
+ ## Error Boundary
212
+
213
+ emoji-picker-react has a top-level error boundary, trying to catch rendering errors. It won't catch server side related errors, or event handlers errors. If an error is caught, the picker will not render, and a console error will be logged.
214
+
215
+ ## Next.js
216
+
217
+ To avoid errors such as "document is not defined" on the server side, you should make sure the library is only imported on the client side. Here is how to do that:
218
+
219
+ ```javascript
220
+ import dynamic from 'next/dynamic';
221
+
222
+ const Picker = dynamic(
223
+ () => {
224
+ return import('emoji-picker-react');
225
+ },
226
+ { ssr: false }
227
+ );
228
+ ```
229
+
230
+ ## Vite
231
+
232
+ For reference, if you only need to shim global, you can add
233
+
234
+ ```html
235
+ <script>
236
+ window.global = window;
237
+ </script>
105
238
  ```
@@ -2,5 +2,13 @@ export declare enum ClassNames {
2
2
  hiddenOnSearch = "epr-hidden-on-search",
3
3
  searchActive = "epr-search-active",
4
4
  hidden = "epr-hidden",
5
- visible = "epr-visible"
5
+ visible = "epr-visible",
6
+ active = "epr-active",
7
+ emoji = "epr-emoji",
8
+ category = "epr-emoji-category",
9
+ label = "epr-emoji-category-label",
10
+ categoryContent = "epr-emoji-category-content",
11
+ emojiHasVariatios = "epr-emoji-has-variations",
12
+ external = "__EmojiPicker__"
6
13
  }
14
+ export declare function asSelectors(...classNames: ClassNames[]): string;
@@ -0,0 +1,10 @@
1
+ import { NullableElement } from './selectors';
2
+ export declare function elementCountInRow(parent: NullableElement, element: NullableElement): number;
3
+ export declare function elementIndexInRow(parent: NullableElement, element: NullableElement): number;
4
+ export declare function rowNumber(parent: NullableElement, element: NullableElement): number;
5
+ export declare function hasNextRow(parent: NullableElement, element: NullableElement): boolean;
6
+ export declare function getElementInRow(elements: HTMLElement[], row: number, elementsInRow: number, indexInRow: number): NullableElement;
7
+ export declare function getElementInNextRow(allElements: HTMLElement[], currentRow: number, elementsInRow: number, index: number): NullableElement;
8
+ export declare function getElementInPrevRow(allElements: HTMLElement[], currentRow: number, elementsInRow: number, index: number): NullableElement;
9
+ export declare function firstVisibleElementInContainer(parent: NullableElement, elements: HTMLElement[]): NullableElement;
10
+ export declare function hasNextElementSibling(element: HTMLElement): boolean;
@@ -0,0 +1,5 @@
1
+ import { NullableElement } from './selectors';
2
+ export declare function focusElement(element: NullableElement): void;
3
+ export declare function focusPrevElementSibling(element: NullableElement): void;
4
+ export declare function focusNextElementSibling(element: NullableElement): void;
5
+ export declare function focusFirstElementChild(element: NullableElement): void;
@@ -0,0 +1,2 @@
1
+ import { NullableElement } from './selectors';
2
+ export declare function getActiveElement(): NullableElement;
@@ -0,0 +1 @@
1
+ export declare function isSystemDarkTheme(): boolean;
@@ -0,0 +1,8 @@
1
+ import { NullableElement } from './selectors';
2
+ export declare function focusFirstVisibleEmoji(parent: NullableElement): void;
3
+ export declare function focusAndClickFirstVisibleEmoji(parent: NullableElement): void;
4
+ export declare function focusLastVisibleEmoji(parent: NullableElement): void;
5
+ export declare function focusNextVisibleEmoji(element: NullableElement): void;
6
+ export declare function focusPrevVisibleEmoji(element: NullableElement): void;
7
+ export declare function focusVisibleEmojiOneRowUp(element: NullableElement, exitUp: () => void): void;
8
+ export declare function focusVisibleEmojiOneRowDown(element: NullableElement): void;
@@ -1 +1,3 @@
1
- export declare function scrollTo(root: HTMLElement | null, top?: number): void;
1
+ import { NullableElement } from './selectors';
2
+ export declare function scrollTo(root: NullableElement, top?: number): void;
3
+ export declare function useScrollTo(): (top: number) => void;
@@ -1,12 +1,25 @@
1
1
  import { DataEmoji } from '../dataUtils/DataTypes';
2
- export declare function buttonFromEmoji(emojiElement: HTMLElement | null): HTMLButtonElement | null;
3
- export declare function emojiFromElement(element: HTMLElement | null): DataEmoji | undefined;
4
- export declare function isEmojiElement(element: HTMLElement | null): boolean;
5
- export declare function closestCategory(element: HTMLElement | null): HTMLElement | null;
6
- export declare function categoryLabelFromCategory(category: HTMLElement | null): HTMLElement | null;
7
- export declare function closestCategoryLabel(element: null | HTMLElement): HTMLElement | null;
8
- export declare function elementHeight(element: HTMLElement | null): number;
9
- export declare function emojiTrueOffsetTop(element: HTMLElement | null): number;
10
- export declare function emojiTruOffsetLeft(element: HTMLElement | null): number;
11
- export declare function unifiedFromEmojiElement(emoji: HTMLElement | null): string | null;
12
- export declare function originalUnifiedFromEmojiElement(emoji: HTMLElement | null): string | null;
2
+ export declare type NullableElement = HTMLElement | null;
3
+ export declare const EmojiButtonSelector: string;
4
+ export declare const VisibleEmojiSelector: string;
5
+ export declare function buttonFromTarget(emojiElement: NullableElement): HTMLButtonElement | null;
6
+ export declare function emojiFromElement(element: NullableElement): [DataEmoji, string] | [];
7
+ export declare function isEmojiElement(element: NullableElement): boolean;
8
+ export declare function categoryLabelFromCategory(category: NullableElement): NullableElement;
9
+ export declare function closestCategoryLabel(element: NullableElement): NullableElement;
10
+ export declare function elementHeight(element: NullableElement): number;
11
+ export declare function emojiTrueOffsetTop(element: NullableElement): number;
12
+ export declare function emojiTruOffsetLeft(element: NullableElement): number;
13
+ export declare function unifiedFromEmojiElement(emoji: NullableElement): string | null;
14
+ export declare function originalUnifiedFromEmojiElement(emoji: NullableElement): string | null;
15
+ export declare function isVisibleEmoji(element: HTMLElement): boolean;
16
+ export declare function isHidden(element: NullableElement): boolean;
17
+ export declare function allVisibleEmojis(parent: NullableElement): HTMLElement[];
18
+ export declare function lastVisibleEmoji(element: NullableElement): NullableElement;
19
+ export declare function nextVisibleEmoji(element: HTMLElement): NullableElement;
20
+ export declare function prevVisibleEmoji(element: HTMLElement): NullableElement;
21
+ export declare function firstVisibleEmoji(parent: NullableElement): NullableElement;
22
+ export declare function prevCategory(element: NullableElement): NullableElement;
23
+ export declare function nextCategory(element: NullableElement): NullableElement;
24
+ export declare function closestCategory(element: NullableElement): NullableElement;
25
+ export declare function closestCategoryContent(element: NullableElement): NullableElement;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { PickerConfig } from './config/config';
3
+ import './EmojiPickerReact.css';
4
+ export interface Props extends PickerConfig {
5
+ }
6
+ export default function EmojiPicker(props: Props): JSX.Element;
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ export default class ErrorBoundary extends React.Component<{
3
+ children: React.ReactNode;
4
+ }, {
5
+ hasError: boolean;
6
+ }> {
7
+ constructor(props: {
8
+ children: React.ReactNode;
9
+ });
10
+ static getDerivedStateFromError(): {
11
+ hasError: boolean;
12
+ };
13
+ componentDidCatch(error: Error, errorInfo: any): void;
14
+ render(): number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactFragment | null | undefined;
15
+ }
@@ -3,5 +3,5 @@ import { CategoryConfig } from '../../config/categoryConfig';
3
3
  declare type Props = Readonly<{
4
4
  categoryConfig: CategoryConfig;
5
5
  }>;
6
- export declare function RecentlyUsed({ categoryConfig }: Props): JSX.Element | null;
6
+ export declare function Suggested({ categoryConfig }: Props): JSX.Element;
7
7
  export {};
@@ -1,17 +1,14 @@
1
1
  import * as React from 'react';
2
+ import { NullableElement } from '../../DomUtils/selectors';
2
3
  export declare function ElementRefContextProvider({ children }: {
3
4
  children: React.ReactNode;
4
5
  }): JSX.Element;
5
- export declare type ElementRef = React.MutableRefObject<HTMLElement | null>;
6
- declare type ElementRefs = {
7
- PickerMainRef: ElementRef;
8
- AnchoredEmojiRef: ElementRef;
9
- BodyRef: React.MutableRefObject<HTMLElement | null>;
10
- };
11
- declare type ElementRefKeys = keyof ElementRefs;
12
- export declare function useElementRef(key: ElementRefKeys): ElementRef | React.MutableRefObject<HTMLElement | null>;
13
- export declare function usePickerMainRef(): ElementRef | React.MutableRefObject<HTMLElement | null>;
14
- export declare function useAnchoredEmojiRef(): ElementRef | React.MutableRefObject<HTMLElement | null>;
15
- export declare function useSetAnchoredEmojiRef(): (target: null | HTMLElement) => void;
16
- export declare function useBodyRef(): React.MutableRefObject<HTMLDivElement | null>;
17
- export {};
6
+ export declare type ElementRef<E extends HTMLElement = HTMLElement> = React.MutableRefObject<E | null>;
7
+ export declare function usePickerMainRef(): ElementRef<HTMLElement>;
8
+ export declare function useAnchoredEmojiRef(): ElementRef<HTMLElement>;
9
+ export declare function useSetAnchoredEmojiRef(): (target: NullableElement) => void;
10
+ export declare function useBodyRef(): ElementRef<HTMLDivElement>;
11
+ export declare function useSearchInputRef(): ElementRef<HTMLInputElement>;
12
+ export declare function useSkinTonePickerRef(): ElementRef<HTMLDivElement>;
13
+ export declare function useCategoryNavigationRef(): ElementRef<HTMLDivElement>;
14
+ export declare function useVariationPickerRef(): ElementRef<HTMLDivElement>;
@@ -9,13 +9,13 @@ declare type Props = Readonly<{
9
9
  }>;
10
10
  export declare function useFilterRef(): React.MutableRefObject<Record<string, Record<string, DataEmoji>>>;
11
11
  export declare function useDisallowClickRef(): React.MutableRefObject<boolean>;
12
- export declare function useSearchTermState(): [string, (term: string) => void];
13
- export declare function useActiveCategoryState(): [ActiveCategoryState, (nextActive: string) => void, (nextActive: string) => void];
12
+ export declare function useDisallowMouseRef(): React.MutableRefObject<boolean>;
13
+ export declare function useSearchTermState(): [string, (term: string) => Promise<string>];
14
14
  export declare function useActiveSkinToneState(): [SkinTones, (skinTone: SkinTones) => void];
15
15
  export declare function useEmojisThatFailedToLoadState(): ReactState<Set<string>>;
16
16
  export declare function useIsPastInitialLoad(): boolean;
17
17
  export declare function useEmojiVariationPickerState(): ReactState<DataEmoji | null>;
18
18
  export declare function useSkinToneFanOpenState(): ReactState<boolean>;
19
+ export declare function useUpdateSuggested(): [number, () => void];
19
20
  export declare type FilterState = Record<string, FilterDict>;
20
- declare type ActiveCategoryState = null | string;
21
21
  export {};
@@ -1,16 +1,20 @@
1
1
  /// <reference types="react" />
2
2
  import { DataEmoji } from '../../dataUtils/DataTypes';
3
- import { EmojiRef } from '../../DomUtils/emojiElementRef';
4
3
  import { EmojiStyle } from '../../types/exposedTypes';
5
4
  import './Emoji.css';
6
- declare type Props = Readonly<{
5
+ declare type ClickableEmojiProps = Readonly<BaseProps & {
7
6
  hidden?: boolean;
8
- emojiStyle: EmojiStyle;
7
+ showVariations?: boolean;
8
+ hiddenOnSearch?: boolean;
9
9
  emoji: DataEmoji;
10
+ }>;
11
+ declare type BaseProps = {
12
+ emoji?: DataEmoji;
13
+ emojiStyle: EmojiStyle;
10
14
  unified: string;
11
- showVariations?: boolean;
12
15
  size?: number;
13
- emojiRef?: EmojiRef;
14
- }>;
15
- export declare function Emoji({ emoji, unified, hidden, emojiStyle, showVariations, size, emojiRef }: Props): JSX.Element;
16
+ lazyLoad?: boolean;
17
+ };
18
+ export declare function ClickableEmoji({ emoji, unified, hidden, hiddenOnSearch, emojiStyle, showVariations, size, lazyLoad }: ClickableEmojiProps): JSX.Element;
19
+ export declare function ViewOnlyEmoji({ emoji, unified, emojiStyle, size, lazyLoad }: BaseProps): JSX.Element;
16
20
  export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { EmojiStyle } from '../../types/exposedTypes';
3
+ export declare function ExportedEmoji({ unified, size, emojiStyle, lazyLoad }: {
4
+ unified: string;
5
+ emojiStyle?: EmojiStyle;
6
+ size?: number;
7
+ lazyLoad?: boolean;
8
+ }): JSX.Element | null;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import './Preview.css';
3
3
  export declare function Preview(): JSX.Element | null;
4
- export declare type HoveredEmoji = null | {
4
+ export declare type PreviewEmoji = null | {
5
5
  unified: string;
6
6
  originalUnified: string;
7
7
  };
@@ -1,6 +1,7 @@
1
- import { Categories } from '../types/exposedTypes';
1
+ import { Categories, SuggestionMode } from '../types/exposedTypes';
2
2
  export { Categories };
3
- export declare const baseCategoriesConfig: CategoryConfig[];
3
+ export declare const SuggestedRecent: CategoryConfig;
4
+ export declare function baseCategoriesConfig(modifiers?: Record<Categories, CategoryConfig>): CategoriesConfig;
4
5
  export declare function categoryFromCategoryConfig(category: CategoryConfig): Categories;
5
6
  export declare function categoryNameFromCategoryConfig(category: CategoryConfig): string;
6
7
  export declare type CategoriesConfig = CategoryConfig[];
@@ -9,4 +10,7 @@ export declare type CategoryConfig = {
9
10
  name: string;
10
11
  };
11
12
  export declare type UserCategoryConfig = Array<Categories | CategoryConfig>;
12
- export declare function mergeCategoriesConfig(userCategoriesConfig?: UserCategoryConfig): CategoriesConfig;
13
+ export declare function mergeCategoriesConfig(userCategoriesConfig?: UserCategoryConfig, modifiers?: CategoryConfigModifiers): CategoriesConfig;
14
+ declare type CategoryConfigModifiers = {
15
+ suggestionMode?: SuggestionMode;
16
+ };
@@ -1,16 +1,6 @@
1
- import { EmojiClickData, EmojiStyle, SkinTones, Theme } from '../types/exposedTypes';
1
+ import { EmojiClickData, EmojiStyle, SkinTones, SuggestionMode, Theme } from '../types/exposedTypes';
2
2
  import { CategoriesConfig } from './categoryConfig';
3
- export declare function mergeConfig(userConfig?: PickerConfig): {
4
- categories: CategoriesConfig;
5
- searchPlaceHolder: string;
6
- defaultSkinTone: SkinTones;
7
- skinTonesDisabled: boolean;
8
- autoFocusSearch: boolean;
9
- emojiStyle: EmojiStyle;
10
- onEmojiClick: (event: MouseEvent, emoji: EmojiClickData) => void;
11
- showPreview: boolean;
12
- theme: Theme;
13
- };
3
+ export declare function mergeConfig(userConfig?: PickerConfig): PickerConfigInternal;
14
4
  export declare function basePickerConfig(): PickerConfigInternal;
15
5
  export declare type PickerConfigInternal = {
16
6
  searchPlaceHolder: string;
@@ -19,8 +9,21 @@ export declare type PickerConfigInternal = {
19
9
  autoFocusSearch: boolean;
20
10
  emojiStyle: EmojiStyle;
21
11
  categories: CategoriesConfig;
22
- onEmojiClick: (event: MouseEvent, emoji: EmojiClickData) => void;
23
- showPreview: boolean;
12
+ onEmojiClick: (emoji: EmojiClickData, event: MouseEvent) => void;
24
13
  theme: Theme;
14
+ suggestedEmojisMode: SuggestionMode;
15
+ lazyLoadEmojis: boolean;
16
+ previewConfig: PreviewConfig;
17
+ height: number;
18
+ width: number;
19
+ };
20
+ export declare type PreviewConfig = {
21
+ defaultEmoji: string;
22
+ defaultCaption: string;
23
+ showPreview: boolean;
25
24
  };
26
- export declare type PickerConfig = Partial<PickerConfigInternal>;
25
+ declare type ConfigExternal = {
26
+ previewConfig: Partial<PreviewConfig>;
27
+ } & Omit<PickerConfigInternal, 'previewConfig'>;
28
+ export declare type PickerConfig = Partial<ConfigExternal>;
29
+ export {};
@@ -1,11 +1,18 @@
1
- import { EmojiClickData, EmojiStyle, SkinTones } from '../types/exposedTypes';
1
+ import { EmojiClickData, EmojiStyle, SkinTones, SuggestionMode, Theme } from '../types/exposedTypes';
2
2
  import { CategoriesConfig } from './categoryConfig';
3
+ import { PreviewConfig } from './config';
3
4
  export declare function useSearchPlaceHolderConfig(): string;
4
5
  export declare function useDefaultSkinToneConfig(): SkinTones;
5
6
  export declare function useSkinTonesDisabledConfig(): boolean;
6
7
  export declare function useEmojiStyleConfig(): EmojiStyle;
7
8
  export declare function useAutoFocusSearchConfig(): boolean;
8
9
  export declare function useCategoriesConfig(): CategoriesConfig;
9
- export declare function useOnEmojiClickConfig(): (event: MouseEvent, emoji: EmojiClickData) => void;
10
- export declare function useShowPreviewConfig(): boolean;
11
- export declare function useThemeConfig(): string;
10
+ export declare function useOnEmojiClickConfig(): (emoji: EmojiClickData, event: MouseEvent) => void;
11
+ export declare function usePreviewConfig(): PreviewConfig;
12
+ export declare function useThemeConfig(): Theme;
13
+ export declare function useSuggestedEmojisModeConfig(): SuggestionMode;
14
+ export declare function useLazyLoadEmojisConfig(): boolean;
15
+ export declare function usePickerSizeConfig(): {
16
+ height: number;
17
+ width: number;
18
+ };
@@ -1,3 +1,5 @@
1
1
  import { SkinTones } from '../types/exposedTypes';
2
2
  declare const skinToneVariations: SkinTones[];
3
+ export declare const skinTonesNamed: Record<string, string>;
4
+ export declare const skinTonesMapped: Record<string, string>;
3
5
  export default skinToneVariations;
@@ -1,8 +1,9 @@
1
- import { Categories } from './../config/categoryConfig';
2
- import { DataEmoji, DataEmojis } from './DataTypes';
1
+ import { Categories } from '../config/categoryConfig';
3
2
  import { EmojiStyle, SkinTones } from '../types/exposedTypes';
3
+ import { DataEmoji, DataEmojis } from './DataTypes';
4
4
  export declare function emojiNames(emoji: DataEmoji): string[];
5
5
  export declare function emojiName(emoji: DataEmoji): string;
6
+ export declare function unifiedWithoutSkinTone(unified: string): string;
6
7
  export declare function emojiUrl(emojiStyle: EmojiStyle, emoji: DataEmoji, skinTone?: string): string;
7
8
  export declare function emojiUnified(emoji: DataEmoji, skinTone?: string): string;
8
9
  export declare function emojisByCategory(category: Categories): DataEmojis;
@@ -0,0 +1,11 @@
1
+ import { SkinTones, SuggestionMode } from '../types/exposedTypes';
2
+ import { DataEmoji } from './DataTypes';
3
+ declare type SuggestedItem = {
4
+ unified: string;
5
+ original: string;
6
+ count: number;
7
+ };
8
+ declare type Suggested = SuggestedItem[];
9
+ export declare function getsuggested(mode?: SuggestionMode): Suggested;
10
+ export declare function setsuggested(emoji: DataEmoji, skinTone: SkinTones): void;
11
+ export {};