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
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// src/hooks/searchHighlight.ts
|
|
2
|
-
var HIGHLIGHTED = "data-epr-highlighted";
|
|
3
|
-
var ACTIVE_DESCENDANT = "aria-activedescendant";
|
|
4
|
-
var unmountWatchers = /* @__PURE__ */ new WeakMap();
|
|
5
|
-
var ARROWS = ["ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"];
|
|
6
|
-
var OPPOSITE = {
|
|
7
|
-
ArrowDown: "ArrowUp",
|
|
8
|
-
ArrowUp: "ArrowDown",
|
|
9
|
-
ArrowRight: "ArrowLeft",
|
|
10
|
-
ArrowLeft: "ArrowRight"
|
|
11
|
-
};
|
|
12
|
-
function createSearchHighlight(...[
|
|
13
|
-
main,
|
|
14
|
-
body,
|
|
15
|
-
input,
|
|
16
|
-
registry,
|
|
17
|
-
setActiveEmoji,
|
|
18
|
-
allUnifiedFromEmojiElement,
|
|
19
|
-
caretAtEdge,
|
|
20
|
-
firstVisibleEmoji,
|
|
21
|
-
focusAdjacentEmoji,
|
|
22
|
-
getRegionInDirection,
|
|
23
|
-
idRef,
|
|
24
|
-
categoryGeometry,
|
|
25
|
-
focusLogicalEmoji
|
|
26
|
-
]) {
|
|
27
|
-
const wanted = () => !!input.current?.hasAttribute(ACTIVE_DESCENDANT);
|
|
28
|
-
const highlighted = () => highlightedEmoji(body.current);
|
|
29
|
-
const moveToFirstEmoji = (options) => {
|
|
30
|
-
const category = Array.from(
|
|
31
|
-
body.current?.querySelectorAll(
|
|
32
|
-
'[data-epr-part="category"]'
|
|
33
|
-
) ?? []
|
|
34
|
-
).find((section) => categoryGeometry(section).count > 0);
|
|
35
|
-
if (category) focusLogicalEmoji(category, 0, options);
|
|
36
|
-
return !!category;
|
|
37
|
-
};
|
|
38
|
-
const highlight = (emoji) => {
|
|
39
|
-
if (emoji === void 0) {
|
|
40
|
-
const generation = registry.currentGeneration();
|
|
41
|
-
return wanted() && (moveToFirstEmoji({
|
|
42
|
-
moveTo: highlight,
|
|
43
|
-
shouldFocus: () => registry.isCurrent(generation) && wanted()
|
|
44
|
-
}) || highlight(null));
|
|
45
|
-
}
|
|
46
|
-
setActiveEmoji(
|
|
47
|
-
emoji && allUnifiedFromEmojiElement(emoji)
|
|
48
|
-
);
|
|
49
|
-
return highlightEmoji(emoji);
|
|
50
|
-
};
|
|
51
|
-
const highlightEmoji = (emoji) => {
|
|
52
|
-
const before = wanted();
|
|
53
|
-
highlighted()?.removeAttribute(HIGHLIGHTED);
|
|
54
|
-
emoji?.setAttribute(HIGHLIGHTED, "");
|
|
55
|
-
emoji?.scrollIntoView?.({ block: "nearest" });
|
|
56
|
-
idRef(input.current, ACTIVE_DESCENDANT, emoji);
|
|
57
|
-
watchUnmount(body.current, input.current, emoji);
|
|
58
|
-
return before;
|
|
59
|
-
};
|
|
60
|
-
const arrowTowardGrid = () => ARROWS.find(
|
|
61
|
-
(key) => getRegionInDirection(registry, main.current, "search", {
|
|
62
|
-
key,
|
|
63
|
-
prefer: "grid"
|
|
64
|
-
})?.kind === "grid"
|
|
65
|
-
) ?? "ArrowDown";
|
|
66
|
-
return {
|
|
67
|
-
highlight,
|
|
68
|
-
highlighted,
|
|
69
|
-
// Arrows move the highlight instead of focus, so the caret stays in
|
|
70
|
-
// the input. The arrow toward the grid starts it (ArrowUp when the
|
|
71
|
-
// grid is above the input; Left or Right beside it, with the caret at
|
|
72
|
-
// that edge of the text); otherwise Left/Right edit text until a cell
|
|
73
|
-
// is highlighted. `key` is the logical arrow, `direction` its non-zero
|
|
74
|
-
// step. Returns whether the key was taken.
|
|
75
|
-
move(event, key, direction, searching) {
|
|
76
|
-
const current = highlighted();
|
|
77
|
-
const towardGrid = arrowTowardGrid();
|
|
78
|
-
const row = key === "ArrowDown" || key === "ArrowUp";
|
|
79
|
-
if (!wanted() && (event.key !== towardGrid || !row && !caretAtEdge(input.current, key === "ArrowRight")))
|
|
80
|
-
return false;
|
|
81
|
-
event.preventDefault();
|
|
82
|
-
if (!current) {
|
|
83
|
-
input.current?.setAttribute(ACTIVE_DESCENDANT, "");
|
|
84
|
-
highlight(searching ? void 0 : firstVisibleEmoji(body.current));
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
const generation = registry.currentGeneration();
|
|
88
|
-
focusAdjacentEmoji(current, direction, row, {
|
|
89
|
-
// Escape or blur ended the highlight, or new results replaced the
|
|
90
|
-
// grid, before the move landed.
|
|
91
|
-
shouldFocus: () => registry.isCurrent(generation) && wanted(),
|
|
92
|
-
// Past the grid edge that faces the input, the highlight ends.
|
|
93
|
-
exit: event.key === OPPOSITE[towardGrid] ? () => highlight(null) : void 0,
|
|
94
|
-
moveTo: highlight
|
|
95
|
-
});
|
|
96
|
-
return true;
|
|
97
|
-
},
|
|
98
|
-
// Enter during a search with nothing highlighted selects the first
|
|
99
|
-
// result by its place in the results, wherever the grid is scrolled.
|
|
100
|
-
// Returns false when Enter selects something else.
|
|
101
|
-
selectFirst(searching) {
|
|
102
|
-
if (!searching || highlighted()) return false;
|
|
103
|
-
const generation = registry.currentGeneration();
|
|
104
|
-
moveToFirstEmoji({
|
|
105
|
-
shouldFocus: () => registry.isCurrent(generation),
|
|
106
|
-
moveTo: (emoji) => emoji.click()
|
|
107
|
-
});
|
|
108
|
-
return true;
|
|
109
|
-
},
|
|
110
|
-
// Leaving the search input ends the highlight.
|
|
111
|
-
blur(event) {
|
|
112
|
-
if (event.target === input.current && wanted()) highlight(null);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function highlightedEmoji(body) {
|
|
117
|
-
return body?.querySelector(`[${HIGHLIGHTED}]`) ?? null;
|
|
118
|
-
}
|
|
119
|
-
function watchUnmount(body, input, emoji) {
|
|
120
|
-
if (!input) return;
|
|
121
|
-
unmountWatchers.get(input)?.disconnect();
|
|
122
|
-
if (!body || !emoji || typeof MutationObserver === "undefined") return;
|
|
123
|
-
const watcher = new MutationObserver(() => {
|
|
124
|
-
if (emoji.isConnected) return;
|
|
125
|
-
watcher.disconnect();
|
|
126
|
-
if (input.getAttribute(ACTIVE_DESCENDANT) === emoji.id)
|
|
127
|
-
input.setAttribute(ACTIVE_DESCENDANT, "");
|
|
128
|
-
});
|
|
129
|
-
watcher.observe(body, { childList: true, subtree: true });
|
|
130
|
-
unmountWatchers.set(input, watcher);
|
|
131
|
-
}
|
|
132
|
-
export {
|
|
133
|
-
createSearchHighlight
|
|
134
|
-
};
|