emoji-picker-react 5.1.2 → 5.1.4
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 +1 -1
- package/dist/dataUtils/nativeEmojiSequenceSupport.d.ts +1 -1
- package/dist/esm/chunks/{chunk-FYMRCRY5.mjs → chunk-R7XJISCB.mjs} +40 -20
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/primitives/index.mjs +1 -1
- package/dist/hooks/useCategoryHeight.d.ts +1 -1
- package/dist/hooks/useEmojiVirtualization.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/primitives/index.js +1 -1
- package/llms-full.txt +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ See [PROPS.md](PROPS.md) for every prop.
|
|
|
66
66
|
- **Localized** — 28 emoji datasets; translate search, categories, previews, reactions, skin tones, loading errors and retry controls, including accessible announcements.
|
|
67
67
|
- **Emoji styles** — native (default), Apple, Google, Facebook, Twitter; native mode filters detected unsupported OS glyphs, including individual sequences and skin tones. See [detection limits](docs/v5/API.md#5c-native-emoji-support-detection).
|
|
68
68
|
- **Custom emojis** — image-based emojis, optionally in their own named groups.
|
|
69
|
-
- **Lean when you want** — the primitives entry loads the dataset on demand (a
|
|
69
|
+
- **Lean when you want** — the primitives entry loads the dataset on demand (a 35 KiB min+gz startup budget including ShipStyles; see the consumer gate); a framework-free data API for search and lookup.
|
|
70
70
|
- **Modern React** — React 16.8 through 19, SSR, React Server Components (`"use client"` entries), TypeScript types included; ships ES2020 for every browser since 2020 and any modern bundler.
|
|
71
71
|
|
|
72
72
|
> **Upgrading from v4?** Most code works unchanged; the default emoji style is now native, and markup, styling and package boundaries have changed. See [Migrating from v4](docs/v5/MIGRATION.md). The APIs on this page need `emoji-picker-react@5` or later.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const NATIVE_PROBE_BATCH =
|
|
1
|
+
export declare const NATIVE_PROBE_BATCH = 16;
|
|
2
2
|
/** One reusable canvas and result cache per detected document/font. */
|
|
3
3
|
export declare function createNativeEmojiSequenceSupport(ctx: CanvasRenderingContext2D, baselineWidth: number): {
|
|
4
4
|
prime: (ids: Iterable<string>) => void;
|
|
@@ -1100,13 +1100,22 @@ var useIsomorphicLayoutEffect = "undefined" != typeof window ? React.useLayoutEf
|
|
|
1100
1100
|
|
|
1101
1101
|
// src/Stylesheet/DedupedStyle.tsx
|
|
1102
1102
|
function DedupedStyle({css, nonce}) {
|
|
1103
|
-
const styleRef = React2.useRef(null), rootRef = React2.useRef(void 0), [owner, setOwner] = React2.useState(!0), syncRef = React2.useRef(void 0);
|
|
1103
|
+
const kept = "undefined" != typeof document && css.startsWith("@layer"), styleRef = React2.useRef(null), rootRef = React2.useRef(void 0), [owner, setOwner] = React2.useState(!0), syncRef = React2.useRef(void 0);
|
|
1104
1104
|
return useIsomorphicLayoutEffect((() => {
|
|
1105
1105
|
const style = styleRef.current, root = rootRef.current = rootRef.current || (style ? style.getRootNode() : void 0);
|
|
1106
1106
|
if (!root) return;
|
|
1107
1107
|
const byKey = claimsByRoot.get(root) || {};
|
|
1108
1108
|
claimsByRoot.set(root, byKey);
|
|
1109
|
-
const key = nonce + css
|
|
1109
|
+
const key = nonce + css;
|
|
1110
|
+
if (kept) {
|
|
1111
|
+
if (!byKey[key]) {
|
|
1112
|
+
byKey[key] = [];
|
|
1113
|
+
const sheet = style.cloneNode();
|
|
1114
|
+
sheet.textContent = css, (root.head || root).appendChild(sheet);
|
|
1115
|
+
}
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const claims = byKey[key] = byKey[key] || [], claim = {
|
|
1110
1119
|
update: () => setOwner(claims[0] === claim),
|
|
1111
1120
|
detached: () => !!styleRef.current && !styleRef.current.isConnected
|
|
1112
1121
|
}, sync = syncRef.current = () => {
|
|
@@ -1122,7 +1131,7 @@ function DedupedStyle({css, nonce}) {
|
|
|
1122
1131
|
nonce,
|
|
1123
1132
|
suppressHydrationWarning: !0,
|
|
1124
1133
|
dangerouslySetInnerHTML: {
|
|
1125
|
-
__html: css
|
|
1134
|
+
__html: kept ? "" : css
|
|
1126
1135
|
}
|
|
1127
1136
|
}) : null;
|
|
1128
1137
|
}
|
|
@@ -2006,7 +2015,7 @@ function formatSearchResultsLabel(labels, searchResultsCount) {
|
|
|
2006
2015
|
}
|
|
2007
2016
|
|
|
2008
2017
|
// src/dataUtils/nativeEmojiSequenceSupport.ts
|
|
2009
|
-
var CELL = 32, NATIVE_PROBE_BATCH =
|
|
2018
|
+
var CELL = 32, NATIVE_PROBE_BATCH = 16;
|
|
2010
2019
|
|
|
2011
2020
|
function createNativeEmojiSequenceSupport(ctx, baselineWidth) {
|
|
2012
2021
|
const results = /* @__PURE__ */ new Map, font = ctx.font;
|
|
@@ -2558,7 +2567,11 @@ function useNativeEmojiSupportState() {
|
|
|
2558
2567
|
const unified = emojiUnified(emoji), version = addedIn(emoji);
|
|
2559
2568
|
samples.has(version) || samples.set(version, unified), [ unified, ...emojiVariations(emoji) ].forEach((id => inventory.push([ id, version ])));
|
|
2560
2569
|
}));
|
|
2561
|
-
let timer,
|
|
2570
|
+
let timer, previousFont = null;
|
|
2571
|
+
const idle = !!view.requestIdleCallback, later = () => timer = idle ? view.requestIdleCallback(flush, {
|
|
2572
|
+
timeout: 500
|
|
2573
|
+
}) : view.setTimeout(flush), cancel = () => idle ? view.cancelIdleCallback(timer) : view.clearTimeout(timer);
|
|
2574
|
+
let detected, published = null;
|
|
2562
2575
|
const pending = /* @__PURE__ */ new Set, publish = next => {
|
|
2563
2576
|
const current = published;
|
|
2564
2577
|
current && inventory.every((([unified, version]) => isNativeEmojiSupported(next, unified, version) === isNativeEmojiSupported(current, unified, version))) || (published = next,
|
|
@@ -2566,17 +2579,17 @@ function useNativeEmojiSupportState() {
|
|
|
2566
2579
|
}, flush = () => {
|
|
2567
2580
|
if (timer = void 0, !detected) return;
|
|
2568
2581
|
const batch = Array.from(pending).slice(0, NATIVE_PROBE_BATCH);
|
|
2569
|
-
batch.forEach((unified => pending.delete(unified))), detected.prime(batch), pending.size ?
|
|
2582
|
+
batch.forEach((unified => pending.delete(unified))), detected.prime(batch), pending.size ? later() : publish(nativeSupportSnapshot(detected, samples));
|
|
2570
2583
|
};
|
|
2571
2584
|
requestRef.current = unifieds => {
|
|
2572
2585
|
unifieds.forEach((unified => {
|
|
2573
2586
|
requested.add(unified), detected && !detected.has(unified) && pending.add(unified);
|
|
2574
|
-
})), pending.size && void 0 === timer && (
|
|
2587
|
+
})), pending.size && void 0 === timer && later();
|
|
2575
2588
|
};
|
|
2576
2589
|
const probe2 = (refresh2 = !1) => {
|
|
2577
2590
|
const customFont = view.getComputedStyle(root).getPropertyValue("--epr-emoji-font-family").trim();
|
|
2578
2591
|
if (!refresh2 && customFont === previousFont) return;
|
|
2579
|
-
previousFont = customFont,
|
|
2592
|
+
previousFont = customFont, cancel(), timer = void 0, pending.clear();
|
|
2580
2593
|
const next = detectNativeEmojiSupport(customFont || void 0, refresh2, root.ownerDocument);
|
|
2581
2594
|
if (!("snapshot" in next)) return detected = void 0, published = null, setSnapshot(null),
|
|
2582
2595
|
void 0;
|
|
@@ -2590,7 +2603,7 @@ function useNativeEmojiSupportState() {
|
|
|
2590
2603
|
});
|
|
2591
2604
|
const fonts = root.ownerDocument.fonts, refresh = () => probe2(!0);
|
|
2592
2605
|
return fonts?.addEventListener("loadingdone", refresh), () => {
|
|
2593
|
-
|
|
2606
|
+
cancel(), detected = void 0, observer.disconnect(), fonts?.removeEventListener("loadingdone", refresh);
|
|
2594
2607
|
};
|
|
2595
2608
|
}), [ shouldDetect, PickerMainRef, allEmojis ]), [ shouldDetect && snapshot?.[1] === allEmojis ? snapshot[0] : null, request ];
|
|
2596
2609
|
}
|
|
@@ -6427,7 +6440,7 @@ function trackColumnCount(previousRef, emojisPerRow, registry) {
|
|
|
6427
6440
|
previousRef.current = emojisPerRow;
|
|
6428
6441
|
}
|
|
6429
6442
|
|
|
6430
|
-
function useCategoryHeight(emojiCount, ready = !0) {
|
|
6443
|
+
function useCategoryHeight(emojiCount, ready = !0, mounted) {
|
|
6431
6444
|
const EmojiListRef = useEmojiListRef(), BodyRef = useBodyRef(), [isReactionsMode] = useReactionsModeState(), PickerMainRef = usePickerMainRef(), emojiSizeRef = React58.useRef(void 0), emojisPerRowRef = React58.useRef(void 0), registry = useNavigationRegistry(), [visibleCategories] = useVisibleCategoriesState(), [emojiSizeFromContext] = useEmojiSizeState(), columns = useColumnsConfig(), [dimensions, setDimensions] = React58.useState(), computeAndSetDimensions = React58.useCallback((() => {
|
|
6432
6445
|
const listEl = EmojiListRef.current;
|
|
6433
6446
|
if (!listEl) return;
|
|
@@ -6448,7 +6461,7 @@ function useCategoryHeight(emojiCount, ready = !0) {
|
|
|
6448
6461
|
}), [ EmojiListRef, BodyRef, emojiCount, emojiSizeFromContext, registry, columns ]);
|
|
6449
6462
|
return useIsomorphicLayoutEffect((() => {
|
|
6450
6463
|
computeAndSetDimensions();
|
|
6451
|
-
}), [ emojiCount, isReactionsMode, computeAndSetDimensions, visibleCategories.length, dimensions, ready ]),
|
|
6464
|
+
}), [ emojiCount, isReactionsMode, computeAndSetDimensions, visibleCategories.length, dimensions, ready, mounted ]),
|
|
6452
6465
|
React58.useEffect((() => {
|
|
6453
6466
|
const listEl = EmojiListRef.current;
|
|
6454
6467
|
if (!listEl || "undefined" == typeof ResizeObserver) return;
|
|
@@ -6474,7 +6487,7 @@ function useCategoryHeight(emojiCount, ready = !0) {
|
|
|
6474
6487
|
}
|
|
6475
6488
|
|
|
6476
6489
|
// src/hooks/useEmojiVirtualization.tsx
|
|
6477
|
-
function useEmojiVirtualization({categoryEmojis, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned}) {
|
|
6490
|
+
function useEmojiVirtualization({categoryEmojis, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned, mounted}) {
|
|
6478
6491
|
const isEmojiHidden = useIsEmojiHidden(), lazyLoadEmojis = useLazyLoadEmojisConfig(), emojiStyle = useEmojiStyleConfig(), [activeSkinTone] = useActiveSkinToneState(), isEmojiDisallowed = useIsEmojiDisallowed(), getEmojiUrl = useGetEmojiUrlConfig(), skinTonesDisabled = useSkinTonesDisabledConfig(), variationsDisabled = useVariationsDisabledConfig(), showVariations = !skinTonesDisabled && !variationsDisabled, BodyRef = useBodyRef(), requestNativeProbe = useRequestNativeProbe(), probe2 = [], preloads = [], [committed, setCommitted] = React59.useState(!1), emojisToPush = React59.useMemo((() => {
|
|
6479
6492
|
const rendered = /* @__PURE__ */ new Set;
|
|
6480
6493
|
return categoryEmojis.filter((emoji => {
|
|
@@ -6483,7 +6496,7 @@ function useEmojiVirtualization({categoryEmojis, topOffset, onHeightReady, scrol
|
|
|
6483
6496
|
const unified = emojiUnified(emoji, activeSkinTone);
|
|
6484
6497
|
return !rendered.has(unified) && (rendered.add(unified), !0);
|
|
6485
6498
|
}));
|
|
6486
|
-
}), [ categoryEmojis, activeSkinTone, isEmojiHidden, isEmojiDisallowed ]), dimensions = useCategoryHeight(emojisToPush.length, isCategoryVisible && positioned);
|
|
6499
|
+
}), [ categoryEmojis, activeSkinTone, isEmojiHidden, isEmojiDisallowed ]), dimensions = useCategoryHeight(emojisToPush.length, isCategoryVisible && positioned, mounted);
|
|
6487
6500
|
useEffect26((() => {
|
|
6488
6501
|
dimensions || setCommitted(!0);
|
|
6489
6502
|
}), [ dimensions ]), useIsomorphicLayoutEffect((() => {
|
|
@@ -6650,9 +6663,11 @@ function EmojiList({scrollTop, outerRef, className, nativeProps}) {
|
|
|
6650
6663
|
...previous,
|
|
6651
6664
|
[categoryId]: height
|
|
6652
6665
|
}));
|
|
6653
|
-
}), []),
|
|
6666
|
+
}), []), [mounted, setMounted] = React62.useState(!1);
|
|
6667
|
+
useIsomorphicLayoutEffect((() => setMounted(!0)), []);
|
|
6668
|
+
const mergedRef = useMergedRefs(EmojiListRef, outerRef), getEmojisByCategory = useGetEmojisByCategory();
|
|
6654
6669
|
useRegisterRegion("grid", EmojiListRef);
|
|
6655
|
-
const labelHeight = getLabelHeight(EmojiListRef.current);
|
|
6670
|
+
const labelHeight = getLabelHeight(EmojiListRef.current), viewportHeight = BodyRef.current?.clientHeight ?? 0;
|
|
6656
6671
|
let topOffset = 0, positioned = !0;
|
|
6657
6672
|
/* @__PURE__ */
|
|
6658
6673
|
return React62.createElement("ul", {
|
|
@@ -6666,27 +6681,32 @@ function EmojiList({scrollTop, outerRef, className, nativeProps}) {
|
|
|
6666
6681
|
const category = categoryFromCategoryConfig(categoryConfig), categoryId = categoryIdFromCategoryConfig(categoryConfig), group = customGroupFromCategoryConfig(categoryConfig), currentOffset = topOffset, isPositioned = positioned;
|
|
6667
6682
|
positioned = positioned && categoryId in categoryHeights;
|
|
6668
6683
|
const categoryHeight = categoryHeights[categoryId];
|
|
6669
|
-
|
|
6684
|
+
categoryHeight && (topOffset += categoryHeight + labelHeight);
|
|
6685
|
+
const inView = positioned && currentOffset < scrollTop + viewportHeight && topOffset > scrollTop;
|
|
6686
|
+
/* @__PURE__ */
|
|
6687
|
+
return React62.createElement(RenderCategory, {
|
|
6670
6688
|
key: categoryId,
|
|
6671
6689
|
categoryEmojis: getEmojisByCategory(category, group),
|
|
6672
6690
|
categoryConfig,
|
|
6673
6691
|
topOffset: currentOffset,
|
|
6674
|
-
isCategoryVisible: 0 === index || visibleCategories.includes(categoryId),
|
|
6692
|
+
isCategoryVisible: 0 === index || inView || visibleCategories.includes(categoryId),
|
|
6675
6693
|
positioned: isPositioned,
|
|
6694
|
+
mounted,
|
|
6676
6695
|
onHeightReady,
|
|
6677
|
-
scrollTop: void 0 === categoryHeight ? scrollTop : Math.max(currentOffset -
|
|
6696
|
+
scrollTop: void 0 === categoryHeight ? scrollTop : Math.max(currentOffset - viewportHeight - (emojiSize || 40) * (OVERSCAN_ROWS + 1), Math.min(scrollTop, currentOffset + categoryHeight + (emojiSize || 40) * (OVERSCAN_ROWS + 1)))
|
|
6678
6697
|
});
|
|
6679
6698
|
})));
|
|
6680
6699
|
}
|
|
6681
6700
|
|
|
6682
|
-
var RenderCategory = /* @__PURE__ */ React62.memo((function RenderCategory2({categoryEmojis, categoryConfig, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned}) {
|
|
6701
|
+
var RenderCategory = /* @__PURE__ */ React62.memo((function RenderCategory2({categoryEmojis, categoryConfig, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned, mounted}) {
|
|
6683
6702
|
const categoryId = categoryIdFromCategoryConfig(categoryConfig), reportHeight = React62.useCallback((height => onHeightReady(categoryId, height)), [ categoryId, onHeightReady ]), {virtualizedCounter, emojis, dimensions, emojiCount} = useEmojiVirtualization({
|
|
6684
6703
|
categoryEmojis,
|
|
6685
6704
|
topOffset,
|
|
6686
6705
|
onHeightReady: reportHeight,
|
|
6687
6706
|
scrollTop,
|
|
6688
6707
|
isCategoryVisible,
|
|
6689
|
-
positioned
|
|
6708
|
+
positioned,
|
|
6709
|
+
mounted
|
|
6690
6710
|
});
|
|
6691
6711
|
/* @__PURE__ */
|
|
6692
6712
|
return React62.createElement(EmojiCategory, {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Categories, CategoryNav, DEFAULT_PICKER_HEIGHT, DEFAULT_PICKER_WIDTH, DefaultPickerConfiguration, EmojiStyle, Empty, List, LoadError, Loading, MutableConfigProvider, Panel, Preview, Reactions, Relative, Root, Search, SkinTone, SkinTonePickerLocation, SkinTones, SuggestionMode, Theme, ViewOnlyEmoji, Viewport, commonInteractionStyles, compareConfig, cx, defaultPickerTokens, emojiByUnified, isPickerBehaviorProp, resolveEmojiStyle, resolveSkinTonePickerLocation, stylesheet, useDefaultAppearance, useDefineMutableConfig, usePreviewConfig, useSearchDisabledConfig, useSkinTonePickerLocationConfig, useSkinTonesDisabledConfig, validColumns } from "./chunks/chunk-
|
|
2
|
+
import { Categories, CategoryNav, DEFAULT_PICKER_HEIGHT, DEFAULT_PICKER_WIDTH, DefaultPickerConfiguration, EmojiStyle, Empty, List, LoadError, Loading, MutableConfigProvider, Panel, Preview, Reactions, Relative, Root, Search, SkinTone, SkinTonePickerLocation, SkinTones, SuggestionMode, Theme, ViewOnlyEmoji, Viewport, commonInteractionStyles, compareConfig, cx, defaultPickerTokens, emojiByUnified, isPickerBehaviorProp, resolveEmojiStyle, resolveSkinTonePickerLocation, stylesheet, useDefaultAppearance, useDefineMutableConfig, usePreviewConfig, useSearchDisabledConfig, useSkinTonePickerLocationConfig, useSkinTonesDisabledConfig, validColumns } from "./chunks/chunk-R7XJISCB.mjs";
|
|
3
3
|
|
|
4
4
|
import "./chunks/chunk-GZYF2CX5.mjs";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Categories, CategoryNav, EmojiStyle, Empty, List, LoadError, Loading, Panel, Preview, Reactions, Root, Search, SearchInput, SkinTone, SkinTonePickerLocation, SkinTones, SuggestionMode, Theme, Viewport, darkPickerTokens, defaultPickerTokens, lightPickerTokens, structuralPickerTokens, useActiveEmoji, useCategoryNavigation, useEmojiDataState, usePickerMode, useSearchActions, useSearchState, useSkinTone } from "../chunks/chunk-
|
|
2
|
+
import { Categories, CategoryNav, EmojiStyle, Empty, List, LoadError, Loading, Panel, Preview, Reactions, Root, Search, SearchInput, SkinTone, SkinTonePickerLocation, SkinTones, SuggestionMode, Theme, Viewport, darkPickerTokens, defaultPickerTokens, lightPickerTokens, structuralPickerTokens, useActiveEmoji, useCategoryNavigation, useEmojiDataState, usePickerMode, useSearchActions, useSearchState, useSkinTone } from "../chunks/chunk-R7XJISCB.mjs";
|
|
3
3
|
|
|
4
4
|
import "../chunks/chunk-V7DBC3DD.mjs";
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { DataEmojis } from '../dataUtils/DataTypes';
|
|
3
|
-
export declare function useEmojiVirtualization({ categoryEmojis, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned, }: {
|
|
3
|
+
export declare function useEmojiVirtualization({ categoryEmojis, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned, mounted, }: {
|
|
4
4
|
categoryEmojis: DataEmojis;
|
|
5
5
|
topOffset: number;
|
|
6
6
|
onHeightReady: (height: number) => void;
|
|
@@ -8,6 +8,8 @@ export declare function useEmojiVirtualization({ categoryEmojis, topOffset, onHe
|
|
|
8
8
|
isCategoryVisible: boolean;
|
|
9
9
|
/** Whether topOffset is final; unmeasured sections above shift it. */
|
|
10
10
|
positioned: boolean;
|
|
11
|
+
/** Whether the list's ref is attached, so sections can measure. */
|
|
12
|
+
mounted: boolean;
|
|
11
13
|
}): {
|
|
12
14
|
virtualizedCounter: number;
|
|
13
15
|
emojis: ReactNode[];
|