emoji-picker-react 5.0.0 → 5.0.1
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/esm/chunks/chunk-7ZGTUZFB.mjs +8021 -12
- package/dist/esm/chunks/chunk-ACXAQEKG.mjs +149 -0
- package/dist/esm/chunks/chunk-F2KS7DCA.mjs +6735 -0
- package/dist/esm/chunks/chunk-L5W4PFRJ.mjs +14 -0
- package/dist/esm/chunks/chunk-LO4TPPLH.mjs +32 -42
- 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 +0 -4
- 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 +6 -3
- package/package.json +1 -1
- 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 +5 -1
- package/src/components/header/Search/Search.tsx +4 -2
- package/src/components/main/defaultAppearance.tsx +2 -1
- package/src/data/skinToneVariations.ts +8 -7
- package/src/data-core/pickerData.ts +1 -3
- package/src/data-core/prepare.ts +20 -35
- package/src/dataUtils/emojiSelectors.ts +2 -1
- package/src/dataUtils/parseNativeEmoji.ts +3 -4
- package/src/hooks/preloadEmoji.ts +1 -46
- package/src/hooks/useActiveCategoryScrollDetection.ts +22 -19
- package/src/hooks/useCategoryHeight.ts +38 -6
- package/src/hooks/useDisallowedEmojis.ts +18 -13
- package/src/hooks/useEmojiVirtualization.tsx +93 -67
- 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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { __esm } from "./chunk-LO4TPPLH.mjs";
|
|
2
|
+
|
|
3
|
+
// src/data/defaultEmojiData.ts
|
|
4
|
+
function registerDefaultEmojiData(data) {
|
|
5
|
+
registered = data;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getRegisteredDefaultEmojiData() {
|
|
9
|
+
return registered;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function defaultEmojiDataOrEmpty() {
|
|
13
|
+
return registered ?? EMPTY_EMOJI_DATA;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function loadDefaultEmojiData() {
|
|
17
|
+
return registered ? Promise.resolve(registered) : (pending || (pending = import("./emojis-6L3GRBAP.mjs").then((module => {
|
|
18
|
+
const data = module.default ?? module;
|
|
19
|
+
return registered = registered ?? data;
|
|
20
|
+
})).catch((error => {
|
|
21
|
+
throw pending = null, error;
|
|
22
|
+
}))), pending);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var registered, EMPTY_EMOJI_DATA, pending, init_defaultEmojiData = __esm({
|
|
26
|
+
"src/data/defaultEmojiData.ts"() {
|
|
27
|
+
registered = null, EMPTY_EMOJI_DATA = Object.freeze({
|
|
28
|
+
categories: {},
|
|
29
|
+
emojis: {}
|
|
30
|
+
}), pending = null;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// src/dataUtils/parseNativeEmoji.ts
|
|
35
|
+
function parseNativeEmoji(unified) {
|
|
36
|
+
return String.fromCodePoint(...unified.split("-").map((hex => parseInt(hex, 16))));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/data-core/prepare.ts
|
|
40
|
+
// src/data-core/prepare.ts
|
|
41
|
+
init_defaultEmojiData();
|
|
42
|
+
|
|
43
|
+
var coreCache = /* @__PURE__ */ new WeakMap, prepareCount = 0;
|
|
44
|
+
|
|
45
|
+
function normalizeUnified(input) {
|
|
46
|
+
return input.trim().toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function normalizeQuery(input) {
|
|
50
|
+
return input && "string" == typeof input ? input.trim().toLowerCase() : "";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readStringArray(raw) {
|
|
54
|
+
return Array.isArray(raw) ? raw.filter((value => "string" == typeof value)).map((value => value.toLowerCase())) : [];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function appendEntry(byUnified, byCharMutable, records, entry) {
|
|
58
|
+
const rawUnified = entry.u;
|
|
59
|
+
if ("string" != typeof rawUnified || 0 === rawUnified.length) return;
|
|
60
|
+
const unified = rawUnified.toLowerCase();
|
|
61
|
+
if (byUnified.has(unified)) return;
|
|
62
|
+
const names = readStringArray(entry.n), variations = readStringArray(entry.v), addedIn = String(entry.a ?? ""), info = Object.freeze({
|
|
63
|
+
unified,
|
|
64
|
+
emoji: parseNativeEmoji(unified),
|
|
65
|
+
name: names[names.length - 1] || "",
|
|
66
|
+
names: Object.freeze(names),
|
|
67
|
+
variations: Object.freeze(variations),
|
|
68
|
+
addedIn
|
|
69
|
+
});
|
|
70
|
+
records.push(info), byUnified.set(unified, info);
|
|
71
|
+
for (const variation of info.variations) byUnified.has(variation) || byUnified.set(variation, info);
|
|
72
|
+
indexCharBucket(byCharMutable, names, info);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function indexCharBucket(byCharMutable, names, info) {
|
|
76
|
+
for (const char of names.join("")) {
|
|
77
|
+
const bucket = byCharMutable.get(char);
|
|
78
|
+
bucket ? bucket[bucket.length - 1] !== info && bucket.push(info) : byCharMutable.set(char, [ info ]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getPreparedCore(emojiData) {
|
|
83
|
+
const source = emojiData ?? defaultEmojiDataOrEmpty(), cached = coreCache.get(source);
|
|
84
|
+
if (cached) return cached;
|
|
85
|
+
prepareCount += 1;
|
|
86
|
+
const byUnified = /* @__PURE__ */ new Map, byCharMutable = /* @__PURE__ */ new Map, records = [], groups = source.emojis ?? {};
|
|
87
|
+
for (const key of Object.keys(groups)) {
|
|
88
|
+
const list = groups[key] ?? [];
|
|
89
|
+
for (const entry of list) appendEntry(byUnified, byCharMutable, records, entry);
|
|
90
|
+
}
|
|
91
|
+
byCharMutable.forEach(Object.freeze);
|
|
92
|
+
const core = {
|
|
93
|
+
records,
|
|
94
|
+
byUnified,
|
|
95
|
+
byChar: byCharMutable,
|
|
96
|
+
queryMemo: /* @__PURE__ */ new Map
|
|
97
|
+
};
|
|
98
|
+
return coreCache.set(source, core), core;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/data-core/search.ts
|
|
102
|
+
var EMPTY_RESULTS = Object.freeze([]), MAX_QUERY_MEMO_SIZE = 500;
|
|
103
|
+
|
|
104
|
+
function memoizeQuery(core, normalized, results) {
|
|
105
|
+
const memo = core.queryMemo;
|
|
106
|
+
if (memo.has(normalized)) memo.delete(normalized); else if (memo.size >= MAX_QUERY_MEMO_SIZE) {
|
|
107
|
+
const oldest = memo.keys().next();
|
|
108
|
+
oldest.done || memo.delete(oldest.value);
|
|
109
|
+
}
|
|
110
|
+
memo.set(normalized, results);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function smallestCandidateBucket(core, normalized) {
|
|
114
|
+
let smallest = core.records;
|
|
115
|
+
for (const char of Array.from(normalized)) {
|
|
116
|
+
const bucket = core.byChar.get(char);
|
|
117
|
+
if (!bucket) return EMPTY_RESULTS;
|
|
118
|
+
bucket.length < smallest.length && (smallest = bucket);
|
|
119
|
+
}
|
|
120
|
+
return smallest;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getEmojiByUnified(unified, options) {
|
|
124
|
+
if (!unified || "string" != typeof unified) return;
|
|
125
|
+
const normalized = normalizeUnified(unified);
|
|
126
|
+
return normalized ? getPreparedCore(options?.emojiData).byUnified.get(normalized) : void 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function searchEmojis(query, options) {
|
|
130
|
+
const normalized = normalizeQuery(query);
|
|
131
|
+
if (!normalized) return EMPTY_RESULTS;
|
|
132
|
+
const core = getPreparedCore(options?.emojiData), memoized = core.queryMemo.get(normalized);
|
|
133
|
+
if (memoized) return memoizeQuery(core, normalized, memoized), Object.freeze([ ...memoized ]);
|
|
134
|
+
if (1 === normalized.length) {
|
|
135
|
+
const bucket = core.byChar.get(normalized) ?? EMPTY_RESULTS;
|
|
136
|
+
return memoizeQuery(core, normalized, bucket), Object.freeze([ ...bucket ]);
|
|
137
|
+
}
|
|
138
|
+
const matches = [];
|
|
139
|
+
for (const record of smallestCandidateBucket(core, normalized)) {
|
|
140
|
+
const names = record.names;
|
|
141
|
+
for (let i = 0; i < names.length; i += 1) if (names[i].includes(normalized)) {
|
|
142
|
+
matches.push(record);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return memoizeQuery(core, normalized, matches), Object.freeze([ ...matches ]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { registerDefaultEmojiData, getRegisteredDefaultEmojiData, EMPTY_EMOJI_DATA, defaultEmojiDataOrEmpty, loadDefaultEmojiData, init_defaultEmojiData, parseNativeEmoji, normalizeQuery, getPreparedCore, getEmojiByUnified, searchEmojis };
|