emoji-picker-react 4.2.0 → 4.3.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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.2.0",
2
+ "version": "4.3.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -37,15 +37,15 @@ function PickerRootElement({ children }: RootProps) {
37
37
  useOnFocus();
38
38
 
39
39
  const style = {
40
- height: `${height}px`,
41
- width: `${width}px`,
40
+ height,
41
+ width
42
42
  };
43
43
 
44
44
  return (
45
45
  <aside
46
46
  className={clsx(ClassNames.emojiPicker, 'epr-main', {
47
47
  [ClassNames.searchActive]: searchModeActive,
48
- 'epr-dark-theme': theme === Theme.DARK,
48
+ 'epr-dark-theme': theme === Theme.DARK
49
49
  })}
50
50
  ref={PickerMainRef}
51
51
  style={style}
@@ -5,13 +5,13 @@ import {
5
5
  EmojiStyle,
6
6
  SkinTones,
7
7
  SuggestionMode,
8
- Theme,
8
+ Theme
9
9
  } from '../types/exposedTypes';
10
10
 
11
11
  import {
12
12
  CategoriesConfig,
13
13
  baseCategoriesConfig,
14
- mergeCategoriesConfig,
14
+ mergeCategoriesConfig
15
15
  } from './categoryConfig';
16
16
 
17
17
  export function mergeConfig(
@@ -26,13 +26,13 @@ export function mergeConfig(
26
26
  const config = Object.assign(base, userConfig);
27
27
 
28
28
  const categories = mergeCategoriesConfig(userConfig.categories, {
29
- suggestionMode: config.suggestedEmojisMode,
29
+ suggestionMode: config.suggestedEmojisMode
30
30
  });
31
31
 
32
32
  return {
33
33
  ...config,
34
34
  categories,
35
- previewConfig,
35
+ previewConfig
36
36
  };
37
37
  }
38
38
 
@@ -55,13 +55,13 @@ export function basePickerConfig(): PickerConfigInternal {
55
55
  event: MouseEvent
56
56
  ) {},
57
57
  previewConfig: {
58
- ...basePreviewConfig,
58
+ ...basePreviewConfig
59
59
  },
60
60
  searchPlaceHolder: 'Search',
61
61
  skinTonesDisabled: false,
62
62
  suggestedEmojisMode: SuggestionMode.FREQUENT,
63
63
  theme: Theme.LIGHT,
64
- width: 350,
64
+ width: 350
65
65
  };
66
66
  }
67
67
 
@@ -78,8 +78,8 @@ export type PickerConfigInternal = {
78
78
  suggestedEmojisMode: SuggestionMode;
79
79
  lazyLoadEmojis: boolean;
80
80
  previewConfig: PreviewConfig;
81
- height: number;
82
- width: number;
81
+ height: PickerDimensions;
82
+ width: PickerDimensions;
83
83
  getEmojiUrl: GetEmojiUrl;
84
84
  };
85
85
 
@@ -92,7 +92,7 @@ export type PreviewConfig = {
92
92
  const basePreviewConfig: PreviewConfig = {
93
93
  defaultEmoji: '1f60a',
94
94
  defaultCaption: "What's your mood?",
95
- showPreview: true,
95
+ showPreview: true
96
96
  };
97
97
 
98
98
  type ConfigExternal = {
@@ -100,3 +100,5 @@ type ConfigExternal = {
100
100
  } & Omit<PickerConfigInternal, 'previewConfig'>;
101
101
 
102
102
  export type PickerConfig = Partial<ConfigExternal>;
103
+
104
+ export type PickerDimensions = string | number;
@@ -5,11 +5,11 @@ import {
5
5
  EmojiStyle,
6
6
  SkinTones,
7
7
  SuggestionMode,
8
- Theme,
8
+ Theme
9
9
  } from '../types/exposedTypes';
10
10
 
11
11
  import { CategoriesConfig } from './categoryConfig';
12
- import { PreviewConfig } from './config';
12
+ import { PickerDimensions, PreviewConfig } from './config';
13
13
 
14
14
  export function useSearchPlaceHolderConfig(): string {
15
15
  const { searchPlaceHolder } = usePickerConfig();
@@ -74,9 +74,12 @@ export function useLazyLoadEmojisConfig(): boolean {
74
74
  return lazyLoadEmojis;
75
75
  }
76
76
 
77
- export function usePickerSizeConfig(): { height: number; width: number } {
77
+ export function usePickerSizeConfig(): {
78
+ height: PickerDimensions;
79
+ width: PickerDimensions;
80
+ } {
78
81
  const { height, width } = usePickerConfig();
79
- return { height, width };
82
+ return { height: getDimension(height), width: getDimension(width) };
80
83
  }
81
84
 
82
85
  export function useEmojiVersionConfig(): string | null {
@@ -91,3 +94,9 @@ export function useGetEmojiUrlConfig(): (
91
94
  const { getEmojiUrl } = usePickerConfig();
92
95
  return getEmojiUrl;
93
96
  }
97
+
98
+ function getDimension(dimensionConfig: PickerDimensions): PickerDimensions {
99
+ return typeof dimensionConfig === 'number'
100
+ ? `${dimensionConfig}px`
101
+ : dimensionConfig;
102
+ }