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.
- package/README.md +29 -1
- package/dist/DomUtils/classNames.d.ts +0 -1
- package/dist/DomUtils/keyboardNavigation.d.ts +5 -1
- package/dist/DomUtils/selectors.d.ts +2 -2
- package/dist/config/defaultPickerConfiguration.d.ts +1 -1
- package/dist/data/index.js +1 -1
- package/dist/data/skinToneVariations.js +2 -2
- package/dist/data-core/prepare.d.ts +6 -0
- package/dist/esm/chunks/chunk-FYMRCRY5.mjs +6818 -0
- package/dist/esm/chunks/chunk-GZYF2CX5.mjs +6 -0
- package/dist/esm/chunks/chunk-V7DBC3DD.mjs +151 -0
- package/dist/esm/chunks/chunk-ZOAKI5M6.mjs +8025 -18
- package/dist/esm/chunks/deferredPicker-A6MWDDKH.mjs +113 -0
- package/dist/esm/chunks/emojis-VTEL5M5C.mjs +3 -6
- package/dist/esm/data.mjs +6 -9
- package/dist/esm/index.mjs +226 -333
- package/dist/esm/primitives/index.mjs +5 -65
- package/dist/hooks/preloadEmoji.d.ts +0 -4
- package/dist/hooks/searchHighlight.d.ts +3 -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/Root.d.ts +2 -2
- package/dist/primitives/index.d.mts +2 -2
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +1 -1
- package/dist/virtualization/virtualizationHelpers.d.ts +2 -0
- package/llms-full.txt +184 -21
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/dist/esm/chunks/chunk-3NQHPTFV.mjs +0 -9
- package/dist/esm/chunks/chunk-FJVAS6PR.mjs +0 -214
- package/dist/esm/chunks/chunk-L4H5QY3X.mjs +0 -9509
- package/dist/esm/chunks/searchHighlight-7NH7OJ5Q.mjs +0 -134
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/hooks/searchHighlight.ts
|
|
2
|
+
var HIGHLIGHTED = "data-epr-highlighted", ACTIVE_DESCENDANT = "aria-activedescendant", unmountWatchers = /* @__PURE__ */ new WeakMap, ARROWS = [ "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft" ], OPPOSITE = {
|
|
3
|
+
ArrowDown: "ArrowUp",
|
|
4
|
+
ArrowUp: "ArrowDown",
|
|
5
|
+
ArrowRight: "ArrowLeft",
|
|
6
|
+
ArrowLeft: "ArrowRight"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function createSearchHighlight(...[main, body, input, registry, setActiveEmoji, allUnifiedFromEmojiElement, caretAtEdge, firstVisibleEmoji, focusAdjacentEmoji, getRegionInDirection, idRef, focusFirstEmoji]) {
|
|
10
|
+
const wanted = () => !!input.current?.hasAttribute(ACTIVE_DESCENDANT), highlighted = () => highlightedEmoji(body.current), highlight = emoji => {
|
|
11
|
+
if (void 0 === emoji) {
|
|
12
|
+
const generation = registry.currentGeneration();
|
|
13
|
+
return wanted() && (focusFirstEmoji(body.current, {
|
|
14
|
+
moveTo: highlight,
|
|
15
|
+
shouldFocus: () => registry.isCurrent(generation) && wanted()
|
|
16
|
+
}) || highlight(null));
|
|
17
|
+
}
|
|
18
|
+
return setActiveEmoji(emoji && allUnifiedFromEmojiElement(emoji)), highlightEmoji(emoji);
|
|
19
|
+
}, highlightEmoji = emoji => {
|
|
20
|
+
const before = wanted();
|
|
21
|
+
return highlighted()?.removeAttribute(HIGHLIGHTED), emoji?.setAttribute(HIGHLIGHTED, ""),
|
|
22
|
+
emoji?.scrollIntoView?.({
|
|
23
|
+
block: "nearest"
|
|
24
|
+
}), idRef(input.current, ACTIVE_DESCENDANT, emoji), watchUnmount(body.current, input.current, emoji),
|
|
25
|
+
before;
|
|
26
|
+
}, arrowTowardGrid = () => ARROWS.find((key => "grid" === getRegionInDirection(registry, main.current, "search", {
|
|
27
|
+
key,
|
|
28
|
+
prefer: "grid"
|
|
29
|
+
})?.kind)) ?? "ArrowDown";
|
|
30
|
+
return {
|
|
31
|
+
highlight,
|
|
32
|
+
highlighted,
|
|
33
|
+
// Arrows move the highlight instead of focus, so the caret stays in
|
|
34
|
+
// the input. The arrow toward the grid starts it (ArrowUp when the
|
|
35
|
+
// grid is above the input; Left or Right beside it, with the caret at
|
|
36
|
+
// that edge of the text); otherwise Left/Right edit text until a cell
|
|
37
|
+
// is highlighted. `key` is the logical arrow, `direction` its non-zero
|
|
38
|
+
// step. Returns whether the key was taken.
|
|
39
|
+
move(event, key, direction, searching) {
|
|
40
|
+
const current = highlighted(), towardGrid = arrowTowardGrid(), row = "ArrowDown" === key || "ArrowUp" === key;
|
|
41
|
+
if (!wanted() && (event.key !== towardGrid || !row && !caretAtEdge(input.current, "ArrowRight" === key))) return !1;
|
|
42
|
+
if (event.preventDefault(), !current) return input.current?.setAttribute(ACTIVE_DESCENDANT, ""),
|
|
43
|
+
highlight(searching ? void 0 : firstVisibleEmoji(body.current)), !0;
|
|
44
|
+
const generation = registry.currentGeneration();
|
|
45
|
+
return focusAdjacentEmoji(current, direction, row, {
|
|
46
|
+
// Escape or blur ended the highlight, or new results replaced the
|
|
47
|
+
// grid, before the move landed.
|
|
48
|
+
shouldFocus: () => registry.isCurrent(generation) && wanted()
|
|
49
|
+
// Past the grid edge that faces the input, the highlight ends.
|
|
50
|
+
,
|
|
51
|
+
exit: event.key === OPPOSITE[towardGrid] ? () => highlight(null) : void 0,
|
|
52
|
+
moveTo: highlight
|
|
53
|
+
}), !0;
|
|
54
|
+
},
|
|
55
|
+
// Leaving the search input ends the highlight.
|
|
56
|
+
blur(event) {
|
|
57
|
+
event.target === input.current && wanted() && highlight(null);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function highlightedEmoji(body) {
|
|
63
|
+
return body?.querySelector(`[${HIGHLIGHTED}]`) ?? null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function watchUnmount(body, input, emoji) {
|
|
67
|
+
if (!input) return;
|
|
68
|
+
if (unmountWatchers.get(input)?.disconnect(), !body || !emoji || "undefined" == typeof MutationObserver) return;
|
|
69
|
+
const watcher = new MutationObserver((() => {
|
|
70
|
+
emoji.isConnected || (watcher.disconnect(), input.getAttribute(ACTIVE_DESCENDANT) === emoji.id && input.setAttribute(ACTIVE_DESCENDANT, ""));
|
|
71
|
+
}));
|
|
72
|
+
watcher.observe(body, {
|
|
73
|
+
childList: !0,
|
|
74
|
+
subtree: !0
|
|
75
|
+
}), unmountWatchers.set(input, watcher);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/data-core/normalizeLoaderResult.ts
|
|
79
|
+
function isRecord(value) {
|
|
80
|
+
return !!value && "object" == typeof value && !Array.isArray(value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isStringArray(value) {
|
|
84
|
+
return Array.isArray(value) && value.every((item => "string" == typeof item));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isUnified(value) {
|
|
88
|
+
return value.split("-").every((hex => /^[\da-f]{1,6}$/i.test(hex) && parseInt(hex, 16) <= 1114111));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function hasValidEncoding(value) {
|
|
92
|
+
return void 0 !== value.imgUrl ? "string" == typeof value.imgUrl : "string" == typeof value.u && isUnified(value.u) && (void 0 === value.v || isStringArray(value.v) && value.v.every(isUnified));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isEmoji(value) {
|
|
96
|
+
return isRecord(value) && "string" == typeof value.u && !!value.u && isStringArray(value.n) && value.n.length > 0 && "string" == typeof value.a && hasValidEncoding(value);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function isEmojiGroup(value) {
|
|
100
|
+
return Array.isArray(value) && value.every(isEmoji);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isCategory(value) {
|
|
104
|
+
return isRecord(value) && "string" == typeof value.category && "string" == typeof value.name;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function normalizeLoaderResult(result) {
|
|
108
|
+
const data = isRecord(result) && "default" in result ? result.default : result;
|
|
109
|
+
if (!(isRecord(data) && isRecord(data.categories) && isRecord(data.emojis) && Object.values(data.emojis).every(isEmojiGroup) && Object.values(data.categories).every(isCategory))) throw new Error("[emoji-picker-react] emojiData loader must resolve a dataset or { default: dataset }.");
|
|
110
|
+
return data;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { createSearchHighlight, normalizeLoaderResult };
|
package/dist/esm/data.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import "./chunks/chunk-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunks/chunk-FJVAS6PR.mjs";
|
|
1
|
+
import "./chunks/chunk-GZYF2CX5.mjs";
|
|
2
|
+
|
|
3
|
+
import { getEmojiByUnified, searchEmojis } from "./chunks/chunk-V7DBC3DD.mjs";
|
|
4
|
+
|
|
6
5
|
import "./chunks/chunk-ZOAKI5M6.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
searchEmojis
|
|
10
|
-
};
|
|
6
|
+
|
|
7
|
+
export { getEmojiByUnified, searchEmojis };
|