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.
@@ -15,6 +15,7 @@ export declare enum ClassNames {
15
15
  emojiPicker = "EmojiPickerReact",
16
16
  open = "epr-open",
17
17
  vertical = "epr-vertical",
18
- horizontal = "epr-horizontal"
18
+ horizontal = "epr-horizontal",
19
+ variationPicker = "epr-emoji-variation-picker"
19
20
  }
20
21
  export declare function asSelectors(...classNames: ClassNames[]): string;
@@ -27,6 +27,7 @@ var ClassNames;
27
27
  ClassNames["open"] = "epr-open";
28
28
  ClassNames["vertical"] = "epr-vertical";
29
29
  ClassNames["horizontal"] = "epr-horizontal";
30
+ ClassNames["variationPicker"] = "epr-emoji-variation-picker";
30
31
  })(ClassNames || (ClassNames = {}));
31
32
 
32
33
  function asSelectors() {
@@ -17630,198 +17631,12 @@ function useHasOpenToggles() {
17630
17631
  };
17631
17632
  }
17632
17633
 
17633
- function focusElement(element) {
17634
- if (!element) {
17635
- return;
17636
- }
17637
-
17638
- requestAnimationFrame(function () {
17639
- element.focus();
17640
- });
17641
- }
17642
- function focusPrevElementSibling(element) {
17643
- if (!element) return;
17644
- var prev = element.previousElementSibling;
17645
- focusElement(prev);
17646
- }
17647
- function focusNextElementSibling(element) {
17648
- if (!element) return;
17649
- var next = element.nextElementSibling;
17650
- focusElement(next);
17651
- }
17652
- function focusFirstElementChild(element) {
17653
- if (!element) return;
17654
- var first = element.firstElementChild;
17655
- focusElement(first);
17656
- }
17657
-
17658
- function scrollTo(root, top) {
17659
- if (top === void 0) {
17660
- top = 0;
17661
- }
17662
-
17663
- var $eprBody = queryScrollBody(root);
17664
-
17665
- if (!$eprBody) {
17666
- return;
17667
- }
17668
-
17669
- requestAnimationFrame(function () {
17670
- $eprBody.scrollTop = top + 1;
17671
- });
17672
- }
17673
- function scrollBy(root, by) {
17674
- var $eprBody = queryScrollBody(root);
17675
-
17676
- if (!$eprBody) {
17677
- return;
17678
- }
17679
-
17680
- requestAnimationFrame(function () {
17681
- $eprBody.scrollTop = $eprBody.scrollTop + by;
17682
- });
17683
- }
17684
- function useScrollTo() {
17685
- var BodyRef = useBodyRef();
17686
- return React.useCallback(function (top) {
17687
- requestAnimationFrame(function () {
17688
- if (BodyRef.current) {
17689
- BodyRef.current.scrollTop = top;
17690
- }
17691
- });
17692
- }, [BodyRef]);
17693
- }
17694
- function scrollEmojiAboveLabel(emoji) {
17695
- if (!isEmojiBehindLabel(emoji)) {
17696
- return;
17697
- }
17698
-
17699
- var scrollBody = closestScrollBody(emoji);
17700
- var by = emojiDistanceFromScrollTop(emoji);
17701
- scrollBy(scrollBody, -(categoryLabelHeight(closestCategory(emoji)) - by));
17702
- }
17703
-
17704
- function focusFirstVisibleEmoji(parent) {
17705
- var emoji = firstVisibleEmoji(parent);
17706
- focusElement(emoji);
17707
- scrollEmojiAboveLabel(emoji);
17708
- }
17709
- function focusAndClickFirstVisibleEmoji(parent) {
17710
- var firstEmoji = firstVisibleEmoji(parent);
17711
- focusElement(firstEmoji);
17712
- firstEmoji == null ? void 0 : firstEmoji.click();
17713
- }
17714
- function focusLastVisibleEmoji(parent) {
17715
- focusElement(lastVisibleEmoji(parent));
17716
- }
17717
- function focusNextVisibleEmoji(element) {
17718
- if (!element) {
17719
- return;
17720
- }
17721
-
17722
- var next = nextVisibleEmoji(element);
17723
-
17724
- if (!next) {
17725
- return focusFirstVisibleEmoji(nextCategory(element));
17726
- }
17727
-
17728
- focusElement(next);
17729
- scrollEmojiAboveLabel(next);
17730
- }
17731
- function focusPrevVisibleEmoji(element) {
17732
- if (!element) {
17733
- return;
17734
- }
17735
-
17736
- var prev = prevVisibleEmoji(element);
17737
-
17738
- if (!prev) {
17739
- return focusLastVisibleEmoji(prevCategory(element));
17740
- }
17741
-
17742
- focusElement(prev);
17743
- scrollEmojiAboveLabel(prev);
17744
- }
17745
- function focusVisibleEmojiOneRowUp(element, exitUp) {
17746
- if (!element) {
17747
- return;
17748
- }
17749
-
17750
- var prev = visibleEmojiOneRowUp(element);
17751
-
17752
- if (!prev) {
17753
- return exitUp();
17754
- }
17755
-
17756
- focusElement(prev);
17757
- scrollEmojiAboveLabel(prev);
17758
- }
17759
- function focusVisibleEmojiOneRowDown(element) {
17760
- if (!element) {
17761
- return;
17762
- }
17763
-
17764
- var next = visibleEmojiOneRowDown(element);
17765
- return focusElement(next);
17766
- }
17767
-
17768
- function visibleEmojiOneRowUp(element) {
17769
- if (!element) {
17770
- return null;
17771
- }
17772
-
17773
- var categoryContent = closestCategoryContent(element);
17774
- var category = closestCategory(categoryContent);
17775
- var indexInRow = elementIndexInRow(categoryContent, element);
17776
- var row = rowNumber(categoryContent, element);
17777
- var countInRow = elementCountInRow(categoryContent, element);
17778
-
17779
- if (row === 0) {
17780
- var prevVisibleCategory = prevCategory(category);
17781
-
17782
- if (!prevVisibleCategory) {
17783
- return null;
17784
- }
17785
-
17786
- return getElementInRow(allVisibleEmojis(prevVisibleCategory), -1, // last row
17787
- countInRow, indexInRow);
17788
- }
17789
-
17790
- return getElementInPrevRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
17791
- }
17792
-
17793
- function visibleEmojiOneRowDown(element) {
17794
- if (!element) {
17795
- return null;
17796
- }
17797
-
17798
- var categoryContent = closestCategoryContent(element);
17799
- var category = closestCategory(categoryContent);
17800
- var indexInRow = elementIndexInRow(categoryContent, element);
17801
- var row = rowNumber(categoryContent, element);
17802
- var countInRow = elementCountInRow(categoryContent, element);
17803
-
17804
- if (!hasNextRow(categoryContent, element)) {
17805
- var nextVisibleCategory = nextCategory(category);
17806
-
17807
- if (!nextVisibleCategory) {
17808
- return null;
17809
- }
17810
-
17811
- return getElementInRow(allVisibleEmojis(nextVisibleCategory), 0, countInRow, indexInRow);
17812
- }
17813
-
17814
- var itemInNextRow = getElementInNextRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
17815
- return itemInNextRow;
17816
- }
17817
-
17818
17634
  function useSetVariationPicker() {
17819
17635
  var setAnchoredEmojiRef = useSetAnchoredEmojiRef();
17820
17636
 
17821
17637
  var _useEmojiVariationPic = useEmojiVariationPickerState(),
17822
17638
  setEmojiVariationPicker = _useEmojiVariationPic[1];
17823
17639
 
17824
- var VariationPickerRef = useVariationPickerRef();
17825
17640
  return function setVariationPicker(element) {
17826
17641
  var _emojiFromElement = emojiFromElement(element),
17827
17642
  emoji = _emojiFromElement[0];
@@ -17832,9 +17647,6 @@ function useSetVariationPicker() {
17832
17647
 
17833
17648
  setAnchoredEmojiRef(element);
17834
17649
  setEmojiVariationPicker(emoji);
17835
- requestAnimationFrame(function () {
17836
- focusFirstVisibleEmoji(VariationPickerRef.current);
17837
- });
17838
17650
  };
17839
17651
  }
17840
17652
 
@@ -17984,6 +17796,81 @@ function useOnScroll(BodyRef) {
17984
17796
  }, [BodyRef, closeAllOpenToggles]);
17985
17797
  }
17986
17798
 
17799
+ function scrollTo(root, top) {
17800
+ if (top === void 0) {
17801
+ top = 0;
17802
+ }
17803
+
17804
+ var $eprBody = queryScrollBody(root);
17805
+
17806
+ if (!$eprBody) {
17807
+ return;
17808
+ }
17809
+
17810
+ requestAnimationFrame(function () {
17811
+ $eprBody.scrollTop = top + 1;
17812
+ });
17813
+ }
17814
+ function scrollBy(root, by) {
17815
+ var $eprBody = queryScrollBody(root);
17816
+
17817
+ if (!$eprBody) {
17818
+ return;
17819
+ }
17820
+
17821
+ requestAnimationFrame(function () {
17822
+ $eprBody.scrollTop = $eprBody.scrollTop + by;
17823
+ });
17824
+ }
17825
+ function useScrollTo() {
17826
+ var BodyRef = useBodyRef();
17827
+ return React.useCallback(function (top) {
17828
+ requestAnimationFrame(function () {
17829
+ if (BodyRef.current) {
17830
+ BodyRef.current.scrollTop = top;
17831
+ }
17832
+ });
17833
+ }, [BodyRef]);
17834
+ }
17835
+ function scrollEmojiAboveLabel(emoji) {
17836
+ if (!emoji || !isEmojiBehindLabel(emoji)) {
17837
+ return;
17838
+ }
17839
+
17840
+ if (emoji.closest(asSelectors(ClassNames.variationPicker))) {
17841
+ return;
17842
+ }
17843
+
17844
+ var scrollBody = closestScrollBody(emoji);
17845
+ var by = emojiDistanceFromScrollTop(emoji);
17846
+ scrollBy(scrollBody, -(categoryLabelHeight(closestCategory(emoji)) - by));
17847
+ }
17848
+
17849
+ function focusElement(element) {
17850
+ if (!element) {
17851
+ return;
17852
+ }
17853
+
17854
+ requestAnimationFrame(function () {
17855
+ element.focus();
17856
+ });
17857
+ }
17858
+ function focusPrevElementSibling(element) {
17859
+ if (!element) return;
17860
+ var prev = element.previousElementSibling;
17861
+ focusElement(prev);
17862
+ }
17863
+ function focusNextElementSibling(element) {
17864
+ if (!element) return;
17865
+ var next = element.nextElementSibling;
17866
+ focusElement(next);
17867
+ }
17868
+ function focusFirstElementChild(element) {
17869
+ if (!element) return;
17870
+ var first = element.firstElementChild;
17871
+ focusElement(first);
17872
+ }
17873
+
17987
17874
  function useFocusSearchInput() {
17988
17875
  var SearchInputRef = useSearchInputRef();
17989
17876
  return React.useCallback(function () {
@@ -18431,6 +18318,120 @@ function RenderCategory(_ref) {
18431
18318
  }, emojis);
18432
18319
  }
18433
18320
 
18321
+ function focusFirstVisibleEmoji(parent) {
18322
+ var emoji = firstVisibleEmoji(parent);
18323
+ focusElement(emoji);
18324
+ scrollEmojiAboveLabel(emoji);
18325
+ }
18326
+ function focusAndClickFirstVisibleEmoji(parent) {
18327
+ var firstEmoji = firstVisibleEmoji(parent);
18328
+ focusElement(firstEmoji);
18329
+ firstEmoji == null ? void 0 : firstEmoji.click();
18330
+ }
18331
+ function focusLastVisibleEmoji(parent) {
18332
+ focusElement(lastVisibleEmoji(parent));
18333
+ }
18334
+ function focusNextVisibleEmoji(element) {
18335
+ if (!element) {
18336
+ return;
18337
+ }
18338
+
18339
+ var next = nextVisibleEmoji(element);
18340
+
18341
+ if (!next) {
18342
+ return focusFirstVisibleEmoji(nextCategory(element));
18343
+ }
18344
+
18345
+ focusElement(next);
18346
+ scrollEmojiAboveLabel(next);
18347
+ }
18348
+ function focusPrevVisibleEmoji(element) {
18349
+ if (!element) {
18350
+ return;
18351
+ }
18352
+
18353
+ var prev = prevVisibleEmoji(element);
18354
+
18355
+ if (!prev) {
18356
+ return focusLastVisibleEmoji(prevCategory(element));
18357
+ }
18358
+
18359
+ focusElement(prev);
18360
+ scrollEmojiAboveLabel(prev);
18361
+ }
18362
+ function focusVisibleEmojiOneRowUp(element, exitUp) {
18363
+ if (!element) {
18364
+ return;
18365
+ }
18366
+
18367
+ var prev = visibleEmojiOneRowUp(element);
18368
+
18369
+ if (!prev) {
18370
+ return exitUp();
18371
+ }
18372
+
18373
+ focusElement(prev);
18374
+ scrollEmojiAboveLabel(prev);
18375
+ }
18376
+ function focusVisibleEmojiOneRowDown(element) {
18377
+ if (!element) {
18378
+ return;
18379
+ }
18380
+
18381
+ var next = visibleEmojiOneRowDown(element);
18382
+ return focusElement(next);
18383
+ }
18384
+
18385
+ function visibleEmojiOneRowUp(element) {
18386
+ if (!element) {
18387
+ return null;
18388
+ }
18389
+
18390
+ var categoryContent = closestCategoryContent(element);
18391
+ var category = closestCategory(categoryContent);
18392
+ var indexInRow = elementIndexInRow(categoryContent, element);
18393
+ var row = rowNumber(categoryContent, element);
18394
+ var countInRow = elementCountInRow(categoryContent, element);
18395
+
18396
+ if (row === 0) {
18397
+ var prevVisibleCategory = prevCategory(category);
18398
+
18399
+ if (!prevVisibleCategory) {
18400
+ return null;
18401
+ }
18402
+
18403
+ return getElementInRow(allVisibleEmojis(prevVisibleCategory), -1, // last row
18404
+ countInRow, indexInRow);
18405
+ }
18406
+
18407
+ return getElementInPrevRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
18408
+ }
18409
+
18410
+ function visibleEmojiOneRowDown(element) {
18411
+ if (!element) {
18412
+ return null;
18413
+ }
18414
+
18415
+ var categoryContent = closestCategoryContent(element);
18416
+ var category = closestCategory(categoryContent);
18417
+ var indexInRow = elementIndexInRow(categoryContent, element);
18418
+ var row = rowNumber(categoryContent, element);
18419
+ var countInRow = elementCountInRow(categoryContent, element);
18420
+
18421
+ if (!hasNextRow(categoryContent, element)) {
18422
+ var nextVisibleCategory = nextCategory(category);
18423
+
18424
+ if (!nextVisibleCategory) {
18425
+ return null;
18426
+ }
18427
+
18428
+ return getElementInRow(allVisibleEmojis(nextVisibleCategory), 0, countInRow, indexInRow);
18429
+ }
18430
+
18431
+ var itemInNextRow = getElementInNextRow(allVisibleEmojis(categoryContent), row, countInRow, indexInRow);
18432
+ return itemInNextRow;
18433
+ }
18434
+
18434
18435
  var Direction;
18435
18436
 
18436
18437
  (function (Direction) {
@@ -18456,10 +18457,17 @@ function EmojiVariationPicker() {
18456
18457
  var getEmojiUrl = useGetEmojiUrlConfig();
18457
18458
  var button = buttonFromTarget(AnchoredEmojiRef.current);
18458
18459
  var visible = emoji && button && emojiHasVariations(emoji) && button.classList.contains(ClassNames.emojiHasVariatios);
18460
+ React.useEffect(function () {
18461
+ if (!visible) {
18462
+ focusElement(AnchoredEmojiRef.current);
18463
+ return;
18464
+ }
18465
+
18466
+ focusFirstVisibleEmoji(VariationPickerRef.current);
18467
+ }, [VariationPickerRef, visible, AnchoredEmojiRef]);
18459
18468
  var top, pointerStyle;
18460
18469
 
18461
18470
  if (!visible && AnchoredEmojiRef.current) {
18462
- focusElement(AnchoredEmojiRef.current);
18463
18471
  setAnchoredEmojiRef(null);
18464
18472
  } else {
18465
18473
  top = getTop();
@@ -18469,7 +18477,7 @@ function EmojiVariationPicker() {
18469
18477
  var safeEmoji = asEmoji(emoji);
18470
18478
  return React.createElement("div", {
18471
18479
  ref: VariationPickerRef,
18472
- className: clsx('epr-emoji-variation-picker', {
18480
+ className: clsx(ClassNames.variationPicker, {
18473
18481
  visible: visible,
18474
18482
  'pointing-up': getMenuDirection() === Direction.Down
18475
18483
  }),
@@ -19143,7 +19151,7 @@ function useSearchInputKeyboardEvents() {
19143
19151
  break;
19144
19152
  }
19145
19153
  };
19146
- }, [focusSkinTonePicker, goDownFromSearchInput, setSkinToneFanOpenState, BodyRef]);
19154
+ }, [focusSkinTonePicker, goDownFromSearchInput, setSkinToneFanOpenState, BodyRef, isSkinToneInSearch]);
19147
19155
  React.useEffect(function () {
19148
19156
  var current = SearchInputRef.current;
19149
19157