emoji-picker-react 5.0.0 → 5.0.2
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/dist/DomUtils/classNames.d.ts +0 -1
- package/dist/DomUtils/keyboardNavigation.d.ts +10 -2
- package/dist/DomUtils/selectors.d.ts +2 -2
- package/dist/data/index.js +1 -1
- package/dist/data/skinToneVariations.js +2 -2
- package/dist/data/skinToneVariations.ts +8 -7
- package/dist/data-core/prepare.d.ts +6 -0
- package/dist/esm/chunks/chunk-56D5WCOZ.mjs +6729 -0
- package/dist/esm/chunks/chunk-7ZGTUZFB.mjs +8021 -12
- package/dist/esm/chunks/chunk-IODYR4CR.mjs +14 -0
- package/dist/esm/chunks/chunk-LO4TPPLH.mjs +32 -42
- package/dist/esm/chunks/chunk-RU7G34WK.mjs +156 -0
- package/dist/esm/chunks/emojis-6L3GRBAP.mjs +5 -7
- package/dist/esm/data.mjs +9 -16
- package/dist/esm/index.mjs +230 -340
- package/dist/esm/primitives/index.mjs +6 -65
- package/dist/hooks/preloadEmoji.d.ts +1 -5
- package/dist/hooks/useCategoryHeight.d.ts +2 -1
- package/dist/hooks/useEmojiVirtualization.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/primitives/index.js +1 -1
- package/dist/virtualization/virtualizationHelpers.d.ts +2 -0
- package/llms-full.txt +9 -3
- package/package.json +2 -2
- package/src/DomUtils/classNames.ts +0 -4
- package/src/DomUtils/elementPositionInRow.ts +2 -2
- package/src/DomUtils/keyboardNavigation.ts +74 -10
- package/src/DomUtils/scrollTo.ts +2 -2
- package/src/DomUtils/selectors.ts +10 -16
- package/src/components/body/EmojiCategory.tsx +1 -1
- package/src/components/body/EmojiList.tsx +54 -23
- package/src/components/context/PickerDataContext.tsx +7 -2
- package/src/components/header/Search/Search.tsx +4 -2
- package/src/components/header/SkinTonePicker/BtnSkinToneVariation.tsx +7 -6
- package/src/components/main/defaultAppearance.tsx +2 -1
- package/src/config/config.ts +6 -3
- package/src/data/skinToneVariations.ts +8 -7
- package/src/data-core/pickerData.ts +8 -12
- package/src/data-core/prepare.ts +32 -39
- package/src/data-core/search.ts +10 -2
- package/src/dataUtils/emojiSelectors.ts +2 -1
- package/src/dataUtils/parseNativeEmoji.ts +3 -4
- package/src/dataUtils/suggestedEmojis.ts +25 -39
- package/src/hooks/preloadEmoji.ts +13 -52
- package/src/hooks/useActiveCategoryScrollDetection.ts +22 -19
- package/src/hooks/useCategoryHeight.ts +38 -6
- package/src/hooks/useDisallowedEmojis.ts +23 -13
- package/src/hooks/useEmojiVirtualization.tsx +102 -66
- package/src/hooks/useFilter.ts +10 -8
- package/src/hooks/useIsEmojiHidden.ts +16 -12
- package/src/hooks/useKeyboardNavigation.ts +104 -17
- package/src/primitives/structuralStyles.tsx +3 -0
- package/src/primitives/tokens.ts +1 -0
- package/src/virtualization/virtualizationHelpers.ts +9 -2
- package/dist/esm/chunks/chunk-46BUDQLE.mjs +0 -228
- package/dist/esm/chunks/chunk-FQIJ4HBW.mjs +0 -25
- package/dist/esm/chunks/chunk-KQPOIRSC.mjs +0 -9305
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__esm
|
|
3
|
-
} from "./chunk-LO4TPPLH.mjs";
|
|
4
|
-
|
|
5
|
-
// src/data/defaultEmojiData.ts
|
|
6
|
-
function registerDefaultEmojiData(data) {
|
|
7
|
-
registered = data;
|
|
8
|
-
}
|
|
9
|
-
function getRegisteredDefaultEmojiData() {
|
|
10
|
-
return registered;
|
|
11
|
-
}
|
|
12
|
-
function defaultEmojiDataOrEmpty() {
|
|
13
|
-
return registered ?? EMPTY_EMOJI_DATA;
|
|
14
|
-
}
|
|
15
|
-
function loadDefaultEmojiData() {
|
|
16
|
-
if (registered) {
|
|
17
|
-
return Promise.resolve(registered);
|
|
18
|
-
}
|
|
19
|
-
if (!pending) {
|
|
20
|
-
pending = import("./emojis-6L3GRBAP.mjs").then((module) => {
|
|
21
|
-
const data = module.default ?? module;
|
|
22
|
-
registered = registered ?? data;
|
|
23
|
-
return registered;
|
|
24
|
-
}).catch((error) => {
|
|
25
|
-
pending = null;
|
|
26
|
-
throw error;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return pending;
|
|
30
|
-
}
|
|
31
|
-
var registered, EMPTY_EMOJI_DATA, pending;
|
|
32
|
-
var init_defaultEmojiData = __esm({
|
|
33
|
-
"src/data/defaultEmojiData.ts"() {
|
|
34
|
-
"use strict";
|
|
35
|
-
registered = null;
|
|
36
|
-
EMPTY_EMOJI_DATA = Object.freeze({
|
|
37
|
-
categories: {},
|
|
38
|
-
emojis: {}
|
|
39
|
-
});
|
|
40
|
-
pending = null;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// src/data-core/prepare.ts
|
|
45
|
-
init_defaultEmojiData();
|
|
46
|
-
|
|
47
|
-
// src/dataUtils/parseNativeEmoji.ts
|
|
48
|
-
function parseNativeEmoji(unified) {
|
|
49
|
-
return unified.split("-").map((hex) => String.fromCodePoint(parseInt(hex, 16))).join("");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/data-core/prepare.ts
|
|
53
|
-
var coreCache = /* @__PURE__ */ new WeakMap();
|
|
54
|
-
var prepareCount = 0;
|
|
55
|
-
function normalizeUnified(input) {
|
|
56
|
-
return input.trim().toLowerCase();
|
|
57
|
-
}
|
|
58
|
-
function normalizeQuery(input) {
|
|
59
|
-
if (!input || typeof input !== "string") {
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
return input.trim().toLowerCase();
|
|
63
|
-
}
|
|
64
|
-
function toEmojiInfo(unified, names, variations, addedIn) {
|
|
65
|
-
return Object.freeze({
|
|
66
|
-
unified,
|
|
67
|
-
emoji: parseNativeEmoji(unified),
|
|
68
|
-
name: names[names.length - 1] || "",
|
|
69
|
-
names: Object.freeze([...names]),
|
|
70
|
-
variations: Object.freeze([...variations ?? []]),
|
|
71
|
-
addedIn
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function readStringArray(raw) {
|
|
75
|
-
if (!Array.isArray(raw)) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
return raw.filter((n) => typeof n === "string").map(
|
|
79
|
-
(n) => n.toLowerCase()
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
function appendEntry(byUnified, byCharMutable, records, entry) {
|
|
83
|
-
const rawUnified = entry.u;
|
|
84
|
-
if (typeof rawUnified !== "string" || rawUnified.length === 0) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const unified = rawUnified.toLowerCase();
|
|
88
|
-
if (byUnified.has(unified)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const names = readStringArray(entry.n);
|
|
92
|
-
const variations = readStringArray(entry.v);
|
|
93
|
-
const rawAddedIn = entry.a;
|
|
94
|
-
const addedIn = typeof rawAddedIn === "string" ? rawAddedIn : String(rawAddedIn ?? "");
|
|
95
|
-
const info = toEmojiInfo(unified, names, variations, addedIn);
|
|
96
|
-
records.push(info);
|
|
97
|
-
byUnified.set(unified, info);
|
|
98
|
-
for (const variation of info.variations) {
|
|
99
|
-
if (!byUnified.has(variation)) {
|
|
100
|
-
byUnified.set(variation, info);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
indexCharBucket(byCharMutable, names, info);
|
|
104
|
-
}
|
|
105
|
-
function indexCharBucket(byCharMutable, names, info) {
|
|
106
|
-
const distinctChars = Array.from(new Set(names.join("")));
|
|
107
|
-
for (const char of distinctChars) {
|
|
108
|
-
const bucket = byCharMutable.get(char);
|
|
109
|
-
if (bucket) {
|
|
110
|
-
bucket.push(info);
|
|
111
|
-
} else {
|
|
112
|
-
byCharMutable.set(char, [info]);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function getPreparedCore(emojiData) {
|
|
117
|
-
const source = emojiData ?? defaultEmojiDataOrEmpty();
|
|
118
|
-
const cached = coreCache.get(source);
|
|
119
|
-
if (cached) {
|
|
120
|
-
return cached;
|
|
121
|
-
}
|
|
122
|
-
prepareCount += 1;
|
|
123
|
-
const byUnified = /* @__PURE__ */ new Map();
|
|
124
|
-
const byCharMutable = /* @__PURE__ */ new Map();
|
|
125
|
-
const records = [];
|
|
126
|
-
const groups = source.emojis ?? {};
|
|
127
|
-
for (const key of Object.keys(groups)) {
|
|
128
|
-
const list = groups[key] ?? [];
|
|
129
|
-
for (const entry of list) {
|
|
130
|
-
appendEntry(byUnified, byCharMutable, records, entry);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const byChar = /* @__PURE__ */ new Map();
|
|
134
|
-
byCharMutable.forEach((bucket, char) => {
|
|
135
|
-
byChar.set(char, Object.freeze(bucket));
|
|
136
|
-
});
|
|
137
|
-
const core = {
|
|
138
|
-
records,
|
|
139
|
-
byUnified,
|
|
140
|
-
byChar,
|
|
141
|
-
queryMemo: /* @__PURE__ */ new Map()
|
|
142
|
-
};
|
|
143
|
-
coreCache.set(source, core);
|
|
144
|
-
return core;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// src/data-core/search.ts
|
|
148
|
-
var EMPTY_RESULTS = Object.freeze([]);
|
|
149
|
-
var MAX_QUERY_MEMO_SIZE = 500;
|
|
150
|
-
function memoizeQuery(core, normalized, results) {
|
|
151
|
-
const memo = core.queryMemo;
|
|
152
|
-
if (memo.has(normalized)) {
|
|
153
|
-
memo.delete(normalized);
|
|
154
|
-
} else if (memo.size >= MAX_QUERY_MEMO_SIZE) {
|
|
155
|
-
const oldest = memo.keys().next();
|
|
156
|
-
if (!oldest.done) {
|
|
157
|
-
memo.delete(oldest.value);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
memo.set(normalized, results);
|
|
161
|
-
}
|
|
162
|
-
function smallestCandidateBucket(core, normalized) {
|
|
163
|
-
let smallest = core.records;
|
|
164
|
-
for (const char of Array.from(normalized)) {
|
|
165
|
-
const bucket = core.byChar.get(char);
|
|
166
|
-
if (!bucket) {
|
|
167
|
-
return EMPTY_RESULTS;
|
|
168
|
-
}
|
|
169
|
-
if (bucket.length < smallest.length) {
|
|
170
|
-
smallest = bucket;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return smallest;
|
|
174
|
-
}
|
|
175
|
-
function getEmojiByUnified(unified, options) {
|
|
176
|
-
if (!unified || typeof unified !== "string") {
|
|
177
|
-
return void 0;
|
|
178
|
-
}
|
|
179
|
-
const normalized = normalizeUnified(unified);
|
|
180
|
-
if (!normalized) {
|
|
181
|
-
return void 0;
|
|
182
|
-
}
|
|
183
|
-
const core = getPreparedCore(options?.emojiData);
|
|
184
|
-
return core.byUnified.get(normalized);
|
|
185
|
-
}
|
|
186
|
-
function searchEmojis(query, options) {
|
|
187
|
-
const normalized = normalizeQuery(query);
|
|
188
|
-
if (!normalized) {
|
|
189
|
-
return EMPTY_RESULTS;
|
|
190
|
-
}
|
|
191
|
-
const core = getPreparedCore(options?.emojiData);
|
|
192
|
-
const memoized = core.queryMemo.get(normalized);
|
|
193
|
-
if (memoized) {
|
|
194
|
-
memoizeQuery(core, normalized, memoized);
|
|
195
|
-
return Object.freeze([...memoized]);
|
|
196
|
-
}
|
|
197
|
-
if (normalized.length === 1) {
|
|
198
|
-
const bucket = core.byChar.get(normalized) ?? EMPTY_RESULTS;
|
|
199
|
-
memoizeQuery(core, normalized, bucket);
|
|
200
|
-
return Object.freeze([...bucket]);
|
|
201
|
-
}
|
|
202
|
-
const matches = [];
|
|
203
|
-
for (const record of smallestCandidateBucket(core, normalized)) {
|
|
204
|
-
const names = record.names;
|
|
205
|
-
for (let i = 0; i < names.length; i += 1) {
|
|
206
|
-
if (names[i].includes(normalized)) {
|
|
207
|
-
matches.push(record);
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
memoizeQuery(core, normalized, matches);
|
|
213
|
-
return Object.freeze([...matches]);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export {
|
|
217
|
-
registerDefaultEmojiData,
|
|
218
|
-
getRegisteredDefaultEmojiData,
|
|
219
|
-
EMPTY_EMOJI_DATA,
|
|
220
|
-
defaultEmojiDataOrEmpty,
|
|
221
|
-
loadDefaultEmojiData,
|
|
222
|
-
init_defaultEmojiData,
|
|
223
|
-
parseNativeEmoji,
|
|
224
|
-
normalizeQuery,
|
|
225
|
-
getPreparedCore,
|
|
226
|
-
getEmojiByUnified,
|
|
227
|
-
searchEmojis
|
|
228
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_defaultEmojiData,
|
|
3
|
-
registerDefaultEmojiData
|
|
4
|
-
} from "./chunk-46BUDQLE.mjs";
|
|
5
|
-
import {
|
|
6
|
-
emojis_default,
|
|
7
|
-
init_emojis
|
|
8
|
-
} from "./chunk-7ZGTUZFB.mjs";
|
|
9
|
-
import {
|
|
10
|
-
__commonJS
|
|
11
|
-
} from "./chunk-LO4TPPLH.mjs";
|
|
12
|
-
|
|
13
|
-
// src/data/registerDefaultEmojiData.ts
|
|
14
|
-
var require_registerDefaultEmojiData = __commonJS({
|
|
15
|
-
"src/data/registerDefaultEmojiData.ts"() {
|
|
16
|
-
"use strict";
|
|
17
|
-
init_defaultEmojiData();
|
|
18
|
-
init_emojis();
|
|
19
|
-
registerDefaultEmojiData(emojis_default);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
require_registerDefaultEmojiData
|
|
25
|
-
};
|