emoji-picker-react 4.7.12 → 4.7.13

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.
@@ -180,6 +180,14 @@ function darkMode(key, value) {
180
180
  };
181
181
  }
182
182
 
183
+ // eslint-disable-next-line complexity
184
+ function compareConfig(prev, next) {
185
+ var _prev$customEmojis, _next$customEmojis;
186
+ var prevCustomEmojis = (_prev$customEmojis = prev.customEmojis) != null ? _prev$customEmojis : [];
187
+ var nextCustomEmojis = (_next$customEmojis = next.customEmojis) != null ? _next$customEmojis : [];
188
+ return prev.open === next.open && prev.emojiVersion === next.emojiVersion && prev.reactionsDefaultOpen === next.reactionsDefaultOpen && prev.searchPlaceHolder === next.searchPlaceHolder && prev.searchPlaceholder === next.searchPlaceholder && 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;
189
+ }
190
+
183
191
  var DEFAULT_REACTIONS = ['1f44d', '2764-fe0f', '1f603', '1f622', '1f64f', '1f44e', '1f621' // 😡
184
192
  ];
185
193
 
@@ -16862,22 +16870,18 @@ function useSetConfig(config) {
16862
16870
  mergedConfig = _React$useState[0],
16863
16871
  setMergedConfig = _React$useState[1];
16864
16872
  useEffect(function () {
16865
- if (avoidRefresh(config, mergedConfig)) {
16873
+ if (compareConfig(mergedConfig, config)) {
16866
16874
  return;
16867
16875
  }
16868
16876
  setMergedConfig(mergeConfig(config));
16869
16877
  // not gonna...
16870
16878
  // eslint-disable-next-line react-hooks/exhaustive-deps
16871
- }, [(_config$customEmojis = config.customEmojis) == null ? void 0 : _config$customEmojis.length, config.open]);
16879
+ }, [(_config$customEmojis = config.customEmojis) == null ? void 0 : _config$customEmojis.length, config.open, config.emojiVersion, config.reactionsDefaultOpen, config.searchPlaceHolder, config.searchPlaceholder, config.defaultSkinTone, config.skinTonesDisabled, config.autoFocusSearch, config.emojiStyle, config.theme, config.suggestedEmojisMode, config.lazyLoadEmojis, config.className, config.height, config.width, config.searchDisabled, config.skinTonePickerLocation]);
16872
16880
  return mergedConfig;
16873
16881
  }
16874
16882
  function usePickerConfig() {
16875
16883
  return useContext(ConfigContext);
16876
16884
  }
16877
- function avoidRefresh(prev, next) {
16878
- var _prev$customEmojis, _next$customEmojis;
16879
- return ((_prev$customEmojis = prev.customEmojis) == null ? void 0 : _prev$customEmojis.length) === ((_next$customEmojis = next.customEmojis) == null ? void 0 : _next$customEmojis.length) && prev.open === next.open;
16880
- }
16881
16885
 
16882
16886
  var MutableConfigContext = /*#__PURE__*/React__default.createContext({});
16883
16887
  function useMutableConfig() {
@@ -18927,6 +18931,16 @@ var styles$9 = /*#__PURE__*/stylesheet.create({
18927
18931
  }
18928
18932
  });
18929
18933
 
18934
+ function detectEmojyPartiallyBelowFold(button, bodyRef) {
18935
+ if (!button || !bodyRef) {
18936
+ return 0;
18937
+ }
18938
+ var buttonRect = button.getBoundingClientRect();
18939
+ var bodyRect = bodyRef.getBoundingClientRect();
18940
+ // If the element is obscured by at least half of its size
18941
+ return bodyRect.height - (buttonRect.y - bodyRect.y);
18942
+ }
18943
+
18930
18944
  function useEmojiPreviewEvents(allow, setPreviewEmoji) {
18931
18945
  var BodyRef = useBodyRef();
18932
18946
  var isMouseDisallowed = useIsMouseDisallowed();
@@ -18980,6 +18994,18 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
18980
18994
  }
18981
18995
  var button = buttonFromTarget(e.target);
18982
18996
  if (button) {
18997
+ var belowFoldByPx = detectEmojyPartiallyBelowFold(button, bodyRef);
18998
+ var buttonHeight = button.getBoundingClientRect().height;
18999
+ if (belowFoldByPx < buttonHeight / 2) {
19000
+ return;
19001
+ }
19002
+ if (belowFoldByPx < buttonHeight) {
19003
+ button.scrollIntoView({
19004
+ behavior: 'smooth',
19005
+ block: 'end'
19006
+ });
19007
+ return;
19008
+ }
18983
19009
  focusElement(button);
18984
19010
  }
18985
19011
  }
@@ -20379,12 +20405,7 @@ function ContentControl() {
20379
20405
  return createElement(PickerMain, null, createElement(Reactions, null), renderAll ? createElement(Fragment, null, createElement(Header, null), createElement(Body, null), createElement(Preview, null)) : null);
20380
20406
  }
20381
20407
  // eslint-disable-next-line complexity
20382
- var EmojiPickerReact = /*#__PURE__*/memo(EmojiPicker, function (prev, next) {
20383
- var _prev$customEmojis, _next$customEmojis;
20384
- var prevCustomEmojis = (_prev$customEmojis = prev.customEmojis) != null ? _prev$customEmojis : [];
20385
- var nextCustomEmojis = (_next$customEmojis = next.customEmojis) != null ? _next$customEmojis : [];
20386
- return prev.open === next.open && prev.emojiVersion === next.emojiVersion && prev.reactionsDefaultOpen === next.reactionsDefaultOpen && prev.searchPlaceHolder === next.searchPlaceHolder && prev.searchPlaceholder === next.searchPlaceholder && 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;
20387
- });
20408
+ var EmojiPickerReact = /*#__PURE__*/memo(EmojiPicker, compareConfig);
20388
20409
 
20389
20410
  var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
20390
20411
  _inheritsLoose(ErrorBoundary, _React$Component);