emoji-picker-react 4.4.3 → 4.4.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.
@@ -21,6 +21,7 @@ var ClassNames;
21
21
  ClassNames["open"] = "epr-open";
22
22
  ClassNames["vertical"] = "epr-vertical";
23
23
  ClassNames["horizontal"] = "epr-horizontal";
24
+ ClassNames["variationPicker"] = "epr-emoji-variation-picker";
24
25
  })(ClassNames || (ClassNames = {}));
25
26
 
26
27
  function asSelectors() {
@@ -17636,198 +17637,12 @@ function useHasOpenToggles() {
17636
17637
  };
17637
17638
  }
17638
17639
 
17639
- function focusElement(element) {
17640
- if (!element) {
17641
- return;
17642
- }
17643
-
17644
- requestAnimationFrame(function () {
17645
- element.focus();
17646
- });
17647
- }
17648
- function focusPrevElementSibling(element) {
17649
- if (!element) return;
17650
- var prev = element.previousElementSibling;
17651
- focusElement(prev);
17652
- }
17653
- function focusNextElementSibling(element) {
17654
- if (!element) return;
17655
- var next = element.nextElementSibling;
17656
- focusElement(next);
17657
- }
17658
- function focusFirstElementChild(element) {
17659
- if (!element) return;
17660
- var first = element.firstElementChild;
17661
- focusElement(first);
17662
- }
17663
-
17664
- function scrollTo(root, top) {
17665
- if (top === void 0) {
17666
- top = 0;
17667
- }
17668
-
17669
- var $eprBody = queryScrollBody(root);
17670
-
17671
- if (!$eprBody) {
17672
- return;
17673
- }
17674
-
17675
- requestAnimationFrame(function () {
17676
- $eprBody.scrollTop = top + 1;
17677
- });
17678
- }
17679
- function scrollBy(root, by) {
17680
- var $eprBody = queryScrollBody(root);
17681
-
17682
- if (!$eprBody) {
17683
- return;
17684
- }
17685
-
17686
- requestAnimationFrame(function () {
17687
- $eprBody.scrollTop = $eprBody.scrollTop + by;
17688
- });
17689
- }
17690
- function useScrollTo() {
17691
- var BodyRef = useBodyRef();
17692
- return useCallback(function (top) {
17693
- requestAnimationFrame(function () {
17694
- if (BodyRef.current) {
17695
- BodyRef.current.scrollTop = top;
17696
- }
17697
- });
17698
- }, [BodyRef]);
17699
- }
17700
- function scrollEmojiAboveLabel(emoji) {
17701
- if (!isEmojiBehindLabel(emoji)) {
17702
- return;
17703
- }
17704
-
17705
- var scrollBody = closestScrollBody(emoji);
17706
- var by = emojiDistanceFromScrollTop(emoji);
17707
- scrollBy(scrollBody, -(categoryLabelHeight(closestCategory(emoji)) - by));
17708
- }
17709
-
17710
- function focusFirstVisibleEmoji(parent) {
17711
- var emoji = firstVisibleEmoji(parent);
17712
- focusElement(emoji);
17713
- scrollEmojiAboveLabel(emoji);
17714
- }
17715
- function focusAndClickFirstVisibleEmoji(parent) {
17716
- var firstEmoji = firstVisibleEmoji(parent);
17717
- focusElement(firstEmoji);
17718
- firstEmoji == null ? void 0 : firstEmoji.click();
17719
- }
17720
- function focusLastVisibleEmoji(parent) {
17721
- focusElement(lastVisibleEmoji(parent));
17722
- }
17723
- function focusNextVisibleEmoji(element) {
17724
- if (!element) {
17725
- return;
17726
- }
17727
-
17728
- var next = nextVisibleEmoji(element);
17729
-
17730
- if (!next) {
17731
- return focusFirstVisibleEmoji(nextCategory(element));
17732
- }
17733
-
17734
- focusElement(next);
17735
- scrollEmojiAboveLabel(next);
17736
- }
17737
- function focusPrevVisibleEmoji(element) {
17738
- if (!element) {
17739
- return;
17740
- }
17741
-
17742
- var prev = prevVisibleEmoji(element);
17743
-
17744
- if (!prev) {
17745
- return focusLastVisibleEmoji(prevCategory(element));
17746
- }
17747
-
17748
- focusElement(prev);
17749
- scrollEmojiAboveLabel(prev);
17750
- }
17751
- function focusVisibleEmojiOneRowUp(element, exitUp) {
17752
- if (!element) {
17753
- return;
17754
- }
17755
-
17756
- var prev = visibleEmojiOneRowUp(element);
17757
-
17758
- if (!prev) {
17759
- return exitUp();
17760
- }
17761
-
17762
- focusElement(prev);
17763
- scrollEmojiAboveLabel(prev);
17764
- }
17765
- function focusVisibleEmojiOneRowDown(element) {
17766
- if (!element) {
17767
- return;
17768
- }
17769
-
17770
- var next = visibleEmojiOneRowDown(element);
17771
- return focusElement(next);
17772
- }
17773
-
17774
- function visibleEmojiOneRowUp(element) {
17775
- if (!element) {
17776
- return null;
17777
- }
17778
-
17779
- var categoryContent = closestCategoryContent(element);
17780
- var category = closestCategory(categoryContent);
17781
- var indexInRow = elementIndexInRow(categoryContent, element);
17782
- var row = rowNumber(categoryContent, element);
17783
- var countInRow = elementCountInRow(categoryContent, element);
17784
-
17785
- if (row === 0) {
17786
- var prevVisibleCategory = prevCategory(category);
17787
-
17788
- if (!prevVisibleCategory) {
17789
- return null;
17790
- }
17791
-
17792
- return getElementInRow(allVisibleEmojis(prevVisibleCategory), -1, // last row
17793
- countInRow, indexInRow);
17794
- }
17795
-
17796
- return getElementInPrevRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
17797
- }
17798
-
17799
- function visibleEmojiOneRowDown(element) {
17800
- if (!element) {
17801
- return null;
17802
- }
17803
-
17804
- var categoryContent = closestCategoryContent(element);
17805
- var category = closestCategory(categoryContent);
17806
- var indexInRow = elementIndexInRow(categoryContent, element);
17807
- var row = rowNumber(categoryContent, element);
17808
- var countInRow = elementCountInRow(categoryContent, element);
17809
-
17810
- if (!hasNextRow(categoryContent, element)) {
17811
- var nextVisibleCategory = nextCategory(category);
17812
-
17813
- if (!nextVisibleCategory) {
17814
- return null;
17815
- }
17816
-
17817
- return getElementInRow(allVisibleEmojis(nextVisibleCategory), 0, countInRow, indexInRow);
17818
- }
17819
-
17820
- var itemInNextRow = getElementInNextRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
17821
- return itemInNextRow;
17822
- }
17823
-
17824
17640
  function useSetVariationPicker() {
17825
17641
  var setAnchoredEmojiRef = useSetAnchoredEmojiRef();
17826
17642
 
17827
17643
  var _useEmojiVariationPic = useEmojiVariationPickerState(),
17828
17644
  setEmojiVariationPicker = _useEmojiVariationPic[1];
17829
17645
 
17830
- var VariationPickerRef = useVariationPickerRef();
17831
17646
  return function setVariationPicker(element) {
17832
17647
  var _emojiFromElement = emojiFromElement(element),
17833
17648
  emoji = _emojiFromElement[0];
@@ -17838,9 +17653,6 @@ function useSetVariationPicker() {
17838
17653
 
17839
17654
  setAnchoredEmojiRef(element);
17840
17655
  setEmojiVariationPicker(emoji);
17841
- requestAnimationFrame(function () {
17842
- focusFirstVisibleEmoji(VariationPickerRef.current);
17843
- });
17844
17656
  };
17845
17657
  }
17846
17658
 
@@ -17990,6 +17802,81 @@ function useOnScroll(BodyRef) {
17990
17802
  }, [BodyRef, closeAllOpenToggles]);
17991
17803
  }
17992
17804
 
17805
+ function scrollTo(root, top) {
17806
+ if (top === void 0) {
17807
+ top = 0;
17808
+ }
17809
+
17810
+ var $eprBody = queryScrollBody(root);
17811
+
17812
+ if (!$eprBody) {
17813
+ return;
17814
+ }
17815
+
17816
+ requestAnimationFrame(function () {
17817
+ $eprBody.scrollTop = top + 1;
17818
+ });
17819
+ }
17820
+ function scrollBy(root, by) {
17821
+ var $eprBody = queryScrollBody(root);
17822
+
17823
+ if (!$eprBody) {
17824
+ return;
17825
+ }
17826
+
17827
+ requestAnimationFrame(function () {
17828
+ $eprBody.scrollTop = $eprBody.scrollTop + by;
17829
+ });
17830
+ }
17831
+ function useScrollTo() {
17832
+ var BodyRef = useBodyRef();
17833
+ return useCallback(function (top) {
17834
+ requestAnimationFrame(function () {
17835
+ if (BodyRef.current) {
17836
+ BodyRef.current.scrollTop = top;
17837
+ }
17838
+ });
17839
+ }, [BodyRef]);
17840
+ }
17841
+ function scrollEmojiAboveLabel(emoji) {
17842
+ if (!emoji || !isEmojiBehindLabel(emoji)) {
17843
+ return;
17844
+ }
17845
+
17846
+ if (emoji.closest(asSelectors(ClassNames.variationPicker))) {
17847
+ return;
17848
+ }
17849
+
17850
+ var scrollBody = closestScrollBody(emoji);
17851
+ var by = emojiDistanceFromScrollTop(emoji);
17852
+ scrollBy(scrollBody, -(categoryLabelHeight(closestCategory(emoji)) - by));
17853
+ }
17854
+
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
+
17993
17880
  function useFocusSearchInput() {
17994
17881
  var SearchInputRef = useSearchInputRef();
17995
17882
  return useCallback(function () {
@@ -18473,6 +18360,120 @@ function RenderCategory(_ref) {
18473
18360
  }, emojis);
18474
18361
  }
18475
18362
 
18363
+ function focusFirstVisibleEmoji(parent) {
18364
+ var emoji = firstVisibleEmoji(parent);
18365
+ focusElement(emoji);
18366
+ scrollEmojiAboveLabel(emoji);
18367
+ }
18368
+ function focusAndClickFirstVisibleEmoji(parent) {
18369
+ var firstEmoji = firstVisibleEmoji(parent);
18370
+ focusElement(firstEmoji);
18371
+ firstEmoji == null ? void 0 : firstEmoji.click();
18372
+ }
18373
+ function focusLastVisibleEmoji(parent) {
18374
+ focusElement(lastVisibleEmoji(parent));
18375
+ }
18376
+ function focusNextVisibleEmoji(element) {
18377
+ if (!element) {
18378
+ return;
18379
+ }
18380
+
18381
+ var next = nextVisibleEmoji(element);
18382
+
18383
+ if (!next) {
18384
+ return focusFirstVisibleEmoji(nextCategory(element));
18385
+ }
18386
+
18387
+ focusElement(next);
18388
+ scrollEmojiAboveLabel(next);
18389
+ }
18390
+ function focusPrevVisibleEmoji(element) {
18391
+ if (!element) {
18392
+ return;
18393
+ }
18394
+
18395
+ var prev = prevVisibleEmoji(element);
18396
+
18397
+ if (!prev) {
18398
+ return focusLastVisibleEmoji(prevCategory(element));
18399
+ }
18400
+
18401
+ focusElement(prev);
18402
+ scrollEmojiAboveLabel(prev);
18403
+ }
18404
+ function focusVisibleEmojiOneRowUp(element, exitUp) {
18405
+ if (!element) {
18406
+ return;
18407
+ }
18408
+
18409
+ var prev = visibleEmojiOneRowUp(element);
18410
+
18411
+ if (!prev) {
18412
+ return exitUp();
18413
+ }
18414
+
18415
+ focusElement(prev);
18416
+ scrollEmojiAboveLabel(prev);
18417
+ }
18418
+ function focusVisibleEmojiOneRowDown(element) {
18419
+ if (!element) {
18420
+ return;
18421
+ }
18422
+
18423
+ var next = visibleEmojiOneRowDown(element);
18424
+ return focusElement(next);
18425
+ }
18426
+
18427
+ function visibleEmojiOneRowUp(element) {
18428
+ if (!element) {
18429
+ return null;
18430
+ }
18431
+
18432
+ var categoryContent = closestCategoryContent(element);
18433
+ var category = closestCategory(categoryContent);
18434
+ var indexInRow = elementIndexInRow(categoryContent, element);
18435
+ var row = rowNumber(categoryContent, element);
18436
+ var countInRow = elementCountInRow(categoryContent, element);
18437
+
18438
+ if (row === 0) {
18439
+ var prevVisibleCategory = prevCategory(category);
18440
+
18441
+ if (!prevVisibleCategory) {
18442
+ return null;
18443
+ }
18444
+
18445
+ return getElementInRow(allVisibleEmojis(prevVisibleCategory), -1, // last row
18446
+ countInRow, indexInRow);
18447
+ }
18448
+
18449
+ return getElementInPrevRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
18450
+ }
18451
+
18452
+ function visibleEmojiOneRowDown(element) {
18453
+ if (!element) {
18454
+ return null;
18455
+ }
18456
+
18457
+ var categoryContent = closestCategoryContent(element);
18458
+ var category = closestCategory(categoryContent);
18459
+ var indexInRow = elementIndexInRow(categoryContent, element);
18460
+ var row = rowNumber(categoryContent, element);
18461
+ var countInRow = elementCountInRow(categoryContent, element);
18462
+
18463
+ if (!hasNextRow(categoryContent, element)) {
18464
+ var nextVisibleCategory = nextCategory(category);
18465
+
18466
+ if (!nextVisibleCategory) {
18467
+ return null;
18468
+ }
18469
+
18470
+ return getElementInRow(allVisibleEmojis(nextVisibleCategory), 0, countInRow, indexInRow);
18471
+ }
18472
+
18473
+ var itemInNextRow = getElementInNextRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
18474
+ return itemInNextRow;
18475
+ }
18476
+
18476
18477
  var css_248z$3 = ".EmojiPickerReact .epr-emoji-variation-picker{align-items:center;background:var(--epr-emoji-variation-picker-bg-color);border:1px solid var(--epr-picker-border-color);border-radius:3px;box-shadow:0 2px 5px rgba(0,0,0,.2);display:flex;height:0;height:var(--epr-emoji-variation-picker-height);justify-content:space-around;left:15px;opacity:0;padding:5px;pointer-events:none;position:absolute;right:15px;top:0;top:-100%;transform:scale(.9);transition:transform .1s ease-out,opacity .2s ease-out;visibility:hidden;z-index:var(--epr-skin-variation-picker-z-index)}.EmojiPickerReact .epr-emoji-variation-picker.pointing-up{transform:scale(.9);transform-origin:center 0}.EmojiPickerReact .epr-emoji-variation-picker.visible{opacity:1;pointer-events:all;transform:scale(1);visibility:visible}.EmojiPickerReact .epr-emoji-variation-picker .EmojiPickerReact .epr-emoji-variation-picker button.epr-emoji:hover{background:none}.EmojiPickerReact .epr-emoji-variation-picker .epr-emoji-pointer{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='50' height='15' xml:space='preserve'%3E%3Cg stroke-miterlimit='10'%3E%3Cpath fill='%23FFF' stroke='%23E8E7E7' d='m1.86-.43 9.83 11.53c.59.69 1.56.69 2.14 0L23.66-.43'/%3E%3Cpath fill='%23010202' stroke='%23151617' d='m26.86-.43 9.83 11.53c.59.69 1.56.69 2.14 0L48.66-.43'/%3E%3C/g%3E%3C/svg%3E\");background-position:0 0;background-repeat:no-repeat;background-size:50px 15px;content:\"\";height:15px;position:absolute;top:-10px;width:25px}.EmojiPickerReact.epr-dark-theme .epr-emoji-variation-picker .epr-emoji-pointer{background-position:-25px 0}.EmojiPickerReact .epr-emoji-variation-picker .epr-emoji-pointer{top:100%;transform:translateX(-18px)}.EmojiPickerReact .epr-emoji-variation-picker.pointing-up .epr-emoji-pointer{top:0;transform:rotate(180deg) translateY(100%) translateX(18px)}";
18477
18478
  styleInject(css_248z$3);
18478
18479
 
@@ -18501,10 +18502,17 @@ function EmojiVariationPicker() {
18501
18502
  var getEmojiUrl = useGetEmojiUrlConfig();
18502
18503
  var button = buttonFromTarget(AnchoredEmojiRef.current);
18503
18504
  var visible = emoji && button && emojiHasVariations(emoji) && button.classList.contains(ClassNames.emojiHasVariatios);
18505
+ useEffect(function () {
18506
+ if (!visible) {
18507
+ focusElement(AnchoredEmojiRef.current);
18508
+ return;
18509
+ }
18510
+
18511
+ focusFirstVisibleEmoji(VariationPickerRef.current);
18512
+ }, [VariationPickerRef, visible, AnchoredEmojiRef]);
18504
18513
  var top, pointerStyle;
18505
18514
 
18506
18515
  if (!visible && AnchoredEmojiRef.current) {
18507
- focusElement(AnchoredEmojiRef.current);
18508
18516
  setAnchoredEmojiRef(null);
18509
18517
  } else {
18510
18518
  top = getTop();
@@ -18514,7 +18522,7 @@ function EmojiVariationPicker() {
18514
18522
  var safeEmoji = asEmoji(emoji);
18515
18523
  return createElement("div", {
18516
18524
  ref: VariationPickerRef,
18517
- className: clsx('epr-emoji-variation-picker', {
18525
+ className: clsx(ClassNames.variationPicker, {
18518
18526
  visible: visible,
18519
18527
  'pointing-up': getMenuDirection() === Direction.Down
18520
18528
  }),
@@ -19209,7 +19217,7 @@ function useSearchInputKeyboardEvents() {
19209
19217
  break;
19210
19218
  }
19211
19219
  };
19212
- }, [focusSkinTonePicker, goDownFromSearchInput, setSkinToneFanOpenState, BodyRef]);
19220
+ }, [focusSkinTonePicker, goDownFromSearchInput, setSkinToneFanOpenState, BodyRef, isSkinToneInSearch]);
19213
19221
  useEffect(function () {
19214
19222
  var current = SearchInputRef.current;
19215
19223