emoji-picker-react 4.6.9 → 4.6.10

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.6.9",
2
+ "version": "4.6.10",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -99,6 +99,6 @@
99
99
  "typescript": "^4.7.4"
100
100
  },
101
101
  "dependencies": {
102
- "flairup": "0.0.28"
102
+ "flairup": "0.0.31"
103
103
  }
104
104
  }
@@ -7,7 +7,6 @@ import { Preview } from './components/footer/Preview';
7
7
  import { Header } from './components/header/Header';
8
8
  import PickerMain from './components/main/PickerMain';
9
9
 
10
- import './EmojiPickerReact.css';
11
10
  import { PickerProps } from './index';
12
11
 
13
12
  function EmojiPicker(props: PickerProps) {
@@ -4,31 +4,39 @@ import { ClassNames } from '../DomUtils/classNames';
4
4
 
5
5
  export const stylesheet = createSheet('epr');
6
6
 
7
+ const hidden = {
8
+ display: 'none',
9
+ opacity: '0',
10
+ pointerEvents: 'none',
11
+ visibility: 'hidden'
12
+ };
13
+
7
14
  export const commonStyles = stylesheet.create({
8
15
  hidden: {
9
16
  '.': ClassNames.hidden,
10
- display: 'none',
11
- opacity: '0',
12
- pointerEvents: 'none',
13
- visibility: 'hidden'
14
- },
15
- hiddenOnSearch: {
16
- display: 'none',
17
- opacity: '0',
18
- pointerEvents: 'none',
19
- visibility: 'hidden'
17
+ ...hidden
20
18
  }
21
19
  });
22
20
 
23
21
  export const commonInteractionStyles = stylesheet.create({
24
- '.epr-main:has(input:not(:placeholder-shown))': {
25
- categoryBtn: {
26
- ':hover': {
27
- opacity: '1',
28
- backgroundPositionY: 'var(--epr-category-navigation-button-size)'
22
+ '.epr-main': {
23
+ ':has(input:not(:placeholder-shown))': {
24
+ categoryBtn: {
25
+ ':hover': {
26
+ opacity: '1',
27
+ backgroundPositionY: 'var(--epr-category-navigation-button-size)'
28
+ }
29
+ },
30
+ hiddenOnSearch: {
31
+ '.': ClassNames.hiddenOnSearch,
32
+ ...hidden
29
33
  }
34
+ },
35
+ ':has(input(:placeholder-shown))': {
36
+ visibleOnSearchOnly: hidden
30
37
  }
31
38
  },
39
+
32
40
  '.EmojiPickerReact:not(.epr-search-active)': {
33
41
  categoryBtn: {
34
42
  ':hover': {
@@ -40,6 +48,10 @@ export const commonInteractionStyles = stylesheet.create({
40
48
  opacity: '1',
41
49
  backgroundPositionY: 'var(--epr-category-navigation-button-size)'
42
50
  }
51
+ },
52
+ visibleOnSearchOnly: {
53
+ '.': 'epr-visible-on-search-only',
54
+ ...hidden
43
55
  }
44
56
  }
45
57
  });
@@ -2,7 +2,11 @@ import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
 
4
4
  import { ClassNames } from '../../DomUtils/classNames';
5
- import { commonStyles, stylesheet } from '../../Stylesheet/stylesheet';
5
+ import {
6
+ commonInteractionStyles,
7
+ commonStyles,
8
+ stylesheet
9
+ } from '../../Stylesheet/stylesheet';
6
10
  import {
7
11
  CategoryConfig,
8
12
  categoryFromCategoryConfig,
@@ -30,7 +34,7 @@ export function EmojiCategory({
30
34
  className={cx(
31
35
  styles.category,
32
36
  hidden && commonStyles.hidden,
33
- hiddenOnSearch && commonStyles.hiddenOnSearch
37
+ hiddenOnSearch && commonInteractionStyles.hiddenOnSearch
34
38
  )}
35
39
  data-name={category}
36
40
  aria-label={categoryName}
@@ -9,5 +9,6 @@ export type BaseEmojiProps = {
9
9
  size?: number;
10
10
  lazyLoad?: boolean;
11
11
  getEmojiUrl?: GetEmojiUrl;
12
+ className?: string;
12
13
  };
13
14
  export type GetEmojiUrl = (unified: string, style: EmojiStyle) => string;
@@ -2,7 +2,7 @@ import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
 
4
4
  import { ClassNames } from '../../DomUtils/classNames';
5
- import { commonStyles, stylesheet } from '../../Stylesheet/stylesheet';
5
+ import { commonInteractionStyles, commonStyles, stylesheet } from '../../Stylesheet/stylesheet';
6
6
  import { Button } from '../atoms/Button';
7
7
 
8
8
  type ClickableEmojiButtonProps = Readonly<{
@@ -29,7 +29,7 @@ export function ClickableEmojiButton({
29
29
  className={cx(
30
30
  styles.emoji,
31
31
  hidden && commonStyles.hidden,
32
- hiddenOnSearch && commonStyles.hiddenOnSearch,
32
+ hiddenOnSearch && commonInteractionStyles.hiddenOnSearch,
33
33
  {
34
34
  [ClassNames.visible]: !hidden && !hiddenOnSearch
35
35
  },
@@ -11,20 +11,22 @@ export function EmojiImg({
11
11
  style,
12
12
  lazyLoad = false,
13
13
  imgUrl,
14
- onError
14
+ onError,
15
+ className
15
16
  }: {
16
17
  emojiName: string;
17
18
  emojiStyle: EmojiStyle;
18
19
  style: React.CSSProperties;
19
20
  lazyLoad?: boolean;
20
21
  imgUrl: string;
21
- onError: () => void;
22
+ onError: () => void;
23
+ className?: string;
22
24
  }) {
23
25
  return (
24
26
  <img
25
27
  src={imgUrl}
26
28
  alt={emojiName}
27
- className={cx(styles.emojiImag, emojiStyles.external, emojiStyles.common)}
29
+ className={cx(styles.emojiImag, emojiStyles.external, emojiStyles.common, className)}
28
30
  loading={lazyLoad ? 'lazy' : 'eager'}
29
31
  onError={onError}
30
32
  style={style}
@@ -8,17 +8,20 @@ import { emojiStyles } from './emojiStyles';
8
8
 
9
9
  export function NativeEmoji({
10
10
  unified,
11
- style
11
+ style,
12
+ className
12
13
  }: {
13
14
  unified: string;
14
15
  style: React.CSSProperties;
16
+ className?: string;
15
17
  }) {
16
18
  return (
17
19
  <span
18
20
  className={cx(
19
21
  styles.nativeEmoji,
20
22
  emojiStyles.common,
21
- emojiStyles.external
23
+ emojiStyles.external,
24
+ className
22
25
  )}
23
26
  data-unified={unified}
24
27
  style={style}
@@ -19,7 +19,8 @@ export function ViewOnlyEmoji({
19
19
  emojiStyle,
20
20
  size,
21
21
  lazyLoad,
22
- getEmojiUrl = emojiUrlByUnified
22
+ getEmojiUrl = emojiUrlByUnified,
23
+ className
23
24
  }: BaseEmojiProps) {
24
25
  const [, setEmojisThatFailedToLoad] = useEmojisThatFailedToLoadState();
25
26
 
@@ -43,6 +44,7 @@ export function ViewOnlyEmoji({
43
44
  lazyLoad={lazyLoad}
44
45
  imgUrl={emojiToRender.imgUrl}
45
46
  onError={onError}
47
+ className={className}
46
48
  />
47
49
  );
48
50
  }
@@ -50,7 +52,7 @@ export function ViewOnlyEmoji({
50
52
  return (
51
53
  <>
52
54
  {emojiStyle === EmojiStyle.NATIVE ? (
53
- <NativeEmoji unified={unified} style={style} />
55
+ <NativeEmoji unified={unified} style={style} className={className} />
54
56
  ) : (
55
57
  <EmojiImg
56
58
  style={style}
@@ -59,6 +61,7 @@ export function ViewOnlyEmoji({
59
61
  lazyLoad={lazyLoad}
60
62
  imgUrl={getEmojiUrl(unified, emojiStyle)}
61
63
  onError={onError}
64
+ className={className}
62
65
  />
63
66
  )}
64
67
  </>
@@ -75,6 +75,7 @@ export function PreviewBody() {
75
75
  emojiStyle={emojiStyle}
76
76
  size={45}
77
77
  getEmojiUrl={getEmojiUrl}
78
+ className={cx(styles.emoji)}
78
79
  />
79
80
  ) : defaultEmoji ? (
80
81
  <ViewOnlyEmoji
@@ -83,6 +84,7 @@ export function PreviewBody() {
83
84
  emojiStyle={emojiStyle}
84
85
  size={45}
85
86
  getEmojiUrl={getEmojiUrl}
87
+ className={cx(styles.emoji)}
86
88
  />
87
89
  ) : null}
88
90
  </div>
@@ -115,5 +117,8 @@ const styles = stylesheet.create({
115
117
  fontSize: 'var(--epr-preview-text-size)',
116
118
  padding: 'var(--epr-preview-text-padding)',
117
119
  textTransform: 'capitalize'
120
+ },
121
+ emoji: {
122
+ padding: '0'
118
123
  }
119
124
  });
@@ -2,7 +2,10 @@ import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
  import { useState } from 'react';
4
4
 
5
- import { stylesheet } from '../../Stylesheet/stylesheet';
5
+ import {
6
+ commonInteractionStyles,
7
+ stylesheet
8
+ } from '../../Stylesheet/stylesheet';
6
9
  import {
7
10
  useAutoFocusSearchConfig,
8
11
  useSearchDisabledConfig,
@@ -83,7 +86,10 @@ export function Search() {
83
86
  ) : null}
84
87
  <div className={cx(styles.icnSearch)} />
85
88
  <Button
86
- className={cx(styles.btnClearSearch, 'epr-visible-on-search-only')}
89
+ className={cx(
90
+ styles.btnClearSearch,
91
+ commonInteractionStyles.visibleOnSearchOnly
92
+ )}
87
93
  onClick={clearSearch}
88
94
  aria-label="Clear"
89
95
  title="Clear"
@@ -140,7 +140,7 @@ const styles = stylesheet.create({
140
140
  backdropFilter: 'blur(5px)',
141
141
  background: 'var(--epr-skin-tone-picker-menu-color)',
142
142
  // @ts-ignore
143
- '&.epr-active:after': {
143
+ '.epr-active:after': {
144
144
  content: '',
145
145
  position: 'absolute',
146
146
  top: '-2px',
@@ -95,7 +95,12 @@ const styles = stylesheet.create({
95
95
  borderRadius: 'var(--epr-picker-border-radius)',
96
96
  borderColor: 'var(--epr-picker-border-color)',
97
97
  backgroundColor: 'var(--epr-bg-color)',
98
- overflow: 'hidden'
98
+ overflow: 'hidden',
99
+ // @ts-expect-error - need to work on this
100
+ '*': {
101
+ boxSizing: 'border-box',
102
+ fontFamily: 'sans-serif'
103
+ }
99
104
  },
100
105
  baseVariables: {
101
106
  '--': {
@@ -161,24 +161,14 @@ const styles = stylesheet.create({
161
161
  catBtn: {
162
162
  backgroundPositionY:
163
163
  'calc(var(--epr-category-navigation-button-size) * 2)'
164
- }
165
- },
166
- '.epr-auto-theme': {
167
- catBtn: {
168
- '@media (prefers-color-scheme: dark)': {
169
- backgroundPositionY:
170
- 'calc(var(--epr-category-navigation-button-size) * 2)'
171
- }
172
- }
173
- },
174
- '.epr-auto-theme:not(.epr-search-active)': {
175
- catBtn: {
176
- '@media (prefers-color-scheme: dark)': {
164
+ },
165
+ ':not(.epr-search-active)': {
166
+ // @ts-expect-error - need to fix this
167
+ catBtn: {
177
168
  ':hover': {
178
169
  backgroundPositionY:
179
170
  'calc(var(--epr-category-navigation-button-size) * 3)'
180
171
  },
181
- // @ts-ignore
182
172
  '&.epr-active': {
183
173
  backgroundPositionY:
184
174
  'calc(var(--epr-category-navigation-button-size) * 3)'
@@ -186,16 +176,26 @@ const styles = stylesheet.create({
186
176
  }
187
177
  }
188
178
  },
189
- '.epr-dark-theme:not(.epr-search-active)': {
179
+ '.epr-auto-theme': {
190
180
  catBtn: {
191
- ':hover': {
192
- backgroundPositionY:
193
- 'calc(var(--epr-category-navigation-button-size) * 3)'
194
- },
195
- // @ts-ignore
196
- '&.epr-active': {
181
+ '@media (prefers-color-scheme: dark)': {
197
182
  backgroundPositionY:
198
- 'calc(var(--epr-category-navigation-button-size) * 3)'
183
+ 'calc(var(--epr-category-navigation-button-size) * 2)'
184
+ }
185
+ },
186
+ ':not(.epr-search-active)': {
187
+ catBtn: {
188
+ '@media (prefers-color-scheme: dark)': {
189
+ ':hover': {
190
+ backgroundPositionY:
191
+ 'calc(var(--epr-category-navigation-button-size) * 3)'
192
+ },
193
+ // @ts-ignore
194
+ '&.epr-active': {
195
+ backgroundPositionY:
196
+ 'calc(var(--epr-category-navigation-button-size) * 3)'
197
+ }
198
+ }
199
199
  }
200
200
  }
201
201
  }
@@ -1,30 +0,0 @@
1
- .EmojiPickerReact:not(.epr-search-active) .epr-visible-on-search-only {
2
- display: none !important;
3
- opacity: 0 !important;
4
- pointer-events: none !important;
5
- visibility: hidden !important;
6
- }
7
-
8
- /* This is the same as .search-active, only without any js behind it
9
- Should switch to it full time when :has() gets better adoption
10
- */
11
- aside.EmojiPickerReact.epr-main:has(input:not(:placeholder-shown))
12
- .epr-hidden-on-search {
13
- display: none !important;
14
- opacity: 0 !important;
15
- pointer-events: none !important;
16
- visibility: hidden !important;
17
- }
18
-
19
- aside.EmojiPickerReact.epr-main:has(input:placeholder-shown)
20
- .epr-visible-on-search-only {
21
- display: none !important;
22
- opacity: 0 !important;
23
- pointer-events: none !important;
24
- visibility: hidden !important;
25
- }
26
-
27
- .EmojiPickerReact * {
28
- box-sizing: border-box;
29
- font-family: sans-serif;
30
- }