emoji-picker-react 5.1.0 → 5.1.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.
Files changed (34) hide show
  1. package/README.md +29 -1
  2. package/dist/DomUtils/classNames.d.ts +0 -1
  3. package/dist/DomUtils/keyboardNavigation.d.ts +5 -1
  4. package/dist/DomUtils/selectors.d.ts +2 -2
  5. package/dist/config/defaultPickerConfiguration.d.ts +1 -1
  6. package/dist/data/index.js +1 -1
  7. package/dist/data/skinToneVariations.js +2 -2
  8. package/dist/data-core/prepare.d.ts +6 -0
  9. package/dist/esm/chunks/chunk-FYMRCRY5.mjs +6818 -0
  10. package/dist/esm/chunks/chunk-GZYF2CX5.mjs +6 -0
  11. package/dist/esm/chunks/chunk-V7DBC3DD.mjs +151 -0
  12. package/dist/esm/chunks/chunk-ZOAKI5M6.mjs +8025 -18
  13. package/dist/esm/chunks/deferredPicker-A6MWDDKH.mjs +113 -0
  14. package/dist/esm/chunks/emojis-VTEL5M5C.mjs +3 -6
  15. package/dist/esm/data.mjs +6 -9
  16. package/dist/esm/index.mjs +226 -333
  17. package/dist/esm/primitives/index.mjs +5 -65
  18. package/dist/hooks/preloadEmoji.d.ts +0 -4
  19. package/dist/hooks/searchHighlight.d.ts +3 -5
  20. package/dist/hooks/useCategoryHeight.d.ts +2 -1
  21. package/dist/hooks/useEmojiVirtualization.d.ts +1 -0
  22. package/dist/index.js +1 -1
  23. package/dist/primitives/Root.d.ts +2 -2
  24. package/dist/primitives/index.d.mts +2 -2
  25. package/dist/primitives/index.d.ts +2 -2
  26. package/dist/primitives/index.js +1 -1
  27. package/dist/virtualization/virtualizationHelpers.d.ts +2 -0
  28. package/llms-full.txt +184 -21
  29. package/llms.txt +1 -0
  30. package/package.json +1 -1
  31. package/dist/esm/chunks/chunk-3NQHPTFV.mjs +0 -9
  32. package/dist/esm/chunks/chunk-FJVAS6PR.mjs +0 -214
  33. package/dist/esm/chunks/chunk-L4H5QY3X.mjs +0 -9509
  34. package/dist/esm/chunks/searchHighlight-7NH7OJ5Q.mjs +0 -134
@@ -0,0 +1,6 @@
1
+ import { registerDefaultEmojiData } from "./chunk-V7DBC3DD.mjs";
2
+
3
+ import { emojis_default } from "./chunk-ZOAKI5M6.mjs";
4
+
5
+ // src/data/registerDefaultEmojiData.ts
6
+ registerDefaultEmojiData(emojis_default);
@@ -0,0 +1,151 @@
1
+ // src/data/defaultEmojiData.ts
2
+ var registered = null;
3
+
4
+ function registerDefaultEmojiData(data) {
5
+ registered = data;
6
+ }
7
+
8
+ function getRegisteredDefaultEmojiData() {
9
+ return registered;
10
+ }
11
+
12
+ var EMPTY_EMOJI_DATA = Object.freeze({
13
+ categories: {},
14
+ emojis: {}
15
+ });
16
+
17
+ function defaultEmojiDataOrEmpty() {
18
+ return registered ?? EMPTY_EMOJI_DATA;
19
+ }
20
+
21
+ var pending = null;
22
+
23
+ function loadDefaultEmojiData() {
24
+ return registered ? Promise.resolve(registered) : (pending || (pending = import("./emojis-VTEL5M5C.mjs").then((module => {
25
+ const data = module.default ?? module;
26
+ return registered = registered ?? data;
27
+ })).catch((error => {
28
+ throw pending = null, error;
29
+ }))), pending);
30
+ }
31
+
32
+ // src/dataUtils/parseNativeEmoji.ts
33
+ function parseNativeEmoji(unified) {
34
+ return String.fromCodePoint(...unified.split("-").map((hex => parseInt(hex, 16))));
35
+ }
36
+
37
+ // src/data-core/prepare.ts
38
+ var coreCache = /* @__PURE__ */ new WeakMap, prepareCount = 0;
39
+
40
+ function normalizeUnified(input) {
41
+ return input.trim().toLowerCase();
42
+ }
43
+
44
+ function withoutFe0f(unified) {
45
+ return unified.replace(/-fe0f/g, "");
46
+ }
47
+
48
+ function normalizeQuery(input) {
49
+ return input && "string" == typeof input ? input.trim().toLowerCase() : "";
50
+ }
51
+
52
+ function readStringArray(raw) {
53
+ return Array.isArray(raw) ? raw.filter((value => "string" == typeof value)).map((value => value.toLowerCase())) : [];
54
+ }
55
+
56
+ function appendEntry(byUnified, byCharMutable, records, entry) {
57
+ const rawUnified = entry.u;
58
+ if ("string" != typeof rawUnified || 0 === rawUnified.length) return;
59
+ const unified = rawUnified.toLowerCase();
60
+ if (byUnified.has(unified)) return;
61
+ const names = readStringArray(entry.n), variations = readStringArray(entry.v), addedIn = String(entry.a ?? ""), info = Object.freeze({
62
+ unified,
63
+ emoji: parseNativeEmoji(unified),
64
+ name: names[names.length - 1] || "",
65
+ names: Object.freeze(names),
66
+ variations: Object.freeze(variations),
67
+ addedIn
68
+ });
69
+ records.push(info), byUnified.set(unified, info);
70
+ for (const id of [ unified, ...info.variations ]) byUnified.has(id) || byUnified.set(id, info),
71
+ byUnified.has(withoutFe0f(id)) || byUnified.set(withoutFe0f(id), 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
+ if (!normalized) return;
127
+ const core = getPreparedCore(options?.emojiData);
128
+ return core.byUnified.get(normalized) ?? core.byUnified.get(withoutFe0f(normalized));
129
+ }
130
+
131
+ function searchEmojis(query, options) {
132
+ const normalized = normalizeQuery(query);
133
+ if (!normalized) return EMPTY_RESULTS;
134
+ const core = getPreparedCore(options?.emojiData), memoized = core.queryMemo.get(normalized);
135
+ if (memoized) return memoizeQuery(core, normalized, memoized), Object.freeze([ ...memoized ]);
136
+ if (1 === normalized.length) {
137
+ const bucket = core.byChar.get(normalized) ?? EMPTY_RESULTS;
138
+ return memoizeQuery(core, normalized, bucket), Object.freeze([ ...bucket ]);
139
+ }
140
+ const matches = [];
141
+ for (const record of smallestCandidateBucket(core, normalized)) {
142
+ const names = record.names;
143
+ for (let i = 0; i < names.length; i += 1) if (names[i].includes(normalized)) {
144
+ matches.push(record);
145
+ break;
146
+ }
147
+ }
148
+ return memoizeQuery(core, normalized, matches), Object.freeze([ ...matches ]);
149
+ }
150
+
151
+ export { registerDefaultEmojiData, getRegisteredDefaultEmojiData, EMPTY_EMOJI_DATA, defaultEmojiDataOrEmpty, loadDefaultEmojiData, parseNativeEmoji, withoutFe0f, normalizeQuery, getPreparedCore, getEmojiByUnified, searchEmojis };