emoji-picker-react 4.4.0-rc.1 → 4.4.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 (40) hide show
  1. package/README.md +26 -16
  2. package/dist/DomUtils/classNames.d.ts +4 -1
  3. package/dist/components/Layout/Absolute.d.ts +8 -0
  4. package/dist/components/Layout/Relative.d.ts +2 -1
  5. package/dist/components/Layout/Space.d.ts +7 -0
  6. package/dist/components/footer/Preview.d.ts +1 -0
  7. package/dist/components/header/Search.d.ts +1 -0
  8. package/dist/components/header/SkinTonePicker.d.ts +10 -1
  9. package/dist/config/config.d.ts +3 -3
  10. package/dist/config/useConfig.d.ts +3 -3
  11. package/dist/emoji-picker-react.cjs.development.css +4 -4
  12. package/dist/emoji-picker-react.cjs.development.js +254 -128
  13. package/dist/emoji-picker-react.cjs.development.js.map +1 -1
  14. package/dist/emoji-picker-react.cjs.production.min.js +1 -1
  15. package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
  16. package/dist/emoji-picker-react.esm.js +266 -140
  17. package/dist/emoji-picker-react.esm.js.map +1 -1
  18. package/dist/hooks/useShouldShowSkinTonePicker.d.ts +4 -0
  19. package/dist/types/exposedTypes.d.ts +4 -0
  20. package/package.json +1 -1
  21. package/src/DomUtils/classNames.ts +4 -1
  22. package/src/EmojiPickerReact.css +3 -0
  23. package/src/components/Layout/Absolute.tsx +15 -0
  24. package/src/components/Layout/Relative.tsx +3 -2
  25. package/src/components/Layout/Space.tsx +11 -0
  26. package/src/components/footer/Preview.css +2 -0
  27. package/src/components/footer/Preview.tsx +23 -11
  28. package/src/components/header/Header.tsx +2 -7
  29. package/src/components/header/Search.tsx +25 -3
  30. package/src/components/header/SkinTonePicker.css +19 -9
  31. package/src/components/header/SkinTonePicker.tsx +41 -4
  32. package/src/config/config.ts +11 -4
  33. package/src/config/useConfig.ts +11 -8
  34. package/src/hooks/useDisallowedEmojis.ts +4 -17
  35. package/src/hooks/useFilter.ts +9 -10
  36. package/src/hooks/useKeyboardNavigation.ts +69 -26
  37. package/src/hooks/useShouldShowSkinTonePicker.ts +22 -0
  38. package/src/types/exposedTypes.ts +10 -5
  39. package/dist/predicates/isFunction.d.ts +0 -1
  40. package/src/predicates/isFunction.ts +0 -5
@@ -38,6 +38,10 @@ import {
38
38
  } from './useFocus';
39
39
  import useIsSearchMode from './useIsSearchMode';
40
40
  import useSetVariationPicker from './useSetVariationPicker';
41
+ import {
42
+ useIsSkinToneInPreview,
43
+ useIsSkinToneInSearch
44
+ } from './useShouldShowSkinTonePicker';
41
45
 
42
46
  enum KeyboardEvents {
43
47
  ArrowDown = 'ArrowDown',
@@ -120,6 +124,7 @@ function useSearchInputKeyboardEvents() {
120
124
  const SearchInputRef = useSearchInputRef();
121
125
  const [, setSkinToneFanOpenState] = useSkinToneFanOpenState();
122
126
  const goDownFromSearchInput = useGoDownFromSearchInput();
127
+ const isSkinToneInSearch = useIsSkinToneInSearch();
123
128
 
124
129
  const onKeyDown = useMemo(
125
130
  () =>
@@ -128,6 +133,9 @@ function useSearchInputKeyboardEvents() {
128
133
 
129
134
  switch (key) {
130
135
  case KeyboardEvents.ArrowRight:
136
+ if (!isSkinToneInSearch) {
137
+ return;
138
+ }
131
139
  event.preventDefault();
132
140
  setSkinToneFanOpenState(true);
133
141
  focusSkinTonePicker();
@@ -171,41 +179,76 @@ function useSkinTonePickerKeyboardEvents() {
171
179
  const SearchInputRef = useSearchInputRef();
172
180
  const goDownFromSearchInput = useGoDownFromSearchInput();
173
181
  const [isOpen, setIsOpen] = useSkinToneFanOpenState();
182
+ const isSkinToneInPreview = useIsSkinToneInPreview();
183
+ const isSkinToneInSearch = useIsSkinToneInSearch();
174
184
  const onType = useOnType();
175
185
 
176
186
  const onKeyDown = useMemo(
177
187
  () =>
188
+ // eslint-disable-next-line complexity
178
189
  function onKeyDown(event: KeyboardEvent) {
179
190
  const { key } = event;
180
191
 
181
- switch (key) {
182
- case KeyboardEvents.ArrowLeft:
183
- event.preventDefault();
184
- if (!isOpen) {
185
- return focusSearchInput();
186
- }
187
- focusNextSkinTone(focusSearchInput);
188
- break;
189
- case KeyboardEvents.ArrowRight:
190
- event.preventDefault();
191
- if (!isOpen) {
192
- return focusSearchInput();
193
- }
194
- focusPrevSkinTone();
195
- break;
196
- case KeyboardEvents.ArrowDown:
197
- event.preventDefault();
198
- if (isOpen) {
199
- setIsOpen(false);
200
- }
201
- goDownFromSearchInput();
202
- break;
203
- default:
204
- onType(event);
205
- break;
192
+ if (isSkinToneInSearch) {
193
+ switch (key) {
194
+ case KeyboardEvents.ArrowLeft:
195
+ event.preventDefault();
196
+ if (!isOpen) {
197
+ return focusSearchInput();
198
+ }
199
+ focusNextSkinTone(focusSearchInput);
200
+ break;
201
+ case KeyboardEvents.ArrowRight:
202
+ event.preventDefault();
203
+ if (!isOpen) {
204
+ return focusSearchInput();
205
+ }
206
+ focusPrevSkinTone();
207
+ break;
208
+ case KeyboardEvents.ArrowDown:
209
+ event.preventDefault();
210
+ if (isOpen) {
211
+ setIsOpen(false);
212
+ }
213
+ goDownFromSearchInput();
214
+ break;
215
+ default:
216
+ onType(event);
217
+ break;
218
+ }
219
+ }
220
+
221
+ if (isSkinToneInPreview) {
222
+ switch (key) {
223
+ case KeyboardEvents.ArrowUp:
224
+ event.preventDefault();
225
+ if (!isOpen) {
226
+ return focusSearchInput();
227
+ }
228
+ focusNextSkinTone(focusSearchInput);
229
+ break;
230
+ case KeyboardEvents.ArrowDown:
231
+ event.preventDefault();
232
+ if (!isOpen) {
233
+ return focusSearchInput();
234
+ }
235
+ focusPrevSkinTone();
236
+ break;
237
+ default:
238
+ onType(event);
239
+ break;
240
+ }
206
241
  }
207
242
  },
208
- [isOpen, focusSearchInput, setIsOpen, goDownFromSearchInput, onType]
243
+ [
244
+ isOpen,
245
+ focusSearchInput,
246
+ setIsOpen,
247
+ goDownFromSearchInput,
248
+ onType,
249
+ isSkinToneInPreview,
250
+ isSkinToneInSearch
251
+ ]
209
252
  );
210
253
 
211
254
  useEffect(() => {
@@ -0,0 +1,22 @@
1
+ import { useSkinTonePickerLocationConfig } from '../config/useConfig';
2
+ import { SkinTonePickerLocation } from '../types/exposedTypes';
3
+
4
+ export function useShouldShowSkinTonePicker() {
5
+ const skinTonePickerLocationConfig = useSkinTonePickerLocationConfig();
6
+
7
+ return function shouldShowSkinTonePicker(location: SkinTonePickerLocation) {
8
+ return skinTonePickerLocationConfig === location;
9
+ };
10
+ }
11
+
12
+ export function useIsSkinToneInSearch() {
13
+ const skinTonePickerLocationConfig = useSkinTonePickerLocationConfig();
14
+
15
+ return skinTonePickerLocationConfig === SkinTonePickerLocation.SEARCH;
16
+ }
17
+
18
+ export function useIsSkinToneInPreview() {
19
+ const skinTonePickerLocationConfig = useSkinTonePickerLocationConfig();
20
+
21
+ return skinTonePickerLocationConfig === SkinTonePickerLocation.PREVIEW;
22
+ }
@@ -9,7 +9,7 @@ export type EmojiClickData = {
9
9
 
10
10
  export enum SuggestionMode {
11
11
  RECENT = 'recent',
12
- FREQUENT = 'frequent',
12
+ FREQUENT = 'frequent'
13
13
  }
14
14
 
15
15
  export enum EmojiStyle {
@@ -17,13 +17,13 @@ export enum EmojiStyle {
17
17
  APPLE = 'apple',
18
18
  TWITTER = 'twitter',
19
19
  GOOGLE = 'google',
20
- FACEBOOK = 'facebook',
20
+ FACEBOOK = 'facebook'
21
21
  }
22
22
 
23
23
  export enum Theme {
24
24
  DARK = 'dark',
25
25
  LIGHT = 'light',
26
- AUTO = 'auto',
26
+ AUTO = 'auto'
27
27
  }
28
28
 
29
29
  export enum SkinTones {
@@ -32,7 +32,7 @@ export enum SkinTones {
32
32
  MEDIUM_LIGHT = '1f3fc',
33
33
  MEDIUM = '1f3fd',
34
34
  MEDIUM_DARK = '1f3fe',
35
- DARK = '1f3ff',
35
+ DARK = '1f3ff'
36
36
  }
37
37
 
38
38
  export enum Categories {
@@ -44,5 +44,10 @@ export enum Categories {
44
44
  ACTIVITIES = 'activities',
45
45
  OBJECTS = 'objects',
46
46
  SYMBOLS = 'symbols',
47
- FLAGS = 'flags',
47
+ FLAGS = 'flags'
48
+ }
49
+
50
+ export enum SkinTonePickerLocation {
51
+ SEARCH = 'SEARCH',
52
+ PREVIEW = 'PREVIEW'
48
53
  }
@@ -1 +0,0 @@
1
- export default function isFunction(value: any): value is (...args: any[]) => any;
@@ -1,5 +0,0 @@
1
- export default function isFunction(
2
- value: any
3
- ): value is (...args: any[]) => any {
4
- return typeof value === 'function';
5
- }