emoji-picker-react 4.9.0 → 4.9.2
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/DomUtils/elementPositionInRow.d.ts +1 -1
- package/dist/emoji-picker-react.cjs.development.js +28 -10
- 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 +28 -10
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/DomUtils/elementPositionInRow.ts +27 -11
- package/src/DomUtils/scrollTo.ts +1 -1
- package/src/DomUtils/selectors.ts +1 -1
- package/src/components/emoji/ClickableEmojiButton.tsx +7 -1
|
@@ -6,5 +6,5 @@ export declare function hasNextRow(parent: NullableElement, element: NullableEle
|
|
|
6
6
|
export declare function getElementInRow(elements: HTMLElement[], row: number, elementsInRow: number, indexInRow: number): NullableElement;
|
|
7
7
|
export declare function getElementInNextRow(allElements: HTMLElement[], currentRow: number, elementsInRow: number, index: number): NullableElement;
|
|
8
8
|
export declare function getElementInPrevRow(allElements: HTMLElement[], currentRow: number, elementsInRow: number, index: number): NullableElement;
|
|
9
|
-
export declare function firstVisibleElementInContainer(parent: NullableElement, elements: HTMLElement[]): NullableElement;
|
|
9
|
+
export declare function firstVisibleElementInContainer(parent: NullableElement, elements: HTMLElement[], maxVisibilityDiffThreshold?: number): NullableElement;
|
|
10
10
|
export declare function hasNextElementSibling(element: HTMLElement): boolean;
|
|
@@ -17359,7 +17359,7 @@ function scrollTo(root, top) {
|
|
|
17359
17359
|
return;
|
|
17360
17360
|
}
|
|
17361
17361
|
requestAnimationFrame(function () {
|
|
17362
|
-
$eprBody.scrollTop = top
|
|
17362
|
+
$eprBody.scrollTop = top;
|
|
17363
17363
|
});
|
|
17364
17364
|
}
|
|
17365
17365
|
function scrollBy(root, by) {
|
|
@@ -18372,29 +18372,43 @@ function getElementInPrevRow(allElements, currentRow, elementsInRow, index) {
|
|
|
18372
18372
|
// default to last
|
|
18373
18373
|
return prevRowElements[index] || prevRowElements[prevRowElements.length - 1] || null;
|
|
18374
18374
|
}
|
|
18375
|
-
function firstVisibleElementInContainer(parent, elements) {
|
|
18375
|
+
function firstVisibleElementInContainer(parent, elements, maxVisibilityDiffThreshold) {
|
|
18376
|
+
if (maxVisibilityDiffThreshold === void 0) {
|
|
18377
|
+
maxVisibilityDiffThreshold = 0;
|
|
18378
|
+
}
|
|
18376
18379
|
if (!parent || !elements.length) {
|
|
18377
18380
|
return null;
|
|
18378
18381
|
}
|
|
18379
18382
|
var parentTop = parent.getBoundingClientRect().top;
|
|
18380
18383
|
var parentBottom = parent.getBoundingClientRect().bottom;
|
|
18381
|
-
var parentTopWithLabel = parentTop +
|
|
18384
|
+
var parentTopWithLabel = parentTop + getLabelHeight(parent);
|
|
18382
18385
|
var visibleElements = elements.find(function (element) {
|
|
18383
18386
|
var elementTop = element.getBoundingClientRect().top;
|
|
18384
18387
|
var elementBottom = element.getBoundingClientRect().bottom;
|
|
18385
|
-
|
|
18388
|
+
var maxVisibilityDiffPixels = element.clientHeight * maxVisibilityDiffThreshold;
|
|
18389
|
+
var elementTopWithAllowedDiff = elementTop + maxVisibilityDiffPixels;
|
|
18390
|
+
var elementBottomWithAllowedDiff = elementBottom - maxVisibilityDiffPixels;
|
|
18391
|
+
if (elementTopWithAllowedDiff < parentTopWithLabel) {
|
|
18386
18392
|
return false;
|
|
18387
18393
|
}
|
|
18388
|
-
return
|
|
18394
|
+
return elementTopWithAllowedDiff >= parentTop && elementTopWithAllowedDiff <= parentBottom || elementBottomWithAllowedDiff >= parentTop && elementBottomWithAllowedDiff <= parentBottom;
|
|
18389
18395
|
});
|
|
18390
18396
|
return visibleElements || null;
|
|
18391
18397
|
}
|
|
18392
18398
|
function hasNextElementSibling(element) {
|
|
18393
18399
|
return !!element.nextElementSibling;
|
|
18394
18400
|
}
|
|
18395
|
-
function
|
|
18396
|
-
var
|
|
18397
|
-
|
|
18401
|
+
function getLabelHeight(parentNode) {
|
|
18402
|
+
var labels = Array.from(parentNode.querySelectorAll(asSelectors(ClassNames.label)));
|
|
18403
|
+
for (var _i = 0, _labels = labels; _i < _labels.length; _i++) {
|
|
18404
|
+
var label = _labels[_i];
|
|
18405
|
+
var height = label.getBoundingClientRect().height;
|
|
18406
|
+
// return height if label is not hidden
|
|
18407
|
+
if (height > 0) {
|
|
18408
|
+
return height;
|
|
18409
|
+
}
|
|
18410
|
+
}
|
|
18411
|
+
return DEFAULT_LABEL_HEIGHT;
|
|
18398
18412
|
}
|
|
18399
18413
|
|
|
18400
18414
|
var EmojiButtonSelector = "button" + /*#__PURE__*/asSelectors(ClassNames.emoji);
|
|
@@ -18560,7 +18574,7 @@ function firstVisibleEmoji(parent) {
|
|
|
18560
18574
|
return null;
|
|
18561
18575
|
}
|
|
18562
18576
|
var allEmojis = allVisibleEmojis(parent);
|
|
18563
|
-
return firstVisibleElementInContainer(parent, allEmojis);
|
|
18577
|
+
return firstVisibleElementInContainer(parent, allEmojis, 0.1);
|
|
18564
18578
|
}
|
|
18565
18579
|
function prevCategory(element) {
|
|
18566
18580
|
var category = closestCategory(element);
|
|
@@ -18825,10 +18839,14 @@ function ClickableEmojiButton(_ref) {
|
|
|
18825
18839
|
return React.createElement(Button, {
|
|
18826
18840
|
className: flairup.cx(styles$2.emoji, hidden && commonStyles.hidden, hiddenOnSearch && commonInteractionStyles.hiddenOnSearch, (_cx = {}, _cx[ClassNames.visible] = !hidden && !hiddenOnSearch, _cx), !!(hasVariations && showVariations) && styles$2.hasVariations, noBackground && styles$2.noBackground, className),
|
|
18827
18841
|
"data-unified": unified,
|
|
18828
|
-
"aria-label": emojiNames
|
|
18842
|
+
"aria-label": getAriaLabel(emojiNames),
|
|
18829
18843
|
"data-full-name": emojiNames
|
|
18830
18844
|
}, children);
|
|
18831
18845
|
}
|
|
18846
|
+
function getAriaLabel(emojiNames) {
|
|
18847
|
+
var _emojiNames$;
|
|
18848
|
+
return emojiNames[0].match('flag-') ? (_emojiNames$ = emojiNames[1]) != null ? _emojiNames$ : emojiNames[0] : emojiNames[0];
|
|
18849
|
+
}
|
|
18832
18850
|
var styles$2 = /*#__PURE__*/stylesheet.create({
|
|
18833
18851
|
emoji: {
|
|
18834
18852
|
'.': ClassNames.emoji,
|