emoji-picker-react 4.2.0 → 4.4.0-rc.1
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 +24 -20
- package/dist/config/config.d.ts +5 -2
- package/dist/config/useConfig.d.ts +5 -3
- package/dist/emoji-picker-react.cjs.development.js +32 -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 +32 -8
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/predicates/isFunction.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/main/PickerMain.tsx +3 -3
- package/src/config/config.ts +14 -9
- package/src/config/useConfig.ts +21 -4
- package/src/hooks/useDisallowedEmojis.ts +17 -4
- package/src/hooks/useFilter.ts +10 -9
- package/src/predicates/isFunction.ts +5 -0
package/README.md
CHANGED
|
@@ -43,22 +43,22 @@ function App() {
|
|
|
43
43
|
|
|
44
44
|
The following props are accepted by them picker:
|
|
45
45
|
|
|
46
|
-
| Prop | Type
|
|
47
|
-
| ------------------- |
|
|
48
|
-
| onEmojiClick | function
|
|
49
|
-
| autoFocusSearch | boolean
|
|
50
|
-
| Theme | string
|
|
51
|
-
| emojiStyle | string
|
|
52
|
-
| defaultSkinTone | string
|
|
53
|
-
| lazyLoadEmojis | boolean
|
|
54
|
-
| previewConfig | object
|
|
55
|
-
| searchPlaceholder | string
|
|
56
|
-
| suggestedEmojisMode | string
|
|
57
|
-
| skinTonesDisabled | boolean
|
|
58
|
-
| `width` | number
|
|
59
|
-
| emojiVersion | `string`
|
|
60
|
-
| `height` | number
|
|
61
|
-
| getEmojiUrl | `Function`
|
|
46
|
+
| Prop | Type | Default | Description |
|
|
47
|
+
| ------------------- | ----------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
48
|
+
| onEmojiClick | function | | Callback function that is called when an emoji is clicked. The function receives the emoji object as a parameter. |
|
|
49
|
+
| autoFocusSearch | boolean | `true` | Controls the auto focus of the search input. |
|
|
50
|
+
| Theme | string | `light` | Controls the theme of the picker. Possible values are `light`, `dark` and `auto`. |
|
|
51
|
+
| emojiStyle | string | `apple` | Controls the emoji style. Possible values are `google`, `apple`, `facebook`, `twitter` and `native`. |
|
|
52
|
+
| defaultSkinTone | string | `neutral` | Controls the default skin tone. |
|
|
53
|
+
| lazyLoadEmojis | boolean | `false` | Controls whether the emojis are loaded lazily or not. |
|
|
54
|
+
| previewConfig | object | `{}` | Controls the preview of the emoji. See below for more information. |
|
|
55
|
+
| searchPlaceholder | string | `Search` | Controls the placeholder of the search input. |
|
|
56
|
+
| suggestedEmojisMode | string | `frequent` | Controls the suggested emojis mode. Possible values are `frequent` and `recent`. |
|
|
57
|
+
| skinTonesDisabled | boolean | `false` | Controls whether the skin tones are disabled or not. |
|
|
58
|
+
| `width` | `number`/`string` | `350` | Controls the width of the picker. You can provide a number that will be treated as pixel size, or your any accepted css width as string. |
|
|
59
|
+
| emojiVersion | `string` | - | Allows displaying emojis up to a certain version for compatibility. |
|
|
60
|
+
| `height` | `number`/`string` | `450` | Controls the height of the picker. You can provide a number that will be treated as pixel size, or your any accepted css height as string. |
|
|
61
|
+
| getEmojiUrl | `Function` | - | Allows to customize the emoji url and provide your own image host. |
|
|
62
62
|
|
|
63
63
|
## Full details
|
|
64
64
|
|
|
@@ -141,12 +141,12 @@ import { SkinTones } from 'emoji-picker-react';
|
|
|
141
141
|
[
|
|
142
142
|
{
|
|
143
143
|
category: 'suggested',
|
|
144
|
-
name: 'Recently Used'
|
|
144
|
+
name: 'Recently Used'
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
category: 'smileys_people',
|
|
148
|
-
name: 'Faces...'
|
|
149
|
-
}
|
|
148
|
+
name: 'Faces...'
|
|
149
|
+
}
|
|
150
150
|
];
|
|
151
151
|
```
|
|
152
152
|
|
|
@@ -171,12 +171,16 @@ import { SkinTones } from 'emoji-picker-react';
|
|
|
171
171
|
|
|
172
172
|
## Custom Picker Width and Height
|
|
173
173
|
|
|
174
|
-
To customize the dimensions of the picker, use the `height` and `width` props
|
|
174
|
+
To customize the dimensions of the picker, use the `height` and `width` props. You can pass in a number that will be treated as pixel size, or your any accepted css width/height as string.
|
|
175
175
|
|
|
176
176
|
```jsx
|
|
177
177
|
<EmojiPicker height={500} width={400} />
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
+
```jsx
|
|
181
|
+
<EmojiPicker height="100%" width="15em" />
|
|
182
|
+
```
|
|
183
|
+
|
|
180
184
|
## CSS Variables
|
|
181
185
|
|
|
182
186
|
The picker can be customized via css variables. The root selector for the picker is `.EmojiPickerReact`, when overriding, make sure to provide a more specific selector.
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GetEmojiUrl } from '../components/emoji/Emoji';
|
|
2
|
+
import { DataEmoji } from '../dataUtils/DataTypes';
|
|
2
3
|
import { EmojiClickData, EmojiStyle, SkinTones, SuggestionMode, Theme } from '../types/exposedTypes';
|
|
3
4
|
import { CategoriesConfig } from './categoryConfig';
|
|
4
5
|
export declare function mergeConfig(userConfig?: PickerConfig): PickerConfigInternal;
|
|
@@ -16,9 +17,10 @@ export declare type PickerConfigInternal = {
|
|
|
16
17
|
suggestedEmojisMode: SuggestionMode;
|
|
17
18
|
lazyLoadEmojis: boolean;
|
|
18
19
|
previewConfig: PreviewConfig;
|
|
19
|
-
height:
|
|
20
|
-
width:
|
|
20
|
+
height: PickerDimensions;
|
|
21
|
+
width: PickerDimensions;
|
|
21
22
|
getEmojiUrl: GetEmojiUrl;
|
|
23
|
+
showEmoji: undefined | ((emoji: DataEmoji) => boolean);
|
|
22
24
|
};
|
|
23
25
|
export declare type PreviewConfig = {
|
|
24
26
|
defaultEmoji: string;
|
|
@@ -29,4 +31,5 @@ declare type ConfigExternal = {
|
|
|
29
31
|
previewConfig: Partial<PreviewConfig>;
|
|
30
32
|
} & Omit<PickerConfigInternal, 'previewConfig'>;
|
|
31
33
|
export declare type PickerConfig = Partial<ConfigExternal>;
|
|
34
|
+
export declare type PickerDimensions = string | number;
|
|
32
35
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { DataEmoji } from '../dataUtils/DataTypes';
|
|
1
2
|
import { EmojiClickData, EmojiStyle, SkinTones, SuggestionMode, Theme } from '../types/exposedTypes';
|
|
2
3
|
import { CategoriesConfig } from './categoryConfig';
|
|
3
|
-
import { PreviewConfig } from './config';
|
|
4
|
+
import { PickerDimensions, PreviewConfig } from './config';
|
|
4
5
|
export declare function useSearchPlaceHolderConfig(): string;
|
|
5
6
|
export declare function useDefaultSkinToneConfig(): SkinTones;
|
|
6
7
|
export declare function useSkinTonesDisabledConfig(): boolean;
|
|
@@ -13,8 +14,9 @@ export declare function useThemeConfig(): Theme;
|
|
|
13
14
|
export declare function useSuggestedEmojisModeConfig(): SuggestionMode;
|
|
14
15
|
export declare function useLazyLoadEmojisConfig(): boolean;
|
|
15
16
|
export declare function usePickerSizeConfig(): {
|
|
16
|
-
height:
|
|
17
|
-
width:
|
|
17
|
+
height: PickerDimensions;
|
|
18
|
+
width: PickerDimensions;
|
|
18
19
|
};
|
|
19
20
|
export declare function useEmojiVersionConfig(): string | null;
|
|
20
21
|
export declare function useGetEmojiUrlConfig(): (unified: string, style: EmojiStyle) => string;
|
|
22
|
+
export declare function useShowEmojiConfig(): undefined | ((emoji: DataEmoji) => boolean);
|
|
@@ -16799,6 +16799,7 @@ function basePickerConfig() {
|
|
|
16799
16799
|
event) {},
|
|
16800
16800
|
previewConfig: _extends({}, basePreviewConfig),
|
|
16801
16801
|
searchPlaceHolder: 'Search',
|
|
16802
|
+
showEmoji: undefined,
|
|
16802
16803
|
skinTonesDisabled: false,
|
|
16803
16804
|
suggestedEmojisMode: exports.SuggestionMode.FREQUENT,
|
|
16804
16805
|
theme: exports.Theme.LIGHT,
|
|
@@ -16901,8 +16902,8 @@ function usePickerSizeConfig() {
|
|
|
16901
16902
|
width = _usePickerConfig12.width;
|
|
16902
16903
|
|
|
16903
16904
|
return {
|
|
16904
|
-
height: height,
|
|
16905
|
-
width: width
|
|
16905
|
+
height: getDimension(height),
|
|
16906
|
+
width: getDimension(width)
|
|
16906
16907
|
};
|
|
16907
16908
|
}
|
|
16908
16909
|
function useEmojiVersionConfig() {
|
|
@@ -16917,6 +16918,16 @@ function useGetEmojiUrlConfig() {
|
|
|
16917
16918
|
|
|
16918
16919
|
return getEmojiUrl;
|
|
16919
16920
|
}
|
|
16921
|
+
function useShowEmojiConfig() {
|
|
16922
|
+
var _usePickerConfig15 = usePickerConfig(),
|
|
16923
|
+
showEmoji = _usePickerConfig15.showEmoji;
|
|
16924
|
+
|
|
16925
|
+
return showEmoji;
|
|
16926
|
+
}
|
|
16927
|
+
|
|
16928
|
+
function getDimension(dimensionConfig) {
|
|
16929
|
+
return typeof dimensionConfig === 'number' ? dimensionConfig + "px" : dimensionConfig;
|
|
16930
|
+
}
|
|
16920
16931
|
|
|
16921
16932
|
var alphaNumericEmojiIndex = {};
|
|
16922
16933
|
setTimeout(function () {
|
|
@@ -16961,24 +16972,37 @@ function useDebouncedState(initialValue, delay) {
|
|
|
16961
16972
|
return [state, debouncedSetState];
|
|
16962
16973
|
}
|
|
16963
16974
|
|
|
16975
|
+
function isFunction(value) {
|
|
16976
|
+
return typeof value === 'function';
|
|
16977
|
+
}
|
|
16978
|
+
|
|
16964
16979
|
function useDisallowedEmojis() {
|
|
16965
16980
|
var DisallowedEmojisRef = React.useRef({});
|
|
16966
16981
|
var emojiVersionConfig = useEmojiVersionConfig();
|
|
16982
|
+
var shouldShowEmoji = useShowEmojiConfig();
|
|
16967
16983
|
return React.useMemo(function () {
|
|
16968
16984
|
var emojiVersion = parseFloat("" + emojiVersionConfig);
|
|
16969
16985
|
|
|
16970
|
-
if (!emojiVersionConfig || Number.isNaN(emojiVersion)) {
|
|
16986
|
+
if ((!emojiVersionConfig || Number.isNaN(emojiVersion)) && !shouldShowEmoji) {
|
|
16971
16987
|
return DisallowedEmojisRef.current;
|
|
16972
16988
|
}
|
|
16973
16989
|
|
|
16974
16990
|
return allEmojis.reduce(function (disallowedEmojis, emoji) {
|
|
16991
|
+
if (isFunction(shouldShowEmoji) && !shouldShowEmoji(emoji)) {
|
|
16992
|
+
disallowEmoji();
|
|
16993
|
+
}
|
|
16994
|
+
|
|
16975
16995
|
if (addedInNewerVersion(emoji, emojiVersion)) {
|
|
16976
|
-
|
|
16996
|
+
disallowEmoji();
|
|
16977
16997
|
}
|
|
16978
16998
|
|
|
16979
16999
|
return disallowedEmojis;
|
|
17000
|
+
|
|
17001
|
+
function disallowEmoji() {
|
|
17002
|
+
disallowedEmojis[emojiUnified(emoji)] = true;
|
|
17003
|
+
}
|
|
16980
17004
|
}, DisallowedEmojisRef.current);
|
|
16981
|
-
}, [emojiVersionConfig]);
|
|
17005
|
+
}, [emojiVersionConfig, shouldShowEmoji]);
|
|
16982
17006
|
}
|
|
16983
17007
|
|
|
16984
17008
|
function addedInNewerVersion(emoji, supportedLevel) {
|
|
@@ -17985,7 +18009,7 @@ function useFocusCategoryNavigation() {
|
|
|
17985
18009
|
function useSetFilterRef() {
|
|
17986
18010
|
var filterRef = useFilterRef();
|
|
17987
18011
|
return function setFilter(setter) {
|
|
17988
|
-
if (
|
|
18012
|
+
if (isFunction(setter)) {
|
|
17989
18013
|
return setFilter(setter(filterRef.current));
|
|
17990
18014
|
}
|
|
17991
18015
|
|
|
@@ -19392,8 +19416,8 @@ function PickerRootElement(_ref2) {
|
|
|
19392
19416
|
useKeyboardNavigation();
|
|
19393
19417
|
useOnFocus();
|
|
19394
19418
|
var style = {
|
|
19395
|
-
height: height
|
|
19396
|
-
width: width
|
|
19419
|
+
height: height,
|
|
19420
|
+
width: width
|
|
19397
19421
|
};
|
|
19398
19422
|
return React.createElement("aside", {
|
|
19399
19423
|
className: clsx(ClassNames.emojiPicker, 'epr-main', (_clsx = {}, _clsx[ClassNames.searchActive] = searchModeActive, _clsx['epr-dark-theme'] = theme === exports.Theme.DARK, _clsx)),
|