emoji-picker-react 4.5.3 → 4.5.5
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/dist/DomUtils/classNames.d.ts +1 -0
- package/dist/emoji-picker-react.cjs.development.js +42 -8
- package/dist/emoji-picker-react.cjs.development.js.map +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
- package/dist/emoji-picker-react.esm.js +42 -8
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -4
- package/src/DomUtils/classNames.ts +24 -0
- package/src/components/Layout/Flex.tsx +2 -1
- package/src/components/Layout/Space.tsx +2 -1
- package/src/components/atoms/Button.tsx +2 -1
- package/src/components/body/EmojiCategory.tsx +1 -2
- package/src/components/body/EmojiList.tsx +13 -6
- package/src/components/body/EmojiVariationPicker.tsx +1 -2
- package/src/components/emoji/ClickableEmojiButton.tsx +1 -2
- package/src/components/emoji/EmojiImg.tsx +1 -2
- package/src/components/emoji/NativeEmoji.tsx +1 -2
- package/src/components/header/Search.tsx +1 -2
- package/src/components/header/SkinTonePicker.tsx +1 -2
- package/src/components/main/PickerMain.tsx +1 -2
- package/src/components/navigation/CategoryNavigation.tsx +1 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.5.
|
|
2
|
+
"version": "4.5.5",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -96,8 +96,5 @@
|
|
|
96
96
|
"tsdx": "^0.14.1",
|
|
97
97
|
"tslib": "^2.4.0",
|
|
98
98
|
"typescript": "^4.7.4"
|
|
99
|
-
},
|
|
100
|
-
"dependencies": {
|
|
101
|
-
"clsx": "^1.2.1"
|
|
102
99
|
}
|
|
103
100
|
}
|
|
@@ -22,3 +22,27 @@ export enum ClassNames {
|
|
|
22
22
|
export function asSelectors(...classNames: ClassNames[]): string {
|
|
23
23
|
return classNames.map(c => `.${c}`).join('');
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
export function clsx(...args: any[]): string {
|
|
27
|
+
const classes = args.reduce((classes, arg) => {
|
|
28
|
+
if (typeof arg === 'string') {
|
|
29
|
+
classes.push(arg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (Array.isArray(arg)) {
|
|
33
|
+
classes.push(clsx(...arg));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof arg === 'object') {
|
|
37
|
+
Object.entries(arg).forEach(([key, value]) => {
|
|
38
|
+
if (value) {
|
|
39
|
+
classes.push(key);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return classes;
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return classes.filter(Boolean).join(' ');
|
|
48
|
+
}
|
|
@@ -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(
|
|
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 &&
|
|
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
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { useEffect } from 'react';
|
|
4
3
|
|
|
5
|
-
import { ClassNames } from '../../DomUtils/classNames';
|
|
4
|
+
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
6
5
|
import { focusFirstVisibleEmoji } from '../../DomUtils/keyboardNavigation';
|
|
7
6
|
import {
|
|
8
7
|
buttonFromTarget,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
|
-
import { ClassNames } from '../../DomUtils/classNames';
|
|
3
|
+
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
5
4
|
import { EmojiStyle } from '../../types/exposedTypes';
|
|
6
5
|
|
|
7
6
|
export function EmojiImg({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
|
-
import { ClassNames } from '../../DomUtils/classNames';
|
|
3
|
+
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
5
4
|
import { parseNativeEmoji } from '../../dataUtils/parseNativeEmoji';
|
|
6
5
|
|
|
7
6
|
export function NativeEmoji({
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { useState } from 'react';
|
|
4
3
|
|
|
5
|
-
import { asSelectors, ClassNames } from '../../DomUtils/classNames';
|
|
4
|
+
import { asSelectors, ClassNames, clsx } from '../../DomUtils/classNames';
|
|
6
5
|
import {
|
|
7
6
|
useAutoFocusSearchConfig,
|
|
8
7
|
useSearchDisabledConfig,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
|
-
import { ClassNames } from '../../DomUtils/classNames';
|
|
3
|
+
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
5
4
|
import { useSkinTonesDisabledConfig } from '../../config/useConfig';
|
|
6
5
|
import skinToneVariations, {
|
|
7
6
|
skinTonesNamed
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
|
-
import { ClassNames } from '../../DomUtils/classNames';
|
|
3
|
+
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
5
4
|
import { usePickerSizeConfig, useThemeConfig } from '../../config/useConfig';
|
|
6
5
|
import useIsSearchMode from '../../hooks/useIsSearchMode';
|
|
7
6
|
import { useKeyboardNavigation } from '../../hooks/useKeyboardNavigation';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { useState } from 'react';
|
|
4
3
|
import './CategoryNavigation.css';
|
|
5
4
|
|
|
6
|
-
import { ClassNames } from '../../DomUtils/classNames';
|
|
5
|
+
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
7
6
|
import {
|
|
8
7
|
categoryFromCategoryConfig,
|
|
9
8
|
categoryNameFromCategoryConfig
|