emoji-picker-react 4.5.15 → 4.5.16

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.5.15",
2
+ "version": "4.5.16",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -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 { asSelectors, ClassNames, clsx } from '../../DomUtils/classNames';
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='epr-search-id'
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='status'
78
- className={clsx('epr-status-search-results', 'epr-status-visually-hidden')}
79
- aria-live='polite'
80
- id='epr-search-id'
81
- aria-atomic='true'
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
- }