emoji-picker-react 4.22.0 → 4.22.1
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/emoji-picker-react.cjs.development.js +50 -16
- package/dist/emoji-picker-react.cjs.development.js.map +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
- package/dist/emoji-picker-react.esm.js +50 -16
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/dist/hooks/useActiveCategoryScrollDetection.d.ts +8 -1
- package/llms.txt +7 -0
- package/package.json +1 -1
- package/src/components/context/PickerConfigContext.tsx +5 -1
- package/src/components/context/PickerDataContext.tsx +12 -7
- package/src/components/navigation/CategoryNavigation.tsx +12 -1
- package/src/config/compareConfig.ts +31 -0
- package/src/hooks/useActiveCategoryScrollDetection.ts +9 -1
|
@@ -179,7 +179,27 @@ function compareConfig(prev, next) {
|
|
|
179
179
|
var _prev$customEmojis, _next$customEmojis;
|
|
180
180
|
var prevCustomEmojis = (_prev$customEmojis = prev.customEmojis) != null ? _prev$customEmojis : [];
|
|
181
181
|
var nextCustomEmojis = (_next$customEmojis = next.customEmojis) != null ? _next$customEmojis : [];
|
|
182
|
-
return prev.open === next.open && prev.emojiVersion === next.emojiVersion && prev.reactionsDefaultOpen === next.reactionsDefaultOpen && prev.searchPlaceHolder === next.searchPlaceHolder && prev.searchPlaceholder === next.searchPlaceholder && prev.searchClearButtonLabel === next.searchClearButtonLabel && prev.defaultSkinTone === next.defaultSkinTone && prev.skinTonesDisabled === next.skinTonesDisabled && prev.autoFocusSearch === next.autoFocusSearch && prev.emojiStyle === next.emojiStyle && prev.theme === next.theme && prev.suggestedEmojisMode === next.suggestedEmojisMode && prev.lazyLoadEmojis === next.lazyLoadEmojis && prev.className === next.className && prev.height === next.height && prev.width === next.width && prev.style === next.style && prev.searchDisabled === next.searchDisabled && prev.skinTonePickerLocation === next.skinTonePickerLocation && prevCustomEmojis.length === nextCustomEmojis.length && prev.emojiData === next.emojiData;
|
|
182
|
+
return prev.open === next.open && prev.emojiVersion === next.emojiVersion && prev.reactionsDefaultOpen === next.reactionsDefaultOpen && prev.searchPlaceHolder === next.searchPlaceHolder && prev.searchPlaceholder === next.searchPlaceholder && prev.searchClearButtonLabel === next.searchClearButtonLabel && prev.defaultSkinTone === next.defaultSkinTone && prev.skinTonesDisabled === next.skinTonesDisabled && prev.autoFocusSearch === next.autoFocusSearch && prev.emojiStyle === next.emojiStyle && prev.theme === next.theme && prev.suggestedEmojisMode === next.suggestedEmojisMode && prev.lazyLoadEmojis === next.lazyLoadEmojis && prev.className === next.className && prev.height === next.height && prev.width === next.width && prev.style === next.style && prev.searchDisabled === next.searchDisabled && prev.skinTonePickerLocation === next.skinTonePickerLocation && prevCustomEmojis.length === nextCustomEmojis.length && customEmojisKey(prevCustomEmojis) === customEmojisKey(nextCustomEmojis) && categoriesKey(prev.categories) === categoriesKey(next.categories) && prev.emojiData === next.emojiData;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Content identity for custom emojis. Length alone misses regroups and
|
|
186
|
+
* swaps, which would leave merged categories, search, and sections stale.
|
|
187
|
+
*/
|
|
188
|
+
function customEmojisKey(customEmojis) {
|
|
189
|
+
return customEmojis.map(function (emoji) {
|
|
190
|
+
var _emoji$group;
|
|
191
|
+
return emoji.id + ":" + ((_emoji$group = emoji.group) != null ? _emoji$group : '') + ":" + emoji.names.join(',') + ":" + emoji.imgUrl;
|
|
192
|
+
}).join('|');
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Content identity for the categories input. Order, labels, icons, and
|
|
196
|
+
* group selection all flow into the merged configuration.
|
|
197
|
+
*/
|
|
198
|
+
function categoriesKey(categories) {
|
|
199
|
+
return (categories != null ? categories : []).map(function (entry) {
|
|
200
|
+
var _entry$group;
|
|
201
|
+
return typeof entry === 'string' ? entry : entry.category + ":" + entry.name + ":" + ((_entry$group = entry.group) != null ? _entry$group : '') + ":" + (entry.icon ? '1' : '');
|
|
202
|
+
}).join('|');
|
|
183
203
|
}
|
|
184
204
|
|
|
185
205
|
var DEFAULT_REACTIONS = ['1f44d', '2764-fe0f', '1f603', '1f622', '1f64f', '1f44e', '1f621'];
|
|
@@ -557,7 +577,6 @@ function PickerConfigProvider(_ref) {
|
|
|
557
577
|
}, children);
|
|
558
578
|
}
|
|
559
579
|
function useSetConfig(config) {
|
|
560
|
-
var _config$customEmojis;
|
|
561
580
|
var _React$useState = React.useState(function () {
|
|
562
581
|
return mergeConfig(config);
|
|
563
582
|
}),
|
|
@@ -570,7 +589,11 @@ function useSetConfig(config) {
|
|
|
570
589
|
setMergedConfig(mergeConfig(config));
|
|
571
590
|
// not gonna...
|
|
572
591
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
573
|
-
}, [
|
|
592
|
+
}, [
|
|
593
|
+
// New references rebuild merged categories and data even at equal
|
|
594
|
+
// length; compareConfig above still gates no-op updates so inline
|
|
595
|
+
// literals don't loop.
|
|
596
|
+
config.categories, config.customEmojis, config.open, config.emojiVersion, config.reactionsDefaultOpen, config.searchPlaceHolder, config.searchPlaceholder, config.searchClearButtonLabel, config.defaultSkinTone, config.skinTonesDisabled, config.autoFocusSearch, config.emojiStyle, config.theme, config.suggestedEmojisMode, config.lazyLoadEmojis, config.className, config.height, config.width, config.searchDisabled, config.skinTonePickerLocation, config.allowExpandReactions, config.emojiData]);
|
|
574
597
|
return mergedConfig;
|
|
575
598
|
}
|
|
576
599
|
function usePickerConfig() {
|
|
@@ -26927,9 +26950,9 @@ function useIsMounted() {
|
|
|
26927
26950
|
var PickerDataContext = /*#__PURE__*/React__default.createContext({
|
|
26928
26951
|
emojiData: {},
|
|
26929
26952
|
allEmojis: [],
|
|
26930
|
-
allEmojisByUnified:
|
|
26931
|
-
searchIndex:
|
|
26932
|
-
customGroups:
|
|
26953
|
+
allEmojisByUnified: /*#__PURE__*/Object.create(null),
|
|
26954
|
+
searchIndex: /*#__PURE__*/Object.create(null),
|
|
26955
|
+
customGroups: /*#__PURE__*/Object.create(null),
|
|
26933
26956
|
emojiByUnified: emojiByUnified,
|
|
26934
26957
|
activeVariationFromUnified: function activeVariationFromUnified() {
|
|
26935
26958
|
return null;
|
|
@@ -26944,7 +26967,10 @@ function PickerDataProvider(_ref) {
|
|
|
26944
26967
|
var emojiData = genericEmojiData || defaultEmojiData;
|
|
26945
26968
|
// Clone to avoid mutation of shared source
|
|
26946
26969
|
var newData = JSON.parse(JSON.stringify(emojiData));
|
|
26947
|
-
|
|
26970
|
+
// Group names and emoji ids are user-controlled strings: use
|
|
26971
|
+
// null-prototype dictionaries so names like `__proto__` behave as
|
|
26972
|
+
// ordinary data instead of resolving Object.prototype members.
|
|
26973
|
+
var customGroups = Object.create(null);
|
|
26948
26974
|
if (customEmojis && customEmojis.length > 0) {
|
|
26949
26975
|
for (var _iterator = _createForOfIteratorHelperLoose(customEmojis), _step; !(_step = _iterator()).done;) {
|
|
26950
26976
|
var _customGroups$emoji$g;
|
|
@@ -26961,8 +26987,8 @@ function PickerDataProvider(_ref) {
|
|
|
26961
26987
|
}
|
|
26962
26988
|
var emojis = newData.emojis || {};
|
|
26963
26989
|
var allEmojis = Object.values(emojis).concat(Object.values(customGroups)).flat();
|
|
26964
|
-
var allEmojisByUnified =
|
|
26965
|
-
var searchIndex =
|
|
26990
|
+
var allEmojisByUnified = Object.create(null);
|
|
26991
|
+
var searchIndex = Object.create(null);
|
|
26966
26992
|
allEmojis.forEach(function (emoji) {
|
|
26967
26993
|
var unified = emoji[EmojiProperties.unified];
|
|
26968
26994
|
allEmojisByUnified[unified] = emoji;
|
|
@@ -26977,7 +27003,7 @@ function PickerDataProvider(_ref) {
|
|
|
26977
27003
|
var joinedNameString = (emoji[EmojiProperties.name] || []).join('').toLowerCase().split('');
|
|
26978
27004
|
joinedNameString.forEach(function (_char) {
|
|
26979
27005
|
var _searchIndex$_char;
|
|
26980
|
-
searchIndex[_char] = (_searchIndex$_char = searchIndex[_char]) != null ? _searchIndex$_char :
|
|
27006
|
+
searchIndex[_char] = (_searchIndex$_char = searchIndex[_char]) != null ? _searchIndex$_char : Object.create(null);
|
|
26981
27007
|
searchIndex[_char][unified] = emoji;
|
|
26982
27008
|
});
|
|
26983
27009
|
});
|
|
@@ -30507,7 +30533,8 @@ function categoryNameFromDom($category) {
|
|
|
30507
30533
|
|
|
30508
30534
|
function useActiveCategoryScrollDetection(_ref) {
|
|
30509
30535
|
var setActiveCategory = _ref.setActiveCategory,
|
|
30510
|
-
setVisibleCategories = _ref.setVisibleCategories
|
|
30536
|
+
setVisibleCategories = _ref.setVisibleCategories,
|
|
30537
|
+
categoryIdentitiesKey = _ref.categoryIdentitiesKey;
|
|
30511
30538
|
var BodyRef = useBodyRef();
|
|
30512
30539
|
React.useEffect(function () {
|
|
30513
30540
|
var visibleCategories = new Map();
|
|
@@ -30559,7 +30586,7 @@ function useActiveCategoryScrollDetection(_ref) {
|
|
|
30559
30586
|
return function () {
|
|
30560
30587
|
observer.disconnect();
|
|
30561
30588
|
};
|
|
30562
|
-
}, [BodyRef, setActiveCategory, setVisibleCategories]);
|
|
30589
|
+
}, [BodyRef, categoryIdentitiesKey, setActiveCategory, setVisibleCategories]);
|
|
30563
30590
|
}
|
|
30564
30591
|
|
|
30565
30592
|
function useScrollCategoryIntoView() {
|
|
@@ -30945,10 +30972,6 @@ function CategoryNavigation() {
|
|
|
30945
30972
|
var _useVisibleCategories = useVisibleCategoriesState(),
|
|
30946
30973
|
setVisibleCategories = _useVisibleCategories[1];
|
|
30947
30974
|
var scrollCategoryIntoView = useScrollCategoryIntoView();
|
|
30948
|
-
useActiveCategoryScrollDetection({
|
|
30949
|
-
setActiveCategory: setActiveCategory,
|
|
30950
|
-
setVisibleCategories: setVisibleCategories
|
|
30951
|
-
});
|
|
30952
30975
|
var isSearchMode = useIsSearchMode();
|
|
30953
30976
|
var categoriesConfig = useCategoriesConfig();
|
|
30954
30977
|
var categoryIcons = useCategoryIconsConfig();
|
|
@@ -30957,6 +30980,17 @@ function CategoryNavigation() {
|
|
|
30957
30980
|
var _usePickerDataContext = usePickerDataContext(),
|
|
30958
30981
|
customGroups = _usePickerDataContext.customGroups,
|
|
30959
30982
|
emojiData = _usePickerDataContext.emojiData;
|
|
30983
|
+
// Rendered section identities. Passed to the scroll-detection hook so
|
|
30984
|
+
// added/removed sections are (re-)subscribed; stable across renders
|
|
30985
|
+
// unless the effective category list changes.
|
|
30986
|
+
var categoryIdentitiesKey = categoriesConfig.map(function (entry) {
|
|
30987
|
+
return categoryIdFromCategoryConfig(entry);
|
|
30988
|
+
}).join('|');
|
|
30989
|
+
useActiveCategoryScrollDetection({
|
|
30990
|
+
setActiveCategory: setActiveCategory,
|
|
30991
|
+
setVisibleCategories: setVisibleCategories,
|
|
30992
|
+
categoryIdentitiesKey: categoryIdentitiesKey
|
|
30993
|
+
});
|
|
30960
30994
|
var visibleCategories = categoriesConfig.filter(function (categoryConfig) {
|
|
30961
30995
|
if (isCustomCategory(categoryConfig) && hideCustomCategory) {
|
|
30962
30996
|
return false;
|