emoji-picker-react 4.8.0 → 4.9.1
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/README.md +3 -0
- package/dist/DomUtils/elementPositionInRow.d.ts +1 -1
- package/dist/config/config.d.ts +2 -0
- package/dist/config/mutableConfig.d.ts +2 -1
- package/dist/config/useConfig.d.ts +1 -0
- package/dist/emoji-picker-react.cjs.development.js +37 -11
- 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 +37 -11
- 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/header/SkinTonePicker/SkinTonePicker.tsx +3 -1
- package/src/config/config.ts +2 -0
- package/src/config/mutableConfig.ts +8 -2
- package/src/config/useConfig.ts +7 -0
- package/src/index.tsx +2 -1
|
@@ -16892,12 +16892,16 @@ function useMutableConfig() {
|
|
|
16892
16892
|
function useDefineMutableConfig(config) {
|
|
16893
16893
|
var MutableConfigRef = React__default.useRef({
|
|
16894
16894
|
onEmojiClick: config.onEmojiClick || emptyFunc,
|
|
16895
|
-
onReactionClick: config.onReactionClick || config.onEmojiClick
|
|
16895
|
+
onReactionClick: config.onReactionClick || config.onEmojiClick,
|
|
16896
|
+
onSkinToneChange: config.onSkinToneChange || emptyFunc
|
|
16896
16897
|
});
|
|
16897
16898
|
React__default.useEffect(function () {
|
|
16898
16899
|
MutableConfigRef.current.onEmojiClick = config.onEmojiClick || emptyFunc;
|
|
16899
16900
|
MutableConfigRef.current.onReactionClick = config.onReactionClick || config.onEmojiClick;
|
|
16900
16901
|
}, [config.onEmojiClick, config.onReactionClick]);
|
|
16902
|
+
React__default.useEffect(function () {
|
|
16903
|
+
MutableConfigRef.current.onSkinToneChange = config.onSkinToneChange || emptyFunc;
|
|
16904
|
+
}, [config.onSkinToneChange]);
|
|
16901
16905
|
return MutableConfigRef;
|
|
16902
16906
|
}
|
|
16903
16907
|
function emptyFunc() {}
|
|
@@ -16963,6 +16967,11 @@ function useOnEmojiClickConfig(mouseEventSource) {
|
|
|
16963
16967
|
var handler = (_ref = mouseEventSource === MOUSE_EVENT_SOURCE.REACTIONS ? current.onReactionClick : current.onEmojiClick) != null ? _ref : current.onEmojiClick;
|
|
16964
16968
|
return handler || function () {};
|
|
16965
16969
|
}
|
|
16970
|
+
function useOnSkinToneChangeConfig() {
|
|
16971
|
+
var _useMutableConfig2 = useMutableConfig(),
|
|
16972
|
+
current = _useMutableConfig2.current;
|
|
16973
|
+
return current.onSkinToneChange || function () {};
|
|
16974
|
+
}
|
|
16966
16975
|
function usePreviewConfig() {
|
|
16967
16976
|
var _usePickerConfig10 = usePickerConfig(),
|
|
16968
16977
|
previewConfig = _usePickerConfig10.previewConfig;
|
|
@@ -17349,7 +17358,7 @@ function scrollTo(root, top) {
|
|
|
17349
17358
|
return;
|
|
17350
17359
|
}
|
|
17351
17360
|
requestAnimationFrame(function () {
|
|
17352
|
-
$eprBody.scrollTop = top
|
|
17361
|
+
$eprBody.scrollTop = top;
|
|
17353
17362
|
});
|
|
17354
17363
|
}
|
|
17355
17364
|
function scrollBy(root, by) {
|
|
@@ -18362,29 +18371,43 @@ function getElementInPrevRow(allElements, currentRow, elementsInRow, index) {
|
|
|
18362
18371
|
// default to last
|
|
18363
18372
|
return prevRowElements[index] || prevRowElements[prevRowElements.length - 1] || null;
|
|
18364
18373
|
}
|
|
18365
|
-
function firstVisibleElementInContainer(parent, elements) {
|
|
18374
|
+
function firstVisibleElementInContainer(parent, elements, maxVisibilityDiffThreshold) {
|
|
18375
|
+
if (maxVisibilityDiffThreshold === void 0) {
|
|
18376
|
+
maxVisibilityDiffThreshold = 0;
|
|
18377
|
+
}
|
|
18366
18378
|
if (!parent || !elements.length) {
|
|
18367
18379
|
return null;
|
|
18368
18380
|
}
|
|
18369
18381
|
var parentTop = parent.getBoundingClientRect().top;
|
|
18370
18382
|
var parentBottom = parent.getBoundingClientRect().bottom;
|
|
18371
|
-
var parentTopWithLabel = parentTop +
|
|
18383
|
+
var parentTopWithLabel = parentTop + getLabelHeight(parent);
|
|
18372
18384
|
var visibleElements = elements.find(function (element) {
|
|
18373
18385
|
var elementTop = element.getBoundingClientRect().top;
|
|
18374
18386
|
var elementBottom = element.getBoundingClientRect().bottom;
|
|
18375
|
-
|
|
18387
|
+
var maxVisibilityDiffPixels = element.clientHeight * maxVisibilityDiffThreshold;
|
|
18388
|
+
var elementTopWithAllowedDiff = elementTop + maxVisibilityDiffPixels;
|
|
18389
|
+
var elementBottomWithAllowedDiff = elementBottom - maxVisibilityDiffPixels;
|
|
18390
|
+
if (elementTopWithAllowedDiff < parentTopWithLabel) {
|
|
18376
18391
|
return false;
|
|
18377
18392
|
}
|
|
18378
|
-
return
|
|
18393
|
+
return elementTopWithAllowedDiff >= parentTop && elementTopWithAllowedDiff <= parentBottom || elementBottomWithAllowedDiff >= parentTop && elementBottomWithAllowedDiff <= parentBottom;
|
|
18379
18394
|
});
|
|
18380
18395
|
return visibleElements || null;
|
|
18381
18396
|
}
|
|
18382
18397
|
function hasNextElementSibling(element) {
|
|
18383
18398
|
return !!element.nextElementSibling;
|
|
18384
18399
|
}
|
|
18385
|
-
function
|
|
18386
|
-
var
|
|
18387
|
-
|
|
18400
|
+
function getLabelHeight(parentNode) {
|
|
18401
|
+
var labels = Array.from(parentNode.querySelectorAll(asSelectors(ClassNames.label)));
|
|
18402
|
+
for (var _i = 0, _labels = labels; _i < _labels.length; _i++) {
|
|
18403
|
+
var label = _labels[_i];
|
|
18404
|
+
var height = label.getBoundingClientRect().height;
|
|
18405
|
+
// return height if label is not hidden
|
|
18406
|
+
if (height > 0) {
|
|
18407
|
+
return height;
|
|
18408
|
+
}
|
|
18409
|
+
}
|
|
18410
|
+
return DEFAULT_LABEL_HEIGHT;
|
|
18388
18411
|
}
|
|
18389
18412
|
|
|
18390
18413
|
var EmojiButtonSelector = "button" + /*#__PURE__*/asSelectors(ClassNames.emoji);
|
|
@@ -18550,7 +18573,7 @@ function firstVisibleEmoji(parent) {
|
|
|
18550
18573
|
return null;
|
|
18551
18574
|
}
|
|
18552
18575
|
var allEmojis = allVisibleEmojis(parent);
|
|
18553
|
-
return firstVisibleElementInContainer(parent, allEmojis);
|
|
18576
|
+
return firstVisibleElementInContainer(parent, allEmojis, 0.1);
|
|
18554
18577
|
}
|
|
18555
18578
|
function prevCategory(element) {
|
|
18556
18579
|
var category = closestCategory(element);
|
|
@@ -19786,6 +19809,7 @@ function SkinTonePicker(_ref) {
|
|
|
19786
19809
|
var _useActiveSkinToneSta = useActiveSkinToneState(),
|
|
19787
19810
|
activeSkinTone = _useActiveSkinToneSta[0],
|
|
19788
19811
|
setActiveSkinTone = _useActiveSkinToneSta[1];
|
|
19812
|
+
var onSkinToneChange = useOnSkinToneChangeConfig();
|
|
19789
19813
|
var closeAllOpenToggles = useCloseAllOpenToggles();
|
|
19790
19814
|
var focusSearchInput = useFocusSearchInput();
|
|
19791
19815
|
if (isDisabled) {
|
|
@@ -19818,6 +19842,7 @@ function SkinTonePicker(_ref) {
|
|
|
19818
19842
|
onClick: function onClick() {
|
|
19819
19843
|
if (isOpen) {
|
|
19820
19844
|
setActiveSkinTone(skinToneVariation);
|
|
19845
|
+
onSkinToneChange(skinToneVariation);
|
|
19821
19846
|
focusSearchInput();
|
|
19822
19847
|
} else {
|
|
19823
19848
|
setIsOpen(true);
|
|
@@ -20512,7 +20537,8 @@ function ExportedEmoji(_ref) {
|
|
|
20512
20537
|
function EmojiPicker$1(props) {
|
|
20513
20538
|
var MutableConfigRef = useDefineMutableConfig({
|
|
20514
20539
|
onEmojiClick: props.onEmojiClick,
|
|
20515
|
-
onReactionClick: props.onReactionClick
|
|
20540
|
+
onReactionClick: props.onReactionClick,
|
|
20541
|
+
onSkinToneChange: props.onSkinToneChange
|
|
20516
20542
|
});
|
|
20517
20543
|
return createElement(ErrorBoundary, null, createElement(MutableConfigContext.Provider, {
|
|
20518
20544
|
value: MutableConfigRef
|