emoji-picker-react 5.1.3 → 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/dist/dataUtils/nativeEmojiSequenceSupport.d.ts +1 -1
- package/dist/esm/chunks/{chunk-CEY4YIFR.mjs → chunk-R7XJISCB.mjs} +28 -17
- 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/package.json +1 -1
|
@@ -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;
|
|
@@ -2015,7 +2015,7 @@ function formatSearchResultsLabel(labels, searchResultsCount) {
|
|
|
2015
2015
|
}
|
|
2016
2016
|
|
|
2017
2017
|
// src/dataUtils/nativeEmojiSequenceSupport.ts
|
|
2018
|
-
var CELL = 32, NATIVE_PROBE_BATCH =
|
|
2018
|
+
var CELL = 32, NATIVE_PROBE_BATCH = 16;
|
|
2019
2019
|
|
|
2020
2020
|
function createNativeEmojiSequenceSupport(ctx, baselineWidth) {
|
|
2021
2021
|
const results = /* @__PURE__ */ new Map, font = ctx.font;
|
|
@@ -2567,7 +2567,11 @@ function useNativeEmojiSupportState() {
|
|
|
2567
2567
|
const unified = emojiUnified(emoji), version = addedIn(emoji);
|
|
2568
2568
|
samples.has(version) || samples.set(version, unified), [ unified, ...emojiVariations(emoji) ].forEach((id => inventory.push([ id, version ])));
|
|
2569
2569
|
}));
|
|
2570
|
-
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;
|
|
2571
2575
|
const pending = /* @__PURE__ */ new Set, publish = next => {
|
|
2572
2576
|
const current = published;
|
|
2573
2577
|
current && inventory.every((([unified, version]) => isNativeEmojiSupported(next, unified, version) === isNativeEmojiSupported(current, unified, version))) || (published = next,
|
|
@@ -2575,17 +2579,17 @@ function useNativeEmojiSupportState() {
|
|
|
2575
2579
|
}, flush = () => {
|
|
2576
2580
|
if (timer = void 0, !detected) return;
|
|
2577
2581
|
const batch = Array.from(pending).slice(0, NATIVE_PROBE_BATCH);
|
|
2578
|
-
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));
|
|
2579
2583
|
};
|
|
2580
2584
|
requestRef.current = unifieds => {
|
|
2581
2585
|
unifieds.forEach((unified => {
|
|
2582
2586
|
requested.add(unified), detected && !detected.has(unified) && pending.add(unified);
|
|
2583
|
-
})), pending.size && void 0 === timer && (
|
|
2587
|
+
})), pending.size && void 0 === timer && later();
|
|
2584
2588
|
};
|
|
2585
2589
|
const probe2 = (refresh2 = !1) => {
|
|
2586
2590
|
const customFont = view.getComputedStyle(root).getPropertyValue("--epr-emoji-font-family").trim();
|
|
2587
2591
|
if (!refresh2 && customFont === previousFont) return;
|
|
2588
|
-
previousFont = customFont,
|
|
2592
|
+
previousFont = customFont, cancel(), timer = void 0, pending.clear();
|
|
2589
2593
|
const next = detectNativeEmojiSupport(customFont || void 0, refresh2, root.ownerDocument);
|
|
2590
2594
|
if (!("snapshot" in next)) return detected = void 0, published = null, setSnapshot(null),
|
|
2591
2595
|
void 0;
|
|
@@ -2599,7 +2603,7 @@ function useNativeEmojiSupportState() {
|
|
|
2599
2603
|
});
|
|
2600
2604
|
const fonts = root.ownerDocument.fonts, refresh = () => probe2(!0);
|
|
2601
2605
|
return fonts?.addEventListener("loadingdone", refresh), () => {
|
|
2602
|
-
|
|
2606
|
+
cancel(), detected = void 0, observer.disconnect(), fonts?.removeEventListener("loadingdone", refresh);
|
|
2603
2607
|
};
|
|
2604
2608
|
}), [ shouldDetect, PickerMainRef, allEmojis ]), [ shouldDetect && snapshot?.[1] === allEmojis ? snapshot[0] : null, request ];
|
|
2605
2609
|
}
|
|
@@ -6436,7 +6440,7 @@ function trackColumnCount(previousRef, emojisPerRow, registry) {
|
|
|
6436
6440
|
previousRef.current = emojisPerRow;
|
|
6437
6441
|
}
|
|
6438
6442
|
|
|
6439
|
-
function useCategoryHeight(emojiCount, ready = !0) {
|
|
6443
|
+
function useCategoryHeight(emojiCount, ready = !0, mounted) {
|
|
6440
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((() => {
|
|
6441
6445
|
const listEl = EmojiListRef.current;
|
|
6442
6446
|
if (!listEl) return;
|
|
@@ -6457,7 +6461,7 @@ function useCategoryHeight(emojiCount, ready = !0) {
|
|
|
6457
6461
|
}), [ EmojiListRef, BodyRef, emojiCount, emojiSizeFromContext, registry, columns ]);
|
|
6458
6462
|
return useIsomorphicLayoutEffect((() => {
|
|
6459
6463
|
computeAndSetDimensions();
|
|
6460
|
-
}), [ emojiCount, isReactionsMode, computeAndSetDimensions, visibleCategories.length, dimensions, ready ]),
|
|
6464
|
+
}), [ emojiCount, isReactionsMode, computeAndSetDimensions, visibleCategories.length, dimensions, ready, mounted ]),
|
|
6461
6465
|
React58.useEffect((() => {
|
|
6462
6466
|
const listEl = EmojiListRef.current;
|
|
6463
6467
|
if (!listEl || "undefined" == typeof ResizeObserver) return;
|
|
@@ -6483,7 +6487,7 @@ function useCategoryHeight(emojiCount, ready = !0) {
|
|
|
6483
6487
|
}
|
|
6484
6488
|
|
|
6485
6489
|
// src/hooks/useEmojiVirtualization.tsx
|
|
6486
|
-
function useEmojiVirtualization({categoryEmojis, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned}) {
|
|
6490
|
+
function useEmojiVirtualization({categoryEmojis, topOffset, onHeightReady, scrollTop, isCategoryVisible, positioned, mounted}) {
|
|
6487
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((() => {
|
|
6488
6492
|
const rendered = /* @__PURE__ */ new Set;
|
|
6489
6493
|
return categoryEmojis.filter((emoji => {
|
|
@@ -6492,7 +6496,7 @@ function useEmojiVirtualization({categoryEmojis, topOffset, onHeightReady, scrol
|
|
|
6492
6496
|
const unified = emojiUnified(emoji, activeSkinTone);
|
|
6493
6497
|
return !rendered.has(unified) && (rendered.add(unified), !0);
|
|
6494
6498
|
}));
|
|
6495
|
-
}), [ categoryEmojis, activeSkinTone, isEmojiHidden, isEmojiDisallowed ]), dimensions = useCategoryHeight(emojisToPush.length, isCategoryVisible && positioned);
|
|
6499
|
+
}), [ categoryEmojis, activeSkinTone, isEmojiHidden, isEmojiDisallowed ]), dimensions = useCategoryHeight(emojisToPush.length, isCategoryVisible && positioned, mounted);
|
|
6496
6500
|
useEffect26((() => {
|
|
6497
6501
|
dimensions || setCommitted(!0);
|
|
6498
6502
|
}), [ dimensions ]), useIsomorphicLayoutEffect((() => {
|
|
@@ -6659,9 +6663,11 @@ function EmojiList({scrollTop, outerRef, className, nativeProps}) {
|
|
|
6659
6663
|
...previous,
|
|
6660
6664
|
[categoryId]: height
|
|
6661
6665
|
}));
|
|
6662
|
-
}), []),
|
|
6666
|
+
}), []), [mounted, setMounted] = React62.useState(!1);
|
|
6667
|
+
useIsomorphicLayoutEffect((() => setMounted(!0)), []);
|
|
6668
|
+
const mergedRef = useMergedRefs(EmojiListRef, outerRef), getEmojisByCategory = useGetEmojisByCategory();
|
|
6663
6669
|
useRegisterRegion("grid", EmojiListRef);
|
|
6664
|
-
const labelHeight = getLabelHeight(EmojiListRef.current);
|
|
6670
|
+
const labelHeight = getLabelHeight(EmojiListRef.current), viewportHeight = BodyRef.current?.clientHeight ?? 0;
|
|
6665
6671
|
let topOffset = 0, positioned = !0;
|
|
6666
6672
|
/* @__PURE__ */
|
|
6667
6673
|
return React62.createElement("ul", {
|
|
@@ -6675,27 +6681,32 @@ function EmojiList({scrollTop, outerRef, className, nativeProps}) {
|
|
|
6675
6681
|
const category = categoryFromCategoryConfig(categoryConfig), categoryId = categoryIdFromCategoryConfig(categoryConfig), group = customGroupFromCategoryConfig(categoryConfig), currentOffset = topOffset, isPositioned = positioned;
|
|
6676
6682
|
positioned = positioned && categoryId in categoryHeights;
|
|
6677
6683
|
const categoryHeight = categoryHeights[categoryId];
|
|
6678
|
-
|
|
6684
|
+
categoryHeight && (topOffset += categoryHeight + labelHeight);
|
|
6685
|
+
const inView = positioned && currentOffset < scrollTop + viewportHeight && topOffset > scrollTop;
|
|
6686
|
+
/* @__PURE__ */
|
|
6687
|
+
return React62.createElement(RenderCategory, {
|
|
6679
6688
|
key: categoryId,
|
|
6680
6689
|
categoryEmojis: getEmojisByCategory(category, group),
|
|
6681
6690
|
categoryConfig,
|
|
6682
6691
|
topOffset: currentOffset,
|
|
6683
|
-
isCategoryVisible: 0 === index || visibleCategories.includes(categoryId),
|
|
6692
|
+
isCategoryVisible: 0 === index || inView || visibleCategories.includes(categoryId),
|
|
6684
6693
|
positioned: isPositioned,
|
|
6694
|
+
mounted,
|
|
6685
6695
|
onHeightReady,
|
|
6686
|
-
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)))
|
|
6687
6697
|
});
|
|
6688
6698
|
})));
|
|
6689
6699
|
}
|
|
6690
6700
|
|
|
6691
|
-
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}) {
|
|
6692
6702
|
const categoryId = categoryIdFromCategoryConfig(categoryConfig), reportHeight = React62.useCallback((height => onHeightReady(categoryId, height)), [ categoryId, onHeightReady ]), {virtualizedCounter, emojis, dimensions, emojiCount} = useEmojiVirtualization({
|
|
6693
6703
|
categoryEmojis,
|
|
6694
6704
|
topOffset,
|
|
6695
6705
|
onHeightReady: reportHeight,
|
|
6696
6706
|
scrollTop,
|
|
6697
6707
|
isCategoryVisible,
|
|
6698
|
-
positioned
|
|
6708
|
+
positioned,
|
|
6709
|
+
mounted
|
|
6699
6710
|
});
|
|
6700
6711
|
/* @__PURE__ */
|
|
6701
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[];
|