@pushwoosh/dumb-components 1.1.9 → 1.1.10
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.
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
import Picker from '
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import { Picker } from 'emoji-mart';
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
3
|
import { EmojiPickerStyled } from './EmojiPicker.styled';
|
|
4
4
|
async function data() {
|
|
5
5
|
const response = await fetch('https://cdn.jsdelivr.net/npm/@emoji-mart/data');
|
|
6
6
|
return response.json();
|
|
7
7
|
}
|
|
8
|
+
function PickerBase(props) {
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
const instance = useRef(null);
|
|
11
|
+
if (instance.current) {
|
|
12
|
+
instance.current.update(props);
|
|
13
|
+
}
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
var _window;
|
|
16
|
+
const PickerElement = (_window = window) === null || _window === void 0 ? void 0 : _window.customElements.get('em-emoji-picker');
|
|
17
|
+
instance.current = new (PickerElement || Picker)({
|
|
18
|
+
...props,
|
|
19
|
+
ref
|
|
20
|
+
});
|
|
21
|
+
return () => {
|
|
22
|
+
instance.current = null;
|
|
23
|
+
};
|
|
24
|
+
}, [props]);
|
|
25
|
+
return React.createElement('div', {
|
|
26
|
+
ref
|
|
27
|
+
});
|
|
28
|
+
}
|
|
8
29
|
export const EmojiPicker = ({
|
|
9
30
|
onEmojiSelect
|
|
10
31
|
}) => {
|
|
11
|
-
return React.createElement(EmojiPickerStyled, null, React.createElement(
|
|
32
|
+
return React.createElement(EmojiPickerStyled, null, React.createElement(PickerBase, {
|
|
12
33
|
data: data,
|
|
13
34
|
onEmojiSelect: emoji => {
|
|
14
35
|
onEmojiSelect(emoji.native);
|