emoji-picker-react 4.13.1 → 4.13.3
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/README.md +15 -15
- package/dist/config/config.d.ts +1 -1
- package/dist/emoji-picker-react.cjs.development.js +34 -18
- 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 +34 -18
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/globals/doesBrowserSupportCssHas.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/header/Search/Search.tsx +1 -3
- package/src/config/config.ts +10 -10
- package/src/globals/doesBrowserSupportCssHas.ts +16 -0
- package/src/hooks/useFilter.ts +24 -17
package/package.json
CHANGED
package/src/config/config.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { DEFAULT_REACTIONS } from '../components/Reactions/DEFAULT_REACTIONS';
|
|
|
4
4
|
import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
|
|
5
5
|
import {
|
|
6
6
|
setCustomEmojis,
|
|
7
|
-
emojiUrlByUnified
|
|
7
|
+
emojiUrlByUnified,
|
|
8
8
|
} from '../dataUtils/emojiSelectors';
|
|
9
9
|
import {
|
|
10
10
|
EmojiClickData,
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
SkinTonePickerLocation,
|
|
13
13
|
SkinTones,
|
|
14
14
|
SuggestionMode,
|
|
15
|
-
Theme
|
|
15
|
+
Theme,
|
|
16
16
|
} from '../types/exposedTypes';
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
CategoriesConfig,
|
|
20
20
|
baseCategoriesConfig,
|
|
21
|
-
mergeCategoriesConfig
|
|
21
|
+
mergeCategoriesConfig,
|
|
22
22
|
} from './categoryConfig';
|
|
23
23
|
import { CustomEmoji } from './customEmojiConfig';
|
|
24
24
|
|
|
@@ -45,10 +45,10 @@ export function mergeConfig(
|
|
|
45
45
|
const config = Object.assign(base, userConfig);
|
|
46
46
|
|
|
47
47
|
const categories = mergeCategoriesConfig(userConfig.categories, {
|
|
48
|
-
suggestionMode: config.suggestedEmojisMode
|
|
48
|
+
suggestionMode: config.suggestedEmojisMode,
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
config.hiddenEmojis.forEach(emoji => {
|
|
51
|
+
config.hiddenEmojis.forEach((emoji) => {
|
|
52
52
|
config.unicodeToHide.add(emoji);
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ export function mergeConfig(
|
|
|
62
62
|
...config,
|
|
63
63
|
categories,
|
|
64
64
|
previewConfig,
|
|
65
|
-
skinTonePickerLocation
|
|
65
|
+
skinTonePickerLocation,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -79,7 +79,7 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
79
79
|
height: 450,
|
|
80
80
|
lazyLoadEmojis: false,
|
|
81
81
|
previewConfig: {
|
|
82
|
-
...basePreviewConfig
|
|
82
|
+
...basePreviewConfig,
|
|
83
83
|
},
|
|
84
84
|
searchDisabled: false,
|
|
85
85
|
searchPlaceHolder: DEFAULT_SEARCH_PLACEHOLDER,
|
|
@@ -95,7 +95,7 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
95
95
|
reactions: DEFAULT_REACTIONS,
|
|
96
96
|
open: true,
|
|
97
97
|
allowExpandReactions: true,
|
|
98
|
-
hiddenEmojis: []
|
|
98
|
+
hiddenEmojis: [],
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -137,7 +137,7 @@ export type PreviewConfig = {
|
|
|
137
137
|
const basePreviewConfig: PreviewConfig = {
|
|
138
138
|
defaultEmoji: '1f60a',
|
|
139
139
|
defaultCaption: "What's your mood?",
|
|
140
|
-
showPreview: true
|
|
140
|
+
showPreview: true,
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
type ConfigExternal = {
|
|
@@ -154,7 +154,7 @@ export type PickerDimensions = string | number;
|
|
|
154
154
|
export type MouseDownEvent = (
|
|
155
155
|
emoji: EmojiClickData,
|
|
156
156
|
event: MouseEvent,
|
|
157
|
-
api
|
|
157
|
+
api?: OnEmojiClickApi
|
|
158
158
|
) => void;
|
|
159
159
|
export type OnSkinToneChange = (emoji: SkinTones) => void;
|
|
160
160
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function doesBrowserSupportCssHas(): boolean {
|
|
2
|
+
// if env is not browser:
|
|
3
|
+
if (typeof window === 'undefined' || typeof window.CSS === 'undefined') {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
return CSS.supports('selector(:has(*))');
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const browserSupportsCssHas = doesBrowserSupportCssHas();
|
|
15
|
+
|
|
16
|
+
export default browserSupportsCssHas;
|
package/src/hooks/useFilter.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { useSearchResultsConfig } from '../config/useConfig';
|
|
12
12
|
import { DataEmoji } from '../dataUtils/DataTypes';
|
|
13
13
|
import { emojiNames } from '../dataUtils/emojiSelectors';
|
|
14
|
+
import doesBrowserSupportCssHas from '../globals/doesBrowserSupportCssHas';
|
|
14
15
|
|
|
15
16
|
import { useFocusSearchInput } from './useFocus';
|
|
16
17
|
|
|
@@ -77,28 +78,34 @@ export function useFilter() {
|
|
|
77
78
|
};
|
|
78
79
|
|
|
79
80
|
function onChange(inputValue: string) {
|
|
80
|
-
|
|
81
|
+
if (doesBrowserSupportCssHas) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
const filter = filterRef.current;
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
return applySearch(nextValue);
|
|
86
|
-
}
|
|
88
|
+
const nextValue = inputValue.toLowerCase();
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
if (filter?.[nextValue] || nextValue.length <= 1) {
|
|
91
|
+
return applySearch(nextValue);
|
|
92
|
+
}
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
// Can we even get here?
|
|
92
|
-
// If so, we need to search among all emojis
|
|
93
|
-
return applySearch(nextValue);
|
|
94
|
-
}
|
|
94
|
+
const longestMatch = findLongestMatch(nextValue, filter);
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
if (!longestMatch) {
|
|
97
|
+
// Can we even get here?
|
|
98
|
+
// If so, we need to search among all emojis
|
|
99
|
+
return applySearch(nextValue);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setFilterRef(current =>
|
|
103
|
+
Object.assign(current, {
|
|
104
|
+
[nextValue]: filterEmojiObjectByKeyword(longestMatch, nextValue)
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
applySearch(nextValue);
|
|
108
|
+
});
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
|