emoji-picker-react 4.5.4 → 4.5.6

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.5.4",
2
+ "version": "4.5.6",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -16,7 +16,9 @@ export enum ClassNames {
16
16
  open = 'epr-open',
17
17
  vertical = 'epr-vertical',
18
18
  horizontal = 'epr-horizontal',
19
- variationPicker = 'epr-emoji-variation-picker'
19
+ variationPicker = 'epr-emoji-variation-picker',
20
+ darkTheme = 'epr-dark-theme',
21
+ autoTheme = 'epr-auto-theme'
20
22
  }
21
23
 
22
24
  export function asSelectors(...classNames: ClassNames[]): string {
@@ -71,21 +71,78 @@
71
71
  --epr-preview-z-index: 6;
72
72
  }
73
73
 
74
- .EmojiPickerReact.epr-dark-theme {
74
+ .EmojiPickerReact {
75
+ /* Dark Theme Variables */
75
76
  --epr-dark: #000;
76
- --epr-emoji-variation-picker-bg-color: var(--epr-dark);
77
- --epr-highlight-color: #c0c0c0;
78
- --epr-text-color: var(--epr-highlight-color);
79
- --epr-hover-bg-color: #363636f6;
80
- --epr-focus-bg-color: #474747;
81
- --epr-search-input-bg-color: #333333;
82
- --epr-category-label-bg-color: #222222e6;
83
- --epr-picker-border-color: #151617;
84
- --epr-bg-color: #222222;
85
- --epr-search-input-bg-color-active: var(--epr-dark);
86
- --epr-emoji-variation-indicator-color: #444;
87
- --epr-category-icon-active-color: #3271b7;
88
- --epr-skin-tone-picker-menu-color: #22222295;
77
+ --epr-dark-emoji-variation-picker-bg-color: var(--epr-dark);
78
+ --epr-dark-highlight-color: #c0c0c0;
79
+ --epr-dark-text-color: var(--epr-highlight-color);
80
+ --epr-dark-hover-bg-color: #363636f6;
81
+ --epr-dark-focus-bg-color: #474747;
82
+ --epr-dark-search-input-bg-color: #333333;
83
+ --epr-dark-category-label-bg-color: #222222e6;
84
+ --epr-dark-picker-border-color: #151617;
85
+ --epr-dark-bg-color: #222222;
86
+ --epr-dark-search-input-bg-color-active: var(--epr-dark);
87
+ --epr-dark-emoji-variation-indicator-color: #444;
88
+ --epr-dark-category-icon-active-color: #3271b7;
89
+ --epr-dark-skin-tone-picker-menu-color: #22222295;
90
+ }
91
+
92
+ @media (prefers-color-scheme: dark) {
93
+ /* Keep in sync with the section below */
94
+ .EmojiPickerReact.epr-auto-theme {
95
+ --epr-dark: var(--epr-dark-dark);
96
+ --epr-emoji-variation-picker-bg-color: var(
97
+ --epr-dark-emoji-variation-picker-bg-color
98
+ );
99
+ --epr-highlight-color: var(--epr-dark-highlight-color);
100
+ --epr-text-color: var(--epr-dark-text-color);
101
+ --epr-hover-bg-color: var(--epr-dark-hover-bg-color);
102
+ --epr-focus-bg-color: var(--epr-dark-focus-bg-color);
103
+ --epr-search-input-bg-color: var(--epr-dark-search-input-bg-color);
104
+ --epr-category-label-bg-color: var(--epr-dark-category-label-bg-color);
105
+ --epr-picker-border-color: var(--epr-dark-picker-border-color);
106
+ --epr-bg-color: var(--epr-dark-bg-color);
107
+ --epr-search-input-bg-color-active: var(
108
+ --epr-dark-search-input-bg-color-active
109
+ );
110
+ --epr-emoji-variation-indicator-color: var(
111
+ --epr-dark-emoji-variation-indicator-color
112
+ );
113
+ --epr-category-icon-active-color: var(
114
+ --epr-dark-category-icon-active-color
115
+ );
116
+ --epr-skin-tone-picker-menu-color: var(
117
+ --epr-dark-skin-tone-picker-menu-color
118
+ );
119
+ }
120
+ }
121
+
122
+ .EmojiPickerReact.epr-dark-theme {
123
+ /* Keep in sync with the section above */
124
+ --epr-dark: var(--epr-dark-dark);
125
+ --epr-emoji-variation-picker-bg-color: var(
126
+ --epr-dark-emoji-variation-picker-bg-color
127
+ );
128
+ --epr-highlight-color: var(--epr-dark-highlight-color);
129
+ --epr-text-color: var(--epr-dark-text-color);
130
+ --epr-hover-bg-color: var(--epr-dark-hover-bg-color);
131
+ --epr-focus-bg-color: var(--epr-dark-focus-bg-color);
132
+ --epr-search-input-bg-color: var(--epr-dark-search-input-bg-color);
133
+ --epr-category-label-bg-color: var(--epr-dark-category-label-bg-color);
134
+ --epr-picker-border-color: var(--epr-dark-picker-border-color);
135
+ --epr-bg-color: var(--epr-dark-bg-color);
136
+ --epr-search-input-bg-color-active: var(
137
+ --epr-dark-search-input-bg-color-active
138
+ );
139
+ --epr-emoji-variation-indicator-color: var(
140
+ --epr-dark-emoji-variation-indicator-color
141
+ );
142
+ --epr-category-icon-active-color: var(--epr-dark-category-icon-active-color);
143
+ --epr-skin-tone-picker-menu-color: var(
144
+ --epr-dark-skin-tone-picker-menu-color
145
+ );
89
146
  }
90
147
 
91
148
  .EmojiPickerReact {
@@ -29,10 +29,11 @@ import './EmojiList.css';
29
29
 
30
30
  export function EmojiList() {
31
31
  const categories = useCategoriesConfig();
32
+ const renderdCategoriesCountRef = React.useRef(0);
32
33
 
33
34
  return (
34
35
  <ul className={ClassNames.emojiList}>
35
- {categories.map((categoryConfig, index) => {
36
+ {categories.map(categoryConfig => {
36
37
  const category = categoryFromCategoryConfig(categoryConfig);
37
38
 
38
39
  if (category === Categories.SUGGESTED) {
@@ -42,9 +43,9 @@ export function EmojiList() {
42
43
  return (
43
44
  <RenderCategory
44
45
  key={category}
45
- index={index}
46
46
  category={category}
47
47
  categoryConfig={categoryConfig}
48
+ renderdCategoriesCountRef={renderdCategoriesCountRef}
48
49
  />
49
50
  );
50
51
  })}
@@ -53,13 +54,13 @@ export function EmojiList() {
53
54
  }
54
55
 
55
56
  function RenderCategory({
56
- index,
57
57
  category,
58
- categoryConfig
58
+ categoryConfig,
59
+ renderdCategoriesCountRef
59
60
  }: {
60
- index: number;
61
61
  category: Categories;
62
62
  categoryConfig: CategoryConfig;
63
+ renderdCategoriesCountRef: React.MutableRefObject<number>;
63
64
  }) {
64
65
  const isEmojiHidden = useIsEmojiHidden();
65
66
  const lazyLoadEmojis = useLazyLoadEmojisConfig();
@@ -73,7 +74,13 @@ function RenderCategory({
73
74
  // Small trick to defer the rendering of all emoji categories until the first category is visible
74
75
  // This way the user gets to actually see something and not wait for the whole picker to render.
75
76
  const emojisToPush =
76
- !isPastInitialLoad && index > 1 ? [] : emojisByCategory(category);
77
+ !isPastInitialLoad && renderdCategoriesCountRef.current > 0
78
+ ? []
79
+ : emojisByCategory(category);
80
+
81
+ if (emojisToPush.length > 0) {
82
+ renderdCategoriesCountRef.current++;
83
+ }
77
84
 
78
85
  let hiddenCounter = 0;
79
86
 
@@ -40,11 +40,14 @@ function PickerRootElement({ children }: RootProps) {
40
40
  width
41
41
  };
42
42
 
43
+
44
+
43
45
  return (
44
46
  <aside
45
47
  className={clsx(ClassNames.emojiPicker, 'epr-main', {
46
48
  [ClassNames.searchActive]: searchModeActive,
47
- 'epr-dark-theme': theme === Theme.DARK
49
+ [ClassNames.darkTheme]: theme === Theme.DARK,
50
+ [ClassNames.autoTheme]: theme === Theme.AUTO
48
51
  })}
49
52
  ref={PickerMainRef}
50
53
  style={style}
@@ -1,4 +1,3 @@
1
- import { isSystemDarkTheme } from '../DomUtils/isDarkTheme';
2
1
  import { usePickerConfig } from '../components/context/PickerConfigContext';
3
2
  import {
4
3
  EmojiClickData,
@@ -73,10 +72,6 @@ export function usePreviewConfig(): PreviewConfig {
73
72
  export function useThemeConfig(): Theme {
74
73
  const { theme } = usePickerConfig();
75
74
 
76
- if (theme === Theme.AUTO) {
77
- return isSystemDarkTheme() ? Theme.DARK : Theme.LIGHT;
78
- }
79
-
80
75
  return theme;
81
76
  }
82
77
 
@@ -1 +0,0 @@
1
- export declare function isSystemDarkTheme(): boolean;
@@ -1,7 +0,0 @@
1
- export function isSystemDarkTheme(): boolean {
2
- if (typeof window === 'undefined') {
3
- return false;
4
- }
5
-
6
- return !!window.matchMedia('(prefers-color-scheme: dark)').matches;
7
- }