emoji-picker-react 4.5.15 → 4.6.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.
- package/README.md +3 -1
- package/dist/components/header/CssSearch.d.ts +4 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/config/useConfig.d.ts +4 -5
- package/dist/emoji-picker-react.cjs.development.js +51 -43
- 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 +51 -43
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/EmojiPickerReact.tsx +2 -0
- package/src/components/header/CssSearch.tsx +45 -0
- package/src/components/header/Search.tsx +12 -42
- package/src/components/main/PickerMain.tsx +6 -10
- package/src/config/config.ts +6 -0
- package/src/config/useConfig.ts +10 -6
package/package.json
CHANGED
package/src/EmojiPickerReact.tsx
CHANGED
|
@@ -39,8 +39,10 @@ export default React.memo(EmojiPicker, (prev, next) => {
|
|
|
39
39
|
prev.theme === next.theme &&
|
|
40
40
|
prev.suggestedEmojisMode === next.suggestedEmojisMode &&
|
|
41
41
|
prev.lazyLoadEmojis === next.lazyLoadEmojis &&
|
|
42
|
+
prev.className === next.className &&
|
|
42
43
|
prev.height === next.height &&
|
|
43
44
|
prev.width === next.width &&
|
|
45
|
+
prev.style === next.style &&
|
|
44
46
|
prev.searchDisabled === next.searchDisabled &&
|
|
45
47
|
prev.skinTonePickerLocation === next.skinTonePickerLocation &&
|
|
46
48
|
prevCustomEmojis.length === nextCustomEmojis.length
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { ClassNames, asSelectors } from '../../DomUtils/classNames';
|
|
4
|
+
import { getNormalizedSearchTerm } from '../../hooks/useFilter';
|
|
5
|
+
|
|
6
|
+
const SCOPE = `${asSelectors(ClassNames.emojiPicker)} ${asSelectors(
|
|
7
|
+
ClassNames.emojiList
|
|
8
|
+
)}`;
|
|
9
|
+
|
|
10
|
+
const EMOJI_BUTTON = ['button', asSelectors(ClassNames.emoji)].join('');
|
|
11
|
+
const CATEGORY = asSelectors(ClassNames.category);
|
|
12
|
+
|
|
13
|
+
export function CssSearch({ value }: { value: undefined | string }) {
|
|
14
|
+
if (!value) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const q = genQuery(value);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<style>{`
|
|
22
|
+
${SCOPE} ${EMOJI_BUTTON} {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
${SCOPE} ${q} {
|
|
28
|
+
display: flex;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
${SCOPE} ${CATEGORY}:not(:has(${q})) {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
`}</style>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function genQuery(value: string): string {
|
|
39
|
+
return [
|
|
40
|
+
EMOJI_BUTTON,
|
|
41
|
+
'[data-full-name*="',
|
|
42
|
+
getNormalizedSearchTerm(value),
|
|
43
|
+
'"]'
|
|
44
|
+
].join('');
|
|
45
|
+
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { clsx } from '../../DomUtils/classNames';
|
|
5
5
|
import {
|
|
6
6
|
useAutoFocusSearchConfig,
|
|
7
7
|
useSearchDisabledConfig,
|
|
8
8
|
useSearchPlaceHolderConfig
|
|
9
9
|
} from '../../config/useConfig';
|
|
10
10
|
import { useCloseAllOpenToggles } from '../../hooks/useCloseAllOpenToggles';
|
|
11
|
-
import {
|
|
12
|
-
getNormalizedSearchTerm,
|
|
13
|
-
useClearSearch,
|
|
14
|
-
useFilter
|
|
15
|
-
} from '../../hooks/useFilter';
|
|
11
|
+
import { useClearSearch, useFilter } from '../../hooks/useFilter';
|
|
16
12
|
import { useIsSkinToneInSearch } from '../../hooks/useShouldShowSkinTonePicker';
|
|
17
13
|
import Flex from '../Layout/Flex';
|
|
18
14
|
import Relative from '../Layout/Relative';
|
|
@@ -20,6 +16,7 @@ import { Button } from '../atoms/Button';
|
|
|
20
16
|
import { useSearchInputRef } from '../context/ElementRefContext';
|
|
21
17
|
|
|
22
18
|
import './Search.css';
|
|
19
|
+
import { CssSearch } from './CssSearch';
|
|
23
20
|
import { SkinTonePicker } from './SkinTonePicker';
|
|
24
21
|
|
|
25
22
|
export function SearchContainer() {
|
|
@@ -62,7 +59,7 @@ export function Search() {
|
|
|
62
59
|
onFocus={closeAllOpenToggles}
|
|
63
60
|
className="epr-search"
|
|
64
61
|
type="text"
|
|
65
|
-
aria-controls=
|
|
62
|
+
aria-controls="epr-search-id"
|
|
66
63
|
placeholder={placeholder}
|
|
67
64
|
onChange={event => {
|
|
68
65
|
setInc(inc + 1);
|
|
@@ -74,11 +71,14 @@ export function Search() {
|
|
|
74
71
|
/>
|
|
75
72
|
{searchTerm ? (
|
|
76
73
|
<div
|
|
77
|
-
role=
|
|
78
|
-
className={clsx(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
role="status"
|
|
75
|
+
className={clsx(
|
|
76
|
+
'epr-status-search-results',
|
|
77
|
+
'epr-status-visually-hidden'
|
|
78
|
+
)}
|
|
79
|
+
aria-live="polite"
|
|
80
|
+
id="epr-search-id"
|
|
81
|
+
aria-atomic="true"
|
|
82
82
|
>
|
|
83
83
|
{statusSearchResults}
|
|
84
84
|
</div>
|
|
@@ -93,33 +93,3 @@ export function Search() {
|
|
|
93
93
|
</Relative>
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
const CSS_SEARCH_SELECTOR = `${asSelectors(
|
|
98
|
-
ClassNames.emojiPicker
|
|
99
|
-
)} ${asSelectors(ClassNames.emojiList)}`;
|
|
100
|
-
|
|
101
|
-
function CssSearch({ value }: { value: undefined | string }) {
|
|
102
|
-
if (!value) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const searchQuery = `button[data-full-name*="${getNormalizedSearchTerm(
|
|
107
|
-
value
|
|
108
|
-
)}"]`;
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<style>{`
|
|
112
|
-
${CSS_SEARCH_SELECTOR} ${asSelectors(
|
|
113
|
-
ClassNames.category
|
|
114
|
-
)}:not(:has(${searchQuery})) {
|
|
115
|
-
display: none;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
${CSS_SEARCH_SELECTOR} button${asSelectors(
|
|
119
|
-
ClassNames.emoji
|
|
120
|
-
)}:not(${searchQuery}) {
|
|
121
|
-
display: none;
|
|
122
|
-
}
|
|
123
|
-
`}</style>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { ClassNames, clsx } from '../../DomUtils/classNames';
|
|
4
|
-
import {
|
|
4
|
+
import { useClassNameConfig, useStyleConfig, useThemeConfig } from '../../config/useConfig';
|
|
5
5
|
import useIsSearchMode from '../../hooks/useIsSearchMode';
|
|
6
6
|
import { useKeyboardNavigation } from '../../hooks/useKeyboardNavigation';
|
|
7
7
|
import { useOnFocus } from '../../hooks/useOnFocus';
|
|
@@ -23,6 +23,8 @@ export default function PickerMain({ children }: Props) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
type RootProps = Readonly<{
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: React.CSSProperties;
|
|
26
28
|
children: React.ReactNode;
|
|
27
29
|
}>;
|
|
28
30
|
|
|
@@ -30,25 +32,19 @@ function PickerRootElement({ children }: RootProps) {
|
|
|
30
32
|
const theme = useThemeConfig();
|
|
31
33
|
const searchModeActive = useIsSearchMode();
|
|
32
34
|
const PickerMainRef = usePickerMainRef();
|
|
33
|
-
const
|
|
35
|
+
const className = useClassNameConfig();
|
|
36
|
+
const style = useStyleConfig();
|
|
34
37
|
|
|
35
38
|
useKeyboardNavigation();
|
|
36
39
|
useOnFocus();
|
|
37
40
|
|
|
38
|
-
const style = {
|
|
39
|
-
height,
|
|
40
|
-
width
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
41
|
return (
|
|
46
42
|
<aside
|
|
47
43
|
className={clsx(ClassNames.emojiPicker, 'epr-main', {
|
|
48
44
|
[ClassNames.searchActive]: searchModeActive,
|
|
49
45
|
[ClassNames.darkTheme]: theme === Theme.DARK,
|
|
50
46
|
[ClassNames.autoTheme]: theme === Theme.AUTO
|
|
51
|
-
})}
|
|
47
|
+
}, className)}
|
|
52
48
|
ref={PickerMainRef}
|
|
53
49
|
style={style}
|
|
54
50
|
>
|
package/src/config/config.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
1
3
|
import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
|
|
2
4
|
import {
|
|
3
5
|
setCustomEmojis,
|
|
@@ -63,6 +65,7 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
63
65
|
return {
|
|
64
66
|
autoFocusSearch: true,
|
|
65
67
|
categories: baseCategoriesConfig(),
|
|
68
|
+
className: '',
|
|
66
69
|
customEmojis: [],
|
|
67
70
|
defaultSkinTone: SkinTones.NEUTRAL,
|
|
68
71
|
emojiStyle: EmojiStyle.APPLE,
|
|
@@ -78,6 +81,7 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
78
81
|
searchPlaceholder: DEFAULT_SEARCH_PLACEHOLDER,
|
|
79
82
|
skinTonePickerLocation: SkinTonePickerLocation.SEARCH,
|
|
80
83
|
skinTonesDisabled: false,
|
|
84
|
+
style: {},
|
|
81
85
|
suggestedEmojisMode: SuggestionMode.FREQUENT,
|
|
82
86
|
theme: Theme.LIGHT,
|
|
83
87
|
unicodeToHide: new Set<string>(KNOWN_FAILING_EMOJIS),
|
|
@@ -98,8 +102,10 @@ export type PickerConfigInternal = {
|
|
|
98
102
|
suggestedEmojisMode: SuggestionMode;
|
|
99
103
|
lazyLoadEmojis: boolean;
|
|
100
104
|
previewConfig: PreviewConfig;
|
|
105
|
+
className: string;
|
|
101
106
|
height: PickerDimensions;
|
|
102
107
|
width: PickerDimensions;
|
|
108
|
+
style: React.CSSProperties;
|
|
103
109
|
getEmojiUrl: GetEmojiUrl;
|
|
104
110
|
searchDisabled: boolean;
|
|
105
111
|
skinTonePickerLocation: SkinTonePickerLocation;
|
package/src/config/useConfig.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
1
3
|
import { usePickerConfig } from '../components/context/PickerConfigContext';
|
|
2
4
|
import {
|
|
3
5
|
EmojiClickData,
|
|
@@ -88,12 +90,14 @@ export function useLazyLoadEmojisConfig(): boolean {
|
|
|
88
90
|
return lazyLoadEmojis;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
export function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
export function useClassNameConfig(): string {
|
|
94
|
+
const { className } = usePickerConfig();
|
|
95
|
+
return className;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function useStyleConfig(): React.CSSProperties {
|
|
99
|
+
const { height, width, style } = usePickerConfig();
|
|
100
|
+
return { height: getDimension(height), width: getDimension(width), ...style };
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
export function useEmojiVersionConfig(): string | null {
|