emoji-picker-react 4.6.14 → 4.7.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 (51) hide show
  1. package/README.md +37 -12
  2. package/dist/components/Reactions/BtnPlus.d.ts +2 -0
  3. package/dist/components/Reactions/DEFAULT_REACTIONS.d.ts +1 -0
  4. package/dist/components/Reactions/Reactions.d.ts +2 -0
  5. package/dist/components/context/ElementRefContext.d.ts +1 -0
  6. package/dist/components/context/PickerContext.d.ts +1 -0
  7. package/dist/components/emoji/ClickableEmojiButton.d.ts +2 -1
  8. package/dist/components/emoji/Emoji.d.ts +2 -1
  9. package/dist/components/header/Search/BtnClearSearch.d.ts +2 -0
  10. package/dist/components/header/Search/IcnSearch.d.ts +2 -0
  11. package/dist/components/header/SkinTonePicker/BtnSkinToneVariation.d.ts +11 -0
  12. package/dist/components/navigation/CategoryButton.d.ts +11 -0
  13. package/dist/config/config.d.ts +2 -0
  14. package/dist/config/useConfig.d.ts +2 -0
  15. package/dist/emoji-picker-react.cjs.development.js +1265 -963
  16. package/dist/emoji-picker-react.cjs.development.js.map +1 -1
  17. package/dist/emoji-picker-react.cjs.production.min.js +1 -1
  18. package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
  19. package/dist/emoji-picker-react.esm.js +1266 -964
  20. package/dist/emoji-picker-react.esm.js.map +1 -1
  21. package/package.json +5 -2
  22. package/src/EmojiPickerReact.tsx +28 -3
  23. package/src/Stylesheet/stylesheet.tsx +14 -2
  24. package/src/components/Reactions/BtnPlus.tsx +78 -0
  25. package/src/components/Reactions/DEFAULT_REACTIONS.ts +9 -0
  26. package/src/components/Reactions/Reactions.tsx +62 -0
  27. package/src/components/Reactions/svg/plus.svg +17 -0
  28. package/src/components/body/Body.tsx +8 -2
  29. package/src/components/body/EmojiVariationPicker.tsx +6 -7
  30. package/src/components/context/ElementRefContext.tsx +10 -2
  31. package/src/components/context/PickerContext.tsx +16 -3
  32. package/src/components/emoji/ClickableEmojiButton.tsx +13 -3
  33. package/src/components/emoji/Emoji.tsx +4 -1
  34. package/src/components/footer/Preview.tsx +11 -8
  35. package/src/components/header/Header.tsx +6 -2
  36. package/src/components/header/Search/BtnClearSearch.tsx +91 -0
  37. package/src/components/header/{CssSearch.tsx → Search/CssSearch.tsx} +2 -2
  38. package/src/components/header/Search/IcnSearch.tsx +39 -0
  39. package/src/components/header/{Search.tsx → Search/Search.tsx} +14 -49
  40. package/src/components/header/SkinTonePicker/BtnSkinToneVariation.tsx +80 -0
  41. package/src/components/header/{SkinTonePicker.tsx → SkinTonePicker/SkinTonePicker.tsx} +25 -67
  42. package/src/components/main/PickerMain.tsx +27 -2
  43. package/src/components/navigation/CategoryButton.tsx +141 -0
  44. package/src/components/navigation/CategoryNavigation.tsx +10 -129
  45. package/src/config/config.ts +7 -2
  46. package/src/config/useConfig.ts +16 -3
  47. /package/dist/components/header/{CssSearch.d.ts → Search/CssSearch.d.ts} +0 -0
  48. /package/dist/components/header/{Search.d.ts → Search/Search.d.ts} +0 -0
  49. /package/dist/components/header/{SkinTonePicker.d.ts → SkinTonePicker/SkinTonePicker.d.ts} +0 -0
  50. /package/src/components/header/{svg → Search/svg}/magnifier.svg +0 -0
  51. /package/src/components/header/{svg → Search/svg}/times.svg +0 -0
@@ -2,25 +2,17 @@ import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
  import { useState } from 'react';
4
4
 
5
- import { ClassNames } from '../../DomUtils/classNames';
6
- import {
7
- commonInteractionStyles,
8
- stylesheet
9
- } from '../../Stylesheet/stylesheet';
10
- import {
11
- categoryFromCategoryConfig,
12
- categoryNameFromCategoryConfig
13
- } from '../../config/categoryConfig';
5
+ import { stylesheet } from '../../Stylesheet/stylesheet';
6
+ import { categoryFromCategoryConfig } from '../../config/categoryConfig';
14
7
  import { useCategoriesConfig } from '../../config/useConfig';
15
8
  import { useActiveCategoryScrollDetection } from '../../hooks/useActiveCategoryScrollDetection';
16
9
  import useIsSearchMode from '../../hooks/useIsSearchMode';
17
10
  import { useScrollCategoryIntoView } from '../../hooks/useScrollCategoryIntoView';
18
11
  import { useShouldHideCustomEmojis } from '../../hooks/useShouldHideCustomEmojis';
19
12
  import { isCustomCategory } from '../../typeRefinements/typeRefinements';
20
- import { Button } from '../atoms/Button';
21
13
  import { useCategoryNavigationRef } from '../context/ElementRefContext';
22
14
 
23
- import SVGNavigation from './svg/CategoryNav.svg';
15
+ import { CategoryButton } from './CategoryButton';
24
16
 
25
17
  export function CategoryNavigation() {
26
18
  const [activeCategory, setActiveCategory] = useState<string | null>(null);
@@ -48,26 +40,19 @@ export function CategoryNavigation() {
48
40
  return null;
49
41
  }
50
42
 
43
+ const allowNavigation = !isSearchMode && !isActiveCategory;
44
+
51
45
  return (
52
- <Button
53
- tabIndex={isSearchMode || isActiveCategory ? -1 : 0}
54
- className={cx(
55
- styles.catBtn,
56
- commonInteractionStyles.categoryBtn,
57
- `epr-icn-${category}`,
58
- {
59
- [ClassNames.active]: isActiveCategory
60
- }
61
- )}
46
+ <CategoryButton
62
47
  key={category}
48
+ category={category}
49
+ isActiveCategory={isActiveCategory}
50
+ allowNavigation={allowNavigation}
51
+ categoryConfig={categoryConfig}
63
52
  onClick={() => {
64
53
  setActiveCategory(category);
65
54
  scrollCategoryIntoView(category);
66
55
  }}
67
- aria-label={categoryNameFromCategoryConfig(categoryConfig)}
68
- aria-selected={isActiveCategory}
69
- role="tab"
70
- aria-controls="epr-category-nav-id"
71
56
  />
72
57
  );
73
58
  })}
@@ -96,109 +81,5 @@ const styles = stylesheet.create({
96
81
  cursor: 'default',
97
82
  pointerEvents: 'none'
98
83
  }
99
- },
100
- catBtn: {
101
- '.': 'epr-cat-btn',
102
- display: 'inline-block',
103
- transition: 'opacity 0.2s ease-in-out',
104
- position: 'relative',
105
- height: 'var(--epr-category-navigation-button-size)',
106
- width: 'var(--epr-category-navigation-button-size)',
107
- backgroundSize: 'calc(var(--epr-category-navigation-button-size) * 10)',
108
- outline: 'none',
109
- backgroundPosition: '0 0',
110
- backgroundImage: `url(${SVGNavigation})`,
111
- ':focus:before': {
112
- content: '',
113
- position: 'absolute',
114
- top: '-2px',
115
- left: '-2px',
116
- right: '-2px',
117
- bottom: '-2px',
118
- border: '2px solid var(--epr-category-icon-active-color)',
119
- borderRadius: '50%'
120
- },
121
- // @ts-ignore
122
- '&.epr-icn-suggested': {
123
- backgroundPositionX:
124
- 'calc(var(--epr-category-navigation-button-size) * -8)'
125
- },
126
- '&.epr-icn-custom': {
127
- backgroundPositionX:
128
- 'calc(var(--epr-category-navigation-button-size) * -9)'
129
- },
130
- '&.epr-icn-activities': {
131
- backgroundPositionX:
132
- 'calc(var(--epr-category-navigation-button-size) * -4)'
133
- },
134
- '&.epr-icn-animals_nature': {
135
- backgroundPositionX:
136
- 'calc(var(--epr-category-navigation-button-size) * -1)'
137
- },
138
- '&.epr-icn-flags': {
139
- backgroundPositionX:
140
- 'calc(var(--epr-category-navigation-button-size) * -7)'
141
- },
142
- '&.epr-icn-food_drink': {
143
- backgroundPositionX:
144
- 'calc(var(--epr-category-navigation-button-size) * -2)'
145
- },
146
- '&.epr-icn-objects': {
147
- backgroundPositionX:
148
- 'calc(var(--epr-category-navigation-button-size) * -5)'
149
- },
150
- '&.epr-icn-smileys_people': {
151
- backgroundPositionX: '0px'
152
- },
153
- '&.epr-icn-symbols': {
154
- backgroundPositionX:
155
- 'calc(var(--epr-category-navigation-button-size) * -6)'
156
- },
157
- '&.epr-icn-travel_places': {
158
- backgroundPositionX:
159
- 'calc(var(--epr-category-navigation-button-size) * -3)'
160
- }
161
- },
162
- '.epr-dark-theme': {
163
- catBtn: {
164
- backgroundPositionY:
165
- 'calc(var(--epr-category-navigation-button-size) * 2)'
166
- },
167
- ':not(.epr-search-active)': {
168
- // @ts-expect-error - need to fix this
169
- catBtn: {
170
- ':hover': {
171
- backgroundPositionY:
172
- 'calc(var(--epr-category-navigation-button-size) * 3)'
173
- },
174
- '&.epr-active': {
175
- backgroundPositionY:
176
- 'calc(var(--epr-category-navigation-button-size) * 3)'
177
- }
178
- }
179
- }
180
- },
181
- '.epr-auto-theme': {
182
- catBtn: {
183
- '@media (prefers-color-scheme: dark)': {
184
- backgroundPositionY:
185
- 'calc(var(--epr-category-navigation-button-size) * 2)'
186
- }
187
- },
188
- ':not(.epr-search-active)': {
189
- catBtn: {
190
- '@media (prefers-color-scheme: dark)': {
191
- ':hover': {
192
- backgroundPositionY:
193
- 'calc(var(--epr-category-navigation-button-size) * 3)'
194
- },
195
- // @ts-ignore
196
- '&.epr-active': {
197
- backgroundPositionY:
198
- 'calc(var(--epr-category-navigation-button-size) * 3)'
199
- }
200
- }
201
- }
202
- }
203
84
  }
204
85
  });
@@ -1,5 +1,6 @@
1
- import * as React from 'react'
1
+ import * as React from 'react';
2
2
 
3
+ import { DEFAULT_REACTIONS } from '../components/Reactions/DEFAULT_REACTIONS';
3
4
  import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
4
5
  import {
5
6
  setCustomEmojis,
@@ -85,7 +86,9 @@ export function basePickerConfig(): PickerConfigInternal {
85
86
  suggestedEmojisMode: SuggestionMode.FREQUENT,
86
87
  theme: Theme.LIGHT,
87
88
  unicodeToHide: new Set<string>(KNOWN_FAILING_EMOJIS),
88
- width: 350
89
+ width: 350,
90
+ reactionsDefaultOpen: false,
91
+ reactions: DEFAULT_REACTIONS
89
92
  };
90
93
  }
91
94
 
@@ -111,6 +114,8 @@ export type PickerConfigInternal = {
111
114
  skinTonePickerLocation: SkinTonePickerLocation;
112
115
  unicodeToHide: Set<string>;
113
116
  customEmojis: CustomEmoji[];
117
+ reactionsDefaultOpen: boolean;
118
+ reactions: string[];
114
119
  };
115
120
 
116
121
  export type PreviewConfig = {
@@ -100,6 +100,11 @@ export function useStyleConfig(): React.CSSProperties {
100
100
  return { height: getDimension(height), width: getDimension(width), ...style };
101
101
  }
102
102
 
103
+ export function useReactionsOpenConfig(): boolean {
104
+ const { reactionsDefaultOpen } = usePickerConfig();
105
+ return reactionsDefaultOpen;
106
+ }
107
+
103
108
  export function useEmojiVersionConfig(): string | null {
104
109
  const { emojiVersion } = usePickerConfig();
105
110
  return emojiVersion;
@@ -120,6 +125,11 @@ export function useUnicodeToHide() {
120
125
  return unicodeToHide;
121
126
  }
122
127
 
128
+ export function useReactionsConfig(): string[] {
129
+ const { reactions } = usePickerConfig();
130
+ return reactions;
131
+ }
132
+
123
133
  export function useGetEmojiUrlConfig(): (
124
134
  unified: string,
125
135
  style: EmojiStyle
@@ -139,9 +149,12 @@ export function useSearchResultsConfig(searchResultsCount: number): string {
139
149
  const isPlural = searchResultsCount > 1;
140
150
 
141
151
  if (hasResults) {
142
- return isPlural ?
143
- SEARCH_RESULTS_MULTIPLE_RESULTS_FOUND.replace('%n', searchResultsCount.toString())
144
- : SEARCH_RESULTS_ONE_RESULT_FOUND;
152
+ return isPlural
153
+ ? SEARCH_RESULTS_MULTIPLE_RESULTS_FOUND.replace(
154
+ '%n',
155
+ searchResultsCount.toString()
156
+ )
157
+ : SEARCH_RESULTS_ONE_RESULT_FOUND;
145
158
  }
146
159
 
147
160
  return SEARCH_RESULTS_NO_RESULTS_FOUND;