emoji-picker-react 4.6.8-rc.3 → 4.6.8

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.8-rc.3",
2
+ "version": "4.6.8",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -92,7 +92,6 @@
92
92
  "react-dom": "^18.2.0",
93
93
  "react-is": "^18.2.0",
94
94
  "rollup-plugin-postcss": "^4.0.2",
95
- "@rollup/plugin-image": "^3.0.3",
96
95
  "size-limit": "^8.0.1",
97
96
  "tiny-invariant": "^1.2.0",
98
97
  "tsdx": "^0.14.1",
@@ -100,6 +99,6 @@
100
99
  "typescript": "^4.7.4"
101
100
  },
102
101
  "dependencies": {
103
- "flairup": "0.0.24"
102
+ "flairup": "^0.0.25"
104
103
  }
105
104
  }
@@ -1,81 +1,3 @@
1
- .EmojiPickerReact .epr-emoji-variation-picker {
2
- position: absolute;
3
- top: 0;
4
- right: 15px;
5
- left: 15px;
6
- padding: 5px;
7
- height: 0;
8
- box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2);
9
- border-radius: 3px;
10
- display: flex;
11
- align-items: center;
12
- justify-content: space-around;
13
- opacity: 0;
14
- visibility: hidden;
15
- pointer-events: none;
16
- top: -100%;
17
- border: 1px solid var(--epr-picker-border-color);
18
- height: var(--epr-emoji-variation-picker-height);
19
- z-index: var(--epr-skin-variation-picker-z-index);
20
- background: var(--epr-emoji-variation-picker-bg-color);
21
- transform: scale(0.9);
22
- transition: transform 0.1s ease-out, opacity 0.2s ease-out;
23
- }
24
-
25
- .EmojiPickerReact .epr-emoji-variation-picker.pointing-up {
26
- transform-origin: center 0%;
27
- transform: scale(0.9);
28
- }
29
-
30
- .EmojiPickerReact .epr-emoji-variation-picker.visible {
31
- opacity: 1;
32
- visibility: visible;
33
- pointer-events: all;
34
- transform: scale(1);
35
- }
36
- .EmojiPickerReact
37
- .epr-emoji-variation-picker
38
- .EmojiPickerReact
39
- .epr-emoji-variation-picker
40
- button.epr-emoji:hover {
41
- background: none;
42
- }
43
-
44
- .EmojiPickerReact .epr-emoji-variation-picker .epr-emoji-pointer {
45
- content: '';
46
- position: absolute;
47
- top: -10px;
48
- width: 25px;
49
- height: 15px;
50
- }
51
-
52
1
  .EmojiPickerReact .epr-emoji-variation-picker .epr-emoji-pointer {
53
2
  background-image: svg-load(./svg/triangle.svg);
54
- background-repeat: no-repeat;
55
- background-position: 0 0;
56
- background-size: 50px 15px;
57
- }
58
-
59
- .EmojiPickerReact.epr-dark-theme
60
- .epr-emoji-variation-picker
61
- .epr-emoji-pointer {
62
- background-position: -25px 0;
63
- }
64
-
65
- @media (prefers-color-scheme: dark) {
66
- .EmojiPickerReact.epr-auto-theme
67
- .epr-emoji-variation-picker
68
- .epr-emoji-pointer {
69
- background-position: -25px 0;
70
- }
71
- }
72
-
73
- .EmojiPickerReact .epr-emoji-variation-picker .epr-emoji-pointer {
74
- top: 100%;
75
- transform: translateX(-18px);
76
- }
77
-
78
- .EmojiPickerReact .epr-emoji-variation-picker.pointing-up .epr-emoji-pointer {
79
- top: 0;
80
- transform: rotate(180deg) translateY(100%) translateX(18px);
81
3
  }
@@ -10,6 +10,7 @@ import {
10
10
  emojiTrueOffsetTop,
11
11
  emojiTruOffsetLeft
12
12
  } from '../../DomUtils/selectors';
13
+ import { stylesheet } from '../../Stylesheet/stylesheet';
13
14
  import {
14
15
  useEmojiStyleConfig,
15
16
  useGetEmojiUrlConfig
@@ -35,6 +36,7 @@ enum Direction {
35
36
  Down
36
37
  }
37
38
 
39
+ // eslint-disable-next-line complexity
38
40
  export function EmojiVariationPicker() {
39
41
  const AnchoredEmojiRef = useAnchoredEmojiRef();
40
42
  const VariationPickerRef = useVariationPickerRef();
@@ -50,11 +52,12 @@ export function EmojiVariationPicker() {
50
52
 
51
53
  const button = buttonFromTarget(AnchoredEmojiRef.current);
52
54
 
53
- const visible =
55
+ const visible = Boolean(
54
56
  emoji &&
55
- button &&
56
- emojiHasVariations(emoji) &&
57
- button.classList.contains(ClassNames.emojiHasVariations);
57
+ button &&
58
+ emojiHasVariations(emoji) &&
59
+ button.classList.contains(ClassNames.emojiHasVariations)
60
+ );
58
61
 
59
62
  useEffect(() => {
60
63
  if (!visible) {
@@ -76,10 +79,11 @@ export function EmojiVariationPicker() {
76
79
  return (
77
80
  <div
78
81
  ref={VariationPickerRef}
79
- className={cx(ClassNames.variationPicker, {
80
- visible,
81
- 'pointing-up': getMenuDirection() === Direction.Down
82
- })}
82
+ className={cx(
83
+ styles.variationPicker,
84
+ getMenuDirection() === Direction.Down && styles.pointingUp,
85
+ visible && styles.visible
86
+ )}
83
87
  style={{ top }}
84
88
  >
85
89
  {visible && emoji
@@ -97,7 +101,7 @@ export function EmojiVariationPicker() {
97
101
  />
98
102
  ))
99
103
  : null}
100
- <div className="epr-emoji-pointer" style={pointerStyle} />
104
+ <div className={cx(styles.pointer)} style={pointerStyle} />
101
105
  </div>
102
106
  );
103
107
  }
@@ -172,3 +176,70 @@ function useVariationPickerTop(
172
176
  return emojiOffsetTop - height;
173
177
  }
174
178
  }
179
+
180
+ const styles = stylesheet.create({
181
+ variationPicker: {
182
+ '.': ClassNames.variationPicker,
183
+ position: 'absolute',
184
+ right: '15px',
185
+ left: '15px',
186
+ padding: '5px',
187
+ boxShadow: '0px 2px 5px rgba(0, 0, 0, 0.2)',
188
+ borderRadius: '3px',
189
+ display: 'flex',
190
+ alignItems: 'center',
191
+ justifyContent: 'space-around',
192
+ opacity: '0',
193
+ visibility: 'hidden',
194
+ pointerEvents: 'none',
195
+ top: '-100%',
196
+ border: '1px solid var(--epr-picker-border-color)',
197
+ height: 'var(--epr-emoji-variation-picker-height)',
198
+ zIndex: 'var(--epr-skin-variation-picker-z-index)',
199
+ background: 'var(--epr-emoji-variation-picker-bg-color)',
200
+ transform: 'scale(0.9)',
201
+ transition: 'transform 0.1s ease-out, opacity 0.2s ease-out'
202
+ },
203
+ pointingUp: {
204
+ '.': 'pointing-up',
205
+ transformOrigin: 'center 0%',
206
+ transform: 'scale(0.9)'
207
+ },
208
+ '.pointing-up': {
209
+ pointer: {
210
+ top: '0',
211
+ transform: 'rotate(180deg) translateY(100%) translateX(18px)'
212
+ }
213
+ },
214
+ visible: {
215
+ opacity: '1',
216
+ visibility: 'visible',
217
+ pointerEvents: 'all',
218
+ transform: 'scale(1)'
219
+ },
220
+ pointer: {
221
+ '.': 'epr-emoji-pointer',
222
+ content: '',
223
+ position: 'absolute',
224
+ width: '25px',
225
+ height: '15px',
226
+ backgroundRepeat: 'no-repeat',
227
+ backgroundPosition: '0 0',
228
+ backgroundSize: '50px 15px',
229
+ top: '100%',
230
+ transform: 'translateX(-18px)'
231
+ },
232
+ '.epr-dark-theme': {
233
+ pointer: {
234
+ backgroundPosition: '-25px 0'
235
+ }
236
+ },
237
+ '.epr-auto-theme': {
238
+ pointer: {
239
+ // @ts-ignore
240
+ '@media (prefers-color-scheme: dark)': {
241
+ backgroundPosition: '-25px 0'
242
+ }
243
+ }
244
+ }
245
+ });
@@ -2,11 +2,9 @@ import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
 
4
4
  import { ClassNames } from '../../DomUtils/classNames';
5
- import { commonStyles } from '../../Stylesheet/stylesheet';
5
+ import { commonStyles, stylesheet } from '../../Stylesheet/stylesheet';
6
6
  import { Button } from '../atoms/Button';
7
7
 
8
- import './Emoji.css';
9
-
10
8
  type ClickableEmojiButtonProps = Readonly<{
11
9
  hidden?: boolean;
12
10
  showVariations?: boolean;
@@ -29,13 +27,13 @@ export function ClickableEmojiButton({
29
27
  return (
30
28
  <Button
31
29
  className={cx(
32
- ClassNames.emoji,
30
+ styles.emoji,
33
31
  hidden && commonStyles.hidden,
34
32
  hiddenOnSearch && commonStyles.hiddenOnSearch,
35
33
  {
36
- [ClassNames.visible]: !hidden && !hiddenOnSearch,
37
- [ClassNames.emojiHasVariations]: hasVariations && showVariations
38
- }
34
+ [ClassNames.visible]: !hidden && !hiddenOnSearch
35
+ },
36
+ !!(hasVariations && showVariations) && styles.hasVariations
39
37
  )}
40
38
  data-unified={unified}
41
39
  aria-label={emojiNames[0]}
@@ -45,3 +43,47 @@ export function ClickableEmojiButton({
45
43
  </Button>
46
44
  );
47
45
  }
46
+
47
+ const styles = stylesheet.create({
48
+ emoji: {
49
+ '.': ClassNames.emoji,
50
+ position: 'relative',
51
+ width: 'var(--epr-emoji-fullsize)',
52
+ height: 'var(--epr-emoji-fullsize)',
53
+ boxSizing: 'border-box',
54
+ display: 'flex',
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ maxWidth: 'var(--epr-emoji-fullsize)',
58
+ maxHeight: 'var(--epr-emoji-fullsize)',
59
+ borderRadius: '8px',
60
+ overflow: 'hidden',
61
+ transition: 'background-color 0.2s',
62
+ ':hover': {
63
+ backgroundColor: 'var(--epr-emoji-hover-color)'
64
+ },
65
+ ':focus': {
66
+ backgroundColor: 'var(--epr-focus-bg-color)'
67
+ }
68
+ },
69
+ hasVariations: {
70
+ '.': ClassNames.emojiHasVariations,
71
+ ':after': {
72
+ content: '',
73
+ display: 'block',
74
+ width: '0',
75
+ height: '0',
76
+ right: '0px',
77
+ bottom: '1px',
78
+ position: 'absolute',
79
+ borderLeft: '4px solid transparent',
80
+ borderRight: '4px solid transparent',
81
+ transform: 'rotate(135deg)',
82
+ borderBottom: '4px solid var(--epr-emoji-variation-indicator-color)',
83
+ zIndex: 'var(--epr-emoji-variations-indictator-z-index)'
84
+ },
85
+ ':hover:after': {
86
+ borderBottom: '4px solid var(--epr-emoji-variation-indicator-color-hover)'
87
+ }
88
+ }
89
+ });
@@ -3,7 +3,6 @@ import * as React from 'react';
3
3
  import { DataEmoji } from '../../dataUtils/DataTypes';
4
4
  import { emojiHasVariations, emojiNames } from '../../dataUtils/emojiSelectors';
5
5
 
6
- import './Emoji.css';
7
6
  import { BaseEmojiProps } from './BaseEmojiProps';
8
7
  import { ClickableEmojiButton } from './ClickableEmojiButton';
9
8
  import { ViewOnlyEmoji } from './ViewOnlyEmoji';
@@ -14,6 +13,7 @@ type ClickableEmojiProps = Readonly<
14
13
  showVariations?: boolean;
15
14
  hiddenOnSearch?: boolean;
16
15
  emoji: DataEmoji;
16
+ className?: string;
17
17
  }
18
18
  >;
19
19
 
@@ -1,9 +1,11 @@
1
1
  import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
 
4
- import { ClassNames } from '../../DomUtils/classNames';
4
+ import { stylesheet } from '../../Stylesheet/stylesheet';
5
5
  import { EmojiStyle } from '../../types/exposedTypes';
6
6
 
7
+ import { emojiStyles } from './emojiStyles';
8
+
7
9
  export function EmojiImg({
8
10
  emojiName,
9
11
  style,
@@ -22,10 +24,21 @@ export function EmojiImg({
22
24
  <img
23
25
  src={imgUrl}
24
26
  alt={emojiName}
25
- className={cx(ClassNames.external, 'epr-emoji-img')}
27
+ className={cx(styles.emojiImag, emojiStyles.external, emojiStyles.common)}
26
28
  loading={lazyLoad ? 'lazy' : 'eager'}
27
29
  onError={onError}
28
30
  style={style}
29
31
  />
30
32
  );
31
33
  }
34
+
35
+ const styles = stylesheet.create({
36
+ emojiImag: {
37
+ '.': 'epr-emoji-img',
38
+ maxWidth: 'var(--epr-emoji-fullsize)',
39
+ maxHeight: 'var(--epr-emoji-fullsize)',
40
+ minWidth: 'var(--epr-emoji-fullsize)',
41
+ minHeight: 'var(--epr-emoji-fullsize)',
42
+ padding: 'var(--epr-emoji-padding)'
43
+ }
44
+ });
@@ -1,9 +1,11 @@
1
1
  import { cx } from 'flairup';
2
2
  import * as React from 'react';
3
3
 
4
- import { ClassNames } from '../../DomUtils/classNames';
4
+ import { stylesheet } from '../../Stylesheet/stylesheet';
5
5
  import { parseNativeEmoji } from '../../dataUtils/parseNativeEmoji';
6
6
 
7
+ import { emojiStyles } from './emojiStyles';
8
+
7
9
  export function NativeEmoji({
8
10
  unified,
9
11
  style
@@ -13,7 +15,11 @@ export function NativeEmoji({
13
15
  }) {
14
16
  return (
15
17
  <span
16
- className={cx(ClassNames.external, 'epr-emoji-native')}
18
+ className={cx(
19
+ styles.nativeEmoji,
20
+ emojiStyles.common,
21
+ emojiStyles.external
22
+ )}
17
23
  data-unified={unified}
18
24
  style={style}
19
25
  >
@@ -21,3 +27,19 @@ export function NativeEmoji({
21
27
  </span>
22
28
  );
23
29
  }
30
+
31
+ const styles = stylesheet.create({
32
+ nativeEmoji: {
33
+ '.': 'epr-emoji-native',
34
+ fontFamily:
35
+ '"Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "EmojiOne Color", "Android Emoji"!important',
36
+ position: 'relative',
37
+ lineHeight: '100%',
38
+ fontSize: 'var(--epr-emoji-size)',
39
+ textAlign: 'center',
40
+ alignSelf: 'center',
41
+ justifySelf: 'center',
42
+ letterSpacing: '0',
43
+ padding: 'var(--epr-emoji-padding)'
44
+ }
45
+ });
@@ -0,0 +1,14 @@
1
+ import { ClassNames } from '../../DomUtils/classNames';
2
+ import { stylesheet } from '../../Stylesheet/stylesheet';
3
+
4
+ export const emojiStyles = stylesheet.create({
5
+ external: {
6
+ '.': ClassNames.external,
7
+ fontSize: '0'
8
+ },
9
+ common: {
10
+ alignSelf: 'center',
11
+ justifySelf: 'center',
12
+ display: 'block'
13
+ }
14
+ });
@@ -1,132 +1,10 @@
1
- .EmojiPickerReact .epr-search-container {
2
- flex: 1;
3
- display: block;
4
- min-width: 0;
5
- }
6
-
7
- .EmojiPickerReact .epr-search-container .epr-status-visually-hidden {
8
- clip: rect(0 0 0 0);
9
- clip-path: inset(50%);
10
- height: 1px;
11
- overflow: hidden;
12
- position: absolute;
13
- white-space: nowrap;
14
- width: 1px;
15
- }
16
-
17
- .EmojiPickerReact .epr-search-container input.epr-search {
18
- outline: none;
19
- transition: all 0.2s ease-in-out;
20
- color: var(--epr-search-input-text-color);
21
- border-radius: var(--epr-search-input-border-radius);
22
- padding: var(--epr-search-input-padding);
23
- height: var(--epr-search-input-height);
24
- background-color: var(--epr-search-input-bg-color);
25
- border: 1px solid var(--epr-search-input-bg-color);
26
- width: 100%;
27
- }
28
-
29
1
  .EmojiPickerReact
30
2
  .epr-search-container
31
3
  button.epr-btn-clear-search
32
4
  .epr-icn-clear-search {
33
5
  background-image: svg-load(./svg/times.svg);
34
- background-color: transparent;
35
- background-repeat: no-repeat;
36
- background-size: 20px;
37
- height: 20px;
38
- width: 20px;
39
- }
40
-
41
- .EmojiPickerReact .epr-search-container button.epr-btn-clear-search {
42
- position: absolute;
43
- right: var(--epr-search-bar-inner-padding);
44
- height: 30px;
45
- width: 30px;
46
- display: flex;
47
- align-items: center;
48
- justify-content: center;
49
- top: 50%;
50
- transform: translateY(-50%);
51
- padding: 0;
52
- border-radius: 50%;
53
- }
54
-
55
- .EmojiPickerReact
56
- .epr-search-container
57
- button.epr-btn-clear-search:hover
58
- .epr-icn-clear-search,
59
- .EmojiPickerReact
60
- .epr-search-container
61
- button.epr-btn-clear-search:focus
62
- .epr-icn-clear-search {
63
- background-position-y: -20px;
64
- }
65
-
66
- .EmojiPickerReact .epr-search-container button.epr-btn-clear-search:hover,
67
- .EmojiPickerReact .epr-search-container button.epr-btn-clear-search:focus {
68
- background: var(--epr-hover-bg-color);
69
- }
70
-
71
- .EmojiPickerReact.epr-dark-theme
72
- .epr-search-container
73
- button.epr-btn-clear-search
74
- .epr-icn-clear-search {
75
- background-position-y: -40px;
76
- }
77
-
78
- .EmojiPickerReact.epr-dark-theme
79
- .epr-search-container
80
- button.epr-btn-clear-search:hover
81
- .epr-icn-clear-search {
82
- background-position-y: -60px;
83
- }
84
-
85
- @media (prefers-color-scheme: dark) {
86
- .EmojiPickerReact.epr-auto-theme
87
- .epr-search-container
88
- button.epr-btn-clear-search
89
- .epr-icn-clear-search {
90
- background-position-y: -40px;
91
- }
92
-
93
- .EmojiPickerReact.epr-auto-theme
94
- .epr-search-container
95
- button.epr-btn-clear-search:hover
96
- .epr-icn-clear-search {
97
- background-position-y: -60px;
98
- }
99
6
  }
100
7
 
101
8
  .EmojiPickerReact .epr-search-container .epr-icn-search {
102
- content: '';
103
- position: absolute;
104
- top: 50%;
105
- left: var(--epr-search-bar-inner-padding);
106
- transform: translateY(-50%);
107
- width: 20px;
108
- height: 20px;
109
9
  background-image: svg-load(./svg/magnifier.svg);
110
- background-repeat: no-repeat;
111
- background-position: 0 0;
112
- background-size: 20px;
113
- }
114
-
115
- .EmojiPickerReact.epr-dark-theme .epr-search-container .epr-icn-search {
116
- background-position-y: -20px;
117
- }
118
-
119
- @media (prefers-color-scheme: dark) {
120
- .EmojiPickerReact.epr-auto-theme .epr-search-container .epr-icn-search {
121
- background-position-y: -20px;
122
- }
123
- }
124
-
125
- .EmojiPickerReact .epr-search-container input.epr-search::placeholder {
126
- color: var(--epr-search-input-placeholder-color);
127
- }
128
-
129
- .EmojiPickerReact .epr-search-container input.epr-search:focus {
130
- background-color: var(--epr-search-input-bg-color-active);
131
- border: 1px solid var(--epr-search-border-color);
132
10
  }