emoji-picker-react 4.4.4 → 4.4.6

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.
@@ -34,6 +34,31 @@ function asSelectors() {
34
34
  }).join('');
35
35
  }
36
36
 
37
+ function focusElement(element) {
38
+ if (!element) {
39
+ return;
40
+ }
41
+
42
+ requestAnimationFrame(function () {
43
+ element.focus();
44
+ });
45
+ }
46
+ function focusPrevElementSibling(element) {
47
+ if (!element) return;
48
+ var prev = element.previousElementSibling;
49
+ focusElement(prev);
50
+ }
51
+ function focusNextElementSibling(element) {
52
+ if (!element) return;
53
+ var next = element.nextElementSibling;
54
+ focusElement(next);
55
+ }
56
+ function focusFirstElementChild(element) {
57
+ if (!element) return;
58
+ var first = element.firstElementChild;
59
+ focusElement(first);
60
+ }
61
+
37
62
  function ElementRefContextProvider(_ref) {
38
63
  var children = _ref.children;
39
64
  var PickerMainRef = useRef(null);
@@ -78,6 +103,10 @@ function useAnchoredEmojiRef() {
78
103
  function useSetAnchoredEmojiRef() {
79
104
  var AnchoredEmojiRef = useAnchoredEmojiRef();
80
105
  return function (target) {
106
+ if (target === null && AnchoredEmojiRef.current !== null) {
107
+ focusElement(AnchoredEmojiRef.current);
108
+ }
109
+
81
110
  AnchoredEmojiRef.current = target;
82
111
  };
83
112
  }
@@ -16619,6 +16648,10 @@ function addedIn(emoji) {
16619
16648
  return parseFloat(emoji[EmojiProperties.added_in]);
16620
16649
  }
16621
16650
  function emojiName(emoji) {
16651
+ if (!emoji) {
16652
+ return '';
16653
+ }
16654
+
16622
16655
  return emojiNames(emoji)[0];
16623
16656
  }
16624
16657
  function unifiedWithoutSkinTone(unified) {
@@ -17852,31 +17885,6 @@ function scrollEmojiAboveLabel(emoji) {
17852
17885
  scrollBy(scrollBody, -(categoryLabelHeight(closestCategory(emoji)) - by));
17853
17886
  }
17854
17887
 
17855
- function focusElement(element) {
17856
- if (!element) {
17857
- return;
17858
- }
17859
-
17860
- requestAnimationFrame(function () {
17861
- element.focus();
17862
- });
17863
- }
17864
- function focusPrevElementSibling(element) {
17865
- if (!element) return;
17866
- var prev = element.previousElementSibling;
17867
- focusElement(prev);
17868
- }
17869
- function focusNextElementSibling(element) {
17870
- if (!element) return;
17871
- var next = element.nextElementSibling;
17872
- focusElement(next);
17873
- }
17874
- function focusFirstElementChild(element) {
17875
- if (!element) return;
17876
- var first = element.firstElementChild;
17877
- focusElement(first);
17878
- }
17879
-
17880
17888
  function useFocusSearchInput() {
17881
17889
  var SearchInputRef = useSearchInputRef();
17882
17890
  return useCallback(function () {
@@ -18083,10 +18091,6 @@ function useIsEmojiHidden() {
18083
18091
  };
18084
18092
  }
18085
18093
 
18086
- function asEmoji(emoji) {
18087
- return emoji;
18088
- }
18089
-
18090
18094
  function Button(props) {
18091
18095
  return createElement("button", Object.assign({
18092
18096
  type: "button"
@@ -18168,13 +18172,18 @@ function ViewOnlyEmoji(_ref2) {
18168
18172
  }
18169
18173
 
18170
18174
  var emojiToRender = emoji ? emoji : emojiByUnified(unified);
18175
+
18176
+ if (!emojiToRender) {
18177
+ return null;
18178
+ }
18179
+
18171
18180
  return createElement(Fragment, null, emojiStyle === EmojiStyle.NATIVE ? createElement(NativeEmoji, {
18172
18181
  unified: unified,
18173
18182
  style: style
18174
18183
  }) : createElement(EmojiImg, {
18175
18184
  unified: unified,
18176
18185
  style: style,
18177
- emoji: asEmoji(emojiToRender),
18186
+ emoji: emojiToRender,
18178
18187
  emojiStyle: emojiStyle,
18179
18188
  lazyLoad: lazyLoad,
18180
18189
  getEmojiUrl: getEmojiUrl
@@ -18504,7 +18513,6 @@ function EmojiVariationPicker() {
18504
18513
  var visible = emoji && button && emojiHasVariations(emoji) && button.classList.contains(ClassNames.emojiHasVariatios);
18505
18514
  useEffect(function () {
18506
18515
  if (!visible) {
18507
- focusElement(AnchoredEmojiRef.current);
18508
18516
  return;
18509
18517
  }
18510
18518
 
@@ -18519,7 +18527,10 @@ function EmojiVariationPicker() {
18519
18527
  pointerStyle = getPointerStyle();
18520
18528
  }
18521
18529
 
18522
- var safeEmoji = asEmoji(emoji);
18530
+ if (!emoji) {
18531
+ return null;
18532
+ }
18533
+
18523
18534
  return createElement("div", {
18524
18535
  ref: VariationPickerRef,
18525
18536
  className: clsx(ClassNames.variationPicker, {
@@ -18529,10 +18540,10 @@ function EmojiVariationPicker() {
18529
18540
  style: {
18530
18541
  top: top
18531
18542
  }
18532
- }, visible ? [emojiUnified(safeEmoji)].concat(emojiVariations(safeEmoji)).slice(0, 6).map(function (unified) {
18543
+ }, visible ? [emojiUnified(emoji)].concat(emojiVariations(emoji)).slice(0, 6).map(function (unified) {
18533
18544
  return createElement(ClickableEmoji, {
18534
18545
  key: unified,
18535
- emoji: safeEmoji,
18546
+ emoji: emoji,
18536
18547
  unified: unified,
18537
18548
  emojiStyle: emojiStyle,
18538
18549
  showVariations: false,
@@ -18895,11 +18906,16 @@ function PreviewBody() {
18895
18906
  return createElement(PreviewContent, null);
18896
18907
 
18897
18908
  function PreviewContent() {
18898
- var defaultEmoji = asEmoji(variationPickerEmoji != null ? variationPickerEmoji : emojiByUnified(previewConfig.defaultEmoji));
18909
+ var defaultEmoji = variationPickerEmoji != null ? variationPickerEmoji : emojiByUnified(previewConfig.defaultEmoji);
18910
+
18911
+ if (!defaultEmoji) {
18912
+ return null;
18913
+ }
18914
+
18899
18915
  var defaultText = variationPickerEmoji ? emojiName(variationPickerEmoji) : previewConfig.defaultCaption;
18900
18916
  return createElement(Fragment, null, createElement("div", null, show ? createElement(ViewOnlyEmoji, {
18901
18917
  unified: previewEmoji == null ? void 0 : previewEmoji.unified,
18902
- emoji: asEmoji(emoji),
18918
+ emoji: emoji,
18903
18919
  emojiStyle: emojiStyle,
18904
18920
  size: 45,
18905
18921
  getEmojiUrl: getEmojiUrl
@@ -18911,7 +18927,7 @@ function PreviewBody() {
18911
18927
  getEmojiUrl: getEmojiUrl
18912
18928
  }) : null), show ? createElement("div", {
18913
18929
  className: "epr-preview-emoji-label"
18914
- }, emojiName(asEmoji(emoji))) : createElement("div", {
18930
+ }, emojiName(emoji)) : createElement("div", {
18915
18931
  className: "epr-preview-emoji-label"
18916
18932
  }, defaultText));
18917
18933
  }