@chayns-components/emoji-input 5.0.0-beta.78 → 5.0.0-beta.80
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/lib/api/item-storage/get.d.ts +8 -0
- package/lib/api/item-storage/get.js +37 -0
- package/lib/api/item-storage/get.js.map +1 -0
- package/lib/api/item-storage/put.d.ts +9 -0
- package/lib/api/item-storage/put.js +42 -0
- package/lib/api/item-storage/put.js.map +1 -0
- package/lib/components/emoji-input/EmojiInput.d.ts +8 -0
- package/lib/components/emoji-input/EmojiInput.js +10 -6
- package/lib/components/emoji-input/EmojiInput.js.map +1 -1
- package/lib/components/emoji-picker/EmojiPicker.d.ts +8 -0
- package/lib/components/emoji-picker/EmojiPicker.js +5 -1
- package/lib/components/emoji-picker/EmojiPicker.js.map +1 -1
- package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +25 -19
- package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.d.ts +2 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +73 -16
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +0 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +2 -12
- package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -1
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.d.ts +8 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +105 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +1 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +20 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +15 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +72 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +11 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +105 -0
- package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.d.ts +8 -0
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +6 -2
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -1
- package/lib/constants/alignment.d.ts +4 -0
- package/lib/constants/alignment.js +7 -1
- package/lib/constants/alignment.js.map +1 -1
- package/lib/constants/categories.d.ts +1 -0
- package/lib/constants/categories.js +1 -0
- package/lib/constants/categories.js.map +1 -1
- package/lib/constants/externalServerUrl.d.ts +1 -0
- package/lib/constants/externalServerUrl.js +9 -0
- package/lib/constants/externalServerUrl.js.map +1 -0
- package/lib/hooks/emojiHistory.d.ts +22 -0
- package/lib/hooks/emojiHistory.js +91 -0
- package/lib/hooks/emojiHistory.js.map +1 -0
- package/lib/types/api.d.ts +4 -0
- package/lib/types/api.js +6 -0
- package/lib/types/api.js.map +1 -0
- package/lib/types/category.d.ts +1 -1
- package/lib/types/category.js.map +1 -1
- package/lib/utils/emoji.d.ts +1 -0
- package/lib/utils/emoji.js +15 -1
- package/lib/utils/emoji.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HistoryItem } from '../../hooks/emojiHistory';
|
|
2
|
+
import type { ApiFunctionResult } from '../../types/api';
|
|
3
|
+
interface GetEmojiHistoryOptions {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
personId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getEmojiHistory: ({ accessToken, personId, }: GetEmojiHistoryOptions) => Promise<ApiFunctionResult<HistoryItem[]>>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEmojiHistory = void 0;
|
|
7
|
+
var _externalServerUrl = require("../../constants/externalServerUrl");
|
|
8
|
+
const getEmojiHistory = async _ref => {
|
|
9
|
+
let {
|
|
10
|
+
accessToken,
|
|
11
|
+
personId
|
|
12
|
+
} = _ref;
|
|
13
|
+
const requestInit = {
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${accessToken}`
|
|
16
|
+
},
|
|
17
|
+
method: 'GET'
|
|
18
|
+
};
|
|
19
|
+
const url = `${_externalServerUrl.ITEM_STORAGE_BASE_URL}/7/users/${personId}/keys/emojis`;
|
|
20
|
+
const response = await fetch(url, requestInit);
|
|
21
|
+
if (response.status === 200) {
|
|
22
|
+
try {
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
return {
|
|
25
|
+
data: data.value,
|
|
26
|
+
status: 200
|
|
27
|
+
};
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// Do nothing
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
status: response.status
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.getEmojiHistory = getEmojiHistory;
|
|
37
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","names":["_externalServerUrl","require","getEmojiHistory","_ref","accessToken","personId","requestInit","headers","Authorization","method","url","ITEM_STORAGE_BASE_URL","response","fetch","status","data","json","value","e","exports"],"sources":["../../../src/api/item-storage/get.ts"],"sourcesContent":["import { ITEM_STORAGE_BASE_URL } from '../../constants/externalServerUrl';\nimport type { HistoryItem } from '../../hooks/emojiHistory';\nimport type { ApiFunctionResult } from '../../types/api';\n\ninterface GetEmojiHistoryOptions {\n accessToken: string;\n personId: string;\n}\n\ninterface GetEmojiHistoryResponseData {\n key: string;\n personId: string;\n schemeId: string;\n value: HistoryItem[];\n}\n\nexport const getEmojiHistory = async ({\n accessToken,\n personId,\n}: GetEmojiHistoryOptions): Promise<ApiFunctionResult<HistoryItem[]>> => {\n const requestInit: RequestInit = {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n method: 'GET',\n };\n\n const url = `${ITEM_STORAGE_BASE_URL}/7/users/${personId}/keys/emojis`;\n\n const response = await fetch(url, requestInit);\n\n if (response.status === 200) {\n try {\n const data = (await response.json()) as GetEmojiHistoryResponseData;\n\n return { data: data.value, status: 200 };\n } catch (e) {\n // Do nothing\n }\n }\n\n return { status: response.status };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAgBO,MAAMC,eAAe,GAAG,MAAAC,IAAA,IAG0C;EAAA,IAHnC;IAClCC,WAAW;IACXC;EACoB,CAAC,GAAAF,IAAA;EACrB,MAAMG,WAAwB,GAAG;IAC7BC,OAAO,EAAE;MACLC,aAAa,EAAG,UAASJ,WAAY;IACzC,CAAC;IACDK,MAAM,EAAE;EACZ,CAAC;EAED,MAAMC,GAAG,GAAI,GAAEC,wCAAsB,YAAWN,QAAS,cAAa;EAEtE,MAAMO,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAG,EAAEJ,WAAW,CAAC;EAE9C,IAAIM,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IACzB,IAAI;MACA,MAAMC,IAAI,GAAI,MAAMH,QAAQ,CAACI,IAAI,EAAkC;MAEnE,OAAO;QAAED,IAAI,EAAEA,IAAI,CAACE,KAAK;QAAEH,MAAM,EAAE;MAAI,CAAC;IAC5C,CAAC,CAAC,OAAOI,CAAC,EAAE;MACR;IAAA;EAER;EAEA,OAAO;IAAEJ,MAAM,EAAEF,QAAQ,CAACE;EAAO,CAAC;AACtC,CAAC;AAACK,OAAA,CAAAjB,eAAA,GAAAA,eAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HistoryItem } from '../../hooks/emojiHistory';
|
|
2
|
+
import type { ApiFunctionResult } from '../../types/api';
|
|
3
|
+
interface PutEmojiHistoryOptions {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
personId: string;
|
|
6
|
+
value: HistoryItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare const putEmojiHistory: ({ accessToken, personId, value, }: PutEmojiHistoryOptions) => Promise<ApiFunctionResult<HistoryItem[]>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.putEmojiHistory = void 0;
|
|
7
|
+
var _externalServerUrl = require("../../constants/externalServerUrl");
|
|
8
|
+
const putEmojiHistory = async _ref => {
|
|
9
|
+
let {
|
|
10
|
+
accessToken,
|
|
11
|
+
personId,
|
|
12
|
+
value
|
|
13
|
+
} = _ref;
|
|
14
|
+
const requestInit = {
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
value
|
|
17
|
+
}),
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${accessToken}`,
|
|
20
|
+
'Content-Type': 'application/json'
|
|
21
|
+
},
|
|
22
|
+
method: 'PUT'
|
|
23
|
+
};
|
|
24
|
+
const url = `${_externalServerUrl.ITEM_STORAGE_BASE_URL}/7/users/${personId}/keys/emojis`;
|
|
25
|
+
const response = await fetch(url, requestInit);
|
|
26
|
+
if (response.status === 201) {
|
|
27
|
+
try {
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
return {
|
|
30
|
+
data: data.value,
|
|
31
|
+
status: 200
|
|
32
|
+
};
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Do nothing
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
status: response.status
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.putEmojiHistory = putEmojiHistory;
|
|
42
|
+
//# sourceMappingURL=put.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"put.js","names":["_externalServerUrl","require","putEmojiHistory","_ref","accessToken","personId","value","requestInit","body","JSON","stringify","headers","Authorization","method","url","ITEM_STORAGE_BASE_URL","response","fetch","status","data","json","e","exports"],"sources":["../../../src/api/item-storage/put.ts"],"sourcesContent":["import { ITEM_STORAGE_BASE_URL } from '../../constants/externalServerUrl';\nimport type { HistoryItem } from '../../hooks/emojiHistory';\nimport type { ApiFunctionResult } from '../../types/api';\n\ninterface PutEmojiHistoryOptions {\n accessToken: string;\n personId: string;\n value: HistoryItem[];\n}\n\ninterface PutEmojiHistoryResponseData {\n key: string;\n personId: string;\n schemeId: string;\n value: HistoryItem[];\n}\n\nexport const putEmojiHistory = async ({\n accessToken,\n personId,\n value,\n}: PutEmojiHistoryOptions): Promise<ApiFunctionResult<HistoryItem[]>> => {\n const requestInit: RequestInit = {\n body: JSON.stringify({ value }),\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n };\n\n const url = `${ITEM_STORAGE_BASE_URL}/7/users/${personId}/keys/emojis`;\n\n const response = await fetch(url, requestInit);\n\n if (response.status === 201) {\n try {\n const data = (await response.json()) as PutEmojiHistoryResponseData;\n\n return { data: data.value, status: 200 };\n } catch (e) {\n // Do nothing\n }\n }\n\n return { status: response.status };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAiBO,MAAMC,eAAe,GAAG,MAAAC,IAAA,IAI0C;EAAA,IAJnC;IAClCC,WAAW;IACXC,QAAQ;IACRC;EACoB,CAAC,GAAAH,IAAA;EACrB,MAAMI,WAAwB,GAAG;IAC7BC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MAAEJ;IAAM,CAAC,CAAC;IAC/BK,OAAO,EAAE;MACLC,aAAa,EAAG,UAASR,WAAY,EAAC;MACtC,cAAc,EAAE;IACpB,CAAC;IACDS,MAAM,EAAE;EACZ,CAAC;EAED,MAAMC,GAAG,GAAI,GAAEC,wCAAsB,YAAWV,QAAS,cAAa;EAEtE,MAAMW,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAG,EAAEP,WAAW,CAAC;EAE9C,IAAIS,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IACzB,IAAI;MACA,MAAMC,IAAI,GAAI,MAAMH,QAAQ,CAACI,IAAI,EAAkC;MAEnE,OAAO;QAAED,IAAI,EAAEA,IAAI,CAACb,KAAK;QAAEY,MAAM,EAAE;MAAI,CAAC;IAC5C,CAAC,CAAC,OAAOG,CAAC,EAAE;MACR;IAAA;EAER;EAEA,OAAO;IAAEH,MAAM,EAAEF,QAAQ,CAACE;EAAO,CAAC;AACtC,CAAC;AAACI,OAAA,CAAApB,eAAA,GAAAA,eAAA"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ChangeEventHandler, FC, KeyboardEventHandler, ReactNode } from 'react';
|
|
2
2
|
import type { PopupAlignment } from '../../constants/alignment';
|
|
3
3
|
export type EmojiInputProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Access token of the logged-in user. Is needed to load and save the history of the emojis.
|
|
6
|
+
*/
|
|
7
|
+
accessToken?: string;
|
|
4
8
|
/**
|
|
5
9
|
* Disables the input so that it cannot be changed anymore
|
|
6
10
|
*/
|
|
@@ -18,6 +22,10 @@ export type EmojiInputProps = {
|
|
|
18
22
|
* @param {boolean} isVisible - Whether the popup is visible or not
|
|
19
23
|
*/
|
|
20
24
|
onPopupVisibilityChange?: (isVisible: boolean) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Person id of the logged-in user. Is needed to load and save the history of the emojis.
|
|
27
|
+
*/
|
|
28
|
+
personId?: string;
|
|
21
29
|
/**
|
|
22
30
|
* Placeholder for the input field
|
|
23
31
|
*/
|
|
@@ -15,10 +15,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
15
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
16
|
const EmojiInput = _ref => {
|
|
17
17
|
let {
|
|
18
|
+
accessToken,
|
|
18
19
|
isDisabled,
|
|
19
20
|
onInput,
|
|
20
21
|
onKeyDown,
|
|
21
22
|
onPopupVisibilityChange,
|
|
23
|
+
personId,
|
|
22
24
|
placeholder,
|
|
23
25
|
popupAlignment,
|
|
24
26
|
rightElement,
|
|
@@ -39,10 +41,10 @@ const EmojiInput = _ref => {
|
|
|
39
41
|
if (!editorRef.current) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
+
const newInnerText = (0, _emoji.convertAsciiToUnicode)(text);
|
|
45
|
+
if (newInnerText !== editorRef.current.innerText) {
|
|
44
46
|
(0, _selection.saveSelection)(editorRef.current);
|
|
45
|
-
editorRef.current.
|
|
47
|
+
editorRef.current.innerText = newInnerText;
|
|
46
48
|
(0, _selection.restoreSelection)(editorRef.current);
|
|
47
49
|
}
|
|
48
50
|
}, []);
|
|
@@ -55,7 +57,7 @@ const EmojiInput = _ref => {
|
|
|
55
57
|
if (!editorRef.current) {
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
|
-
handleUpdateText(editorRef.current.
|
|
60
|
+
handleUpdateText(editorRef.current.innerText);
|
|
59
61
|
if (typeof onInput === 'function') {
|
|
60
62
|
onInput(event);
|
|
61
63
|
}
|
|
@@ -105,7 +107,7 @@ const EmojiInput = _ref => {
|
|
|
105
107
|
selection.removeAllRanges();
|
|
106
108
|
selection.addRange(newRange);
|
|
107
109
|
} else {
|
|
108
|
-
editorRef.current.
|
|
110
|
+
editorRef.current.innerText += emoji;
|
|
109
111
|
}
|
|
110
112
|
const event = new Event('input', {
|
|
111
113
|
bubbles: true
|
|
@@ -149,9 +151,11 @@ const EmojiInput = _ref => {
|
|
|
149
151
|
placeholder: placeholder,
|
|
150
152
|
ref: editorRef
|
|
151
153
|
}), !isMobile && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.default, {
|
|
154
|
+
accessToken: accessToken,
|
|
152
155
|
alignment: popupAlignment,
|
|
153
156
|
onSelect: handlePopupSelect,
|
|
154
|
-
onPopupVisibilityChange: onPopupVisibilityChange
|
|
157
|
+
onPopupVisibilityChange: onPopupVisibilityChange,
|
|
158
|
+
personId: personId
|
|
155
159
|
})), rightElement && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputRightWrapper, null, rightElement));
|
|
156
160
|
};
|
|
157
161
|
EmojiInput.displayName = 'EmojiInput';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_selection","_EmojiPickerPopup","_interopRequireDefault","_EmojiInput","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiInput","_ref","isDisabled","onInput","onKeyDown","onPopupVisibilityChange","placeholder","popupAlignment","rightElement","value","isMobile","useState","getIsMobile","editorRef","useRef","handleUpdateText","useCallback","text","current","newHtml","convertAsciiToUnicode","innerHTML","saveSelection","restoreSelection","handleInput","event","handlePopupSelect","emoji","selection","window","getSelection","anchorNode","contains","endOffset","startOffset","getRangeAt","rangeDistance","offset","length","nodeValue","substring","newTextNode","document","createTextNode","appendChild","newRange","createRange","Math","min","setStart","setEnd","removeAllRanges","addRange","Event","bubbles","dispatchEvent","handlePreventLoseFocus","_element$parentElemen","element","target","classList","parentElement","preventDefault","stopPropagation","useEffect","body","addEventListener","removeEventListener","createElement","StyledEmojiInput","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","ref","alignment","onSelect","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { PopupAlignment } from '../../constants/alignment';\nimport { convertAsciiToUnicode } from '../../utils/emoji';\nimport { getIsMobile } from '../../utils/environment';\nimport { restoreSelection, saveSelection } from '../../utils/selection';\nimport EmojiPickerPopup from '../emoji-picker-popup/EmojiPickerPopup';\nimport {\n StyledEmojiInput,\n StyledEmojiInputContent,\n StyledEmojiInputEditor,\n StyledEmojiInputRightWrapper,\n} from './EmojiInput.styles';\n\nexport type EmojiInputProps = {\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the text of the input changes\n */\n onInput?: ChangeEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when a key is pressed down.\n */\n onKeyDown?: KeyboardEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the visibility of the popup changes.\n * @param {boolean} isVisible - Whether the popup is visible or not\n */\n onPopupVisibilityChange?: (isVisible: boolean) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Sets the alignment of the popup to a fixed value. If this value is not set, the component\n * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this\n * value.\n */\n popupAlignment?: PopupAlignment;\n /**\n * Element that is rendered inside the EmojiInput on the right side.\n */\n rightElement?: ReactNode;\n /**\n * Value of the input field\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n isDisabled,\n onInput,\n onKeyDown,\n onPopupVisibilityChange,\n placeholder,\n popupAlignment,\n rightElement,\n value,\n}) => {\n const [isMobile] = useState(getIsMobile());\n\n const editorRef = useRef<HTMLDivElement>(null);\n\n /**\n * This function updates the content of the 'contentEditable' element if the new text is\n * different from the previous content. So this is only true if, for example, a text like \":-)\"\n * has been replaced to the corresponding emoji.\n *\n * When updating the HTML, the current cursor position is saved before replacing the content, so\n * that it can be set again afterward.\n */\n const handleUpdateText = useCallback((text: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const newHtml = convertAsciiToUnicode(text);\n\n if (newHtml !== editorRef.current.innerHTML) {\n saveSelection(editorRef.current);\n\n editorRef.current.innerHTML = newHtml;\n\n restoreSelection(editorRef.current);\n }\n }, []);\n\n /**\n * This function handles the 'input' events of the 'contentEditable' element and also passes the\n * respective event up accordingly if the 'onInput' property is a function.\n */\n const handleInput = useCallback(\n (event: ChangeEvent<HTMLDivElement>) => {\n if (!editorRef.current) {\n return;\n }\n\n handleUpdateText(editorRef.current.innerHTML);\n\n if (typeof onInput === 'function') {\n onInput(event);\n }\n },\n [handleUpdateText, onInput]\n );\n\n /**\n * This function processes the selection of an emoji via the popup. If the 'contentEditable'\n * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji\n * will be appended to the back of the input field content.\n *\n * In addition, this function also sets the cursor to the correct position when the input field\n * has the focus. For this purpose, the current position of the cursor or a selection is read to\n * calculate the cursor position after inserting the emoji.\n *\n * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,\n * which in turn executes the 'onInput' function from the props. So this serves to ensure that\n * the event is also passed through to the top when inserting via the popup.\n */\n const handlePopupSelect = useCallback((emoji: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const selection = window.getSelection();\n\n if (selection?.anchorNode && editorRef.current.contains(selection.anchorNode)) {\n const { endOffset, startOffset } = selection.getRangeAt(0);\n\n const rangeDistance = endOffset - startOffset;\n\n let offset = endOffset + emoji.length - rangeDistance;\n\n let { anchorNode } = selection;\n\n if (anchorNode.nodeValue) {\n anchorNode.nodeValue =\n anchorNode.nodeValue.substring(0, startOffset) +\n emoji +\n anchorNode.nodeValue.substring(endOffset);\n } else if (anchorNode === editorRef.current) {\n const newTextNode = document.createTextNode(emoji);\n\n editorRef.current.appendChild(newTextNode);\n\n anchorNode = newTextNode;\n }\n\n const newRange = document.createRange();\n\n if (anchorNode.nodeValue) {\n offset = Math.min(offset, anchorNode.nodeValue.length);\n }\n\n newRange.setStart(anchorNode, offset);\n newRange.setEnd(anchorNode, offset);\n\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n editorRef.current.innerHTML += emoji;\n }\n\n const event = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(event);\n }, []);\n\n /**\n * This function ensures that the input field does not lose focus when the popup is opened or an\n * emoji is selected in it. For this purpose the corresponding elements get the class\n * 'prevent-lose-focus'.\n *\n * The class can also be set to any other elements that should also not cause the input field to\n * lose focus.\n */\n const handlePreventLoseFocus = useCallback((event: MouseEvent) => {\n const element = event.target as Element;\n\n if (\n element.classList.contains('prevent-lose-focus') ||\n element.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n }, []);\n\n useEffect(() => {\n handleUpdateText(value);\n }, [handleUpdateText, value]);\n\n useEffect(() => {\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, [handlePreventLoseFocus]);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled}>\n <StyledEmojiInputContent isRightElementGiven={!!rightElement}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n onInput={handleInput}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={editorRef}\n />\n {!isMobile && (\n <EmojiPickerPopup\n alignment={popupAlignment}\n onSelect={handlePopupSelect}\n onPopupVisibilityChange={onPopupVisibilityChange}\n />\n )}\n </StyledEmojiInputContent>\n {rightElement && (\n <StyledEmojiInputRightWrapper>{rightElement}</StyledEmojiInputRightWrapper>\n )}\n </StyledEmojiInput>\n );\n};\n\nEmojiInput.displayName = 'EmojiInput';\n\nexport default EmojiInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAYA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAK6B,SAAAK,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAZ,wBAAAQ,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAA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qE,QAAQ,EAAElD,iBAAkB;IAC5BrB,uBAAuB,EAAEA;EAAwB,EAExD,CACqB,EACzBG,YAAY,iBACTvC,MAAA,CAAAW,OAAA,CAAAwF,aAAA,CAAC3F,WAAA,CAAAoG,4BAA4B,QAAErE,YAAY,CAC9C,CACc;AAE3B,CAAC;AAEDR,UAAU,CAAC8E,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvB/E,UAAU;AAAAgF,OAAA,CAAApG,OAAA,GAAAmG,QAAA"}
|
|
1
|
+
{"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_selection","_EmojiPickerPopup","_interopRequireDefault","_EmojiInput","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiInput","_ref","accessToken","isDisabled","onInput","onKeyDown","onPopupVisibilityChange","personId","placeholder","popupAlignment","rightElement","value","isMobile","useState","getIsMobile","editorRef","useRef","handleUpdateText","useCallback","text","current","newInnerText","convertAsciiToUnicode","innerText","saveSelection","restoreSelection","handleInput","event","handlePopupSelect","emoji","selection","window","getSelection","anchorNode","contains","endOffset","startOffset","getRangeAt","rangeDistance","offset","length","nodeValue","substring","newTextNode","document","createTextNode","appendChild","newRange","createRange","Math","min","setStart","setEnd","removeAllRanges","addRange","Event","bubbles","dispatchEvent","handlePreventLoseFocus","_element$parentElemen","element","target","classList","parentElement","preventDefault","stopPropagation","useEffect","body","addEventListener","removeEventListener","createElement","StyledEmojiInput","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","ref","alignment","onSelect","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { PopupAlignment } from '../../constants/alignment';\nimport { convertAsciiToUnicode } from '../../utils/emoji';\nimport { getIsMobile } from '../../utils/environment';\nimport { restoreSelection, saveSelection } from '../../utils/selection';\nimport EmojiPickerPopup from '../emoji-picker-popup/EmojiPickerPopup';\nimport {\n StyledEmojiInput,\n StyledEmojiInputContent,\n StyledEmojiInputEditor,\n StyledEmojiInputRightWrapper,\n} from './EmojiInput.styles';\n\nexport type EmojiInputProps = {\n /**\n * Access token of the logged-in user. Is needed to load and save the history of the emojis.\n */\n accessToken?: string;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the text of the input changes\n */\n onInput?: ChangeEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when a key is pressed down.\n */\n onKeyDown?: KeyboardEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the visibility of the popup changes.\n * @param {boolean} isVisible - Whether the popup is visible or not\n */\n onPopupVisibilityChange?: (isVisible: boolean) => void;\n /**\n * Person id of the logged-in user. Is needed to load and save the history of the emojis.\n */\n personId?: string;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Sets the alignment of the popup to a fixed value. If this value is not set, the component\n * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this\n * value.\n */\n popupAlignment?: PopupAlignment;\n /**\n * Element that is rendered inside the EmojiInput on the right side.\n */\n rightElement?: ReactNode;\n /**\n * Value of the input field\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n accessToken,\n isDisabled,\n onInput,\n onKeyDown,\n onPopupVisibilityChange,\n personId,\n placeholder,\n popupAlignment,\n rightElement,\n value,\n}) => {\n const [isMobile] = useState(getIsMobile());\n\n const editorRef = useRef<HTMLDivElement>(null);\n\n /**\n * This function updates the content of the 'contentEditable' element if the new text is\n * different from the previous content. So this is only true if, for example, a text like \":-)\"\n * has been replaced to the corresponding emoji.\n *\n * When updating the HTML, the current cursor position is saved before replacing the content, so\n * that it can be set again afterward.\n */\n const handleUpdateText = useCallback((text: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const newInnerText = convertAsciiToUnicode(text);\n\n if (newInnerText !== editorRef.current.innerText) {\n saveSelection(editorRef.current);\n\n editorRef.current.innerText = newInnerText;\n\n restoreSelection(editorRef.current);\n }\n }, []);\n\n /**\n * This function handles the 'input' events of the 'contentEditable' element and also passes the\n * respective event up accordingly if the 'onInput' property is a function.\n */\n const handleInput = useCallback(\n (event: ChangeEvent<HTMLDivElement>) => {\n if (!editorRef.current) {\n return;\n }\n\n handleUpdateText(editorRef.current.innerText);\n\n if (typeof onInput === 'function') {\n onInput(event);\n }\n },\n [handleUpdateText, onInput]\n );\n\n /**\n * This function processes the selection of an emoji via the popup. If the 'contentEditable'\n * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji\n * will be appended to the back of the input field content.\n *\n * In addition, this function also sets the cursor to the correct position when the input field\n * has the focus. For this purpose, the current position of the cursor or a selection is read to\n * calculate the cursor position after inserting the emoji.\n *\n * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,\n * which in turn executes the 'onInput' function from the props. So this serves to ensure that\n * the event is also passed through to the top when inserting via the popup.\n */\n const handlePopupSelect = useCallback((emoji: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const selection = window.getSelection();\n\n if (selection?.anchorNode && editorRef.current.contains(selection.anchorNode)) {\n const { endOffset, startOffset } = selection.getRangeAt(0);\n\n const rangeDistance = endOffset - startOffset;\n\n let offset = endOffset + emoji.length - rangeDistance;\n\n let { anchorNode } = selection;\n\n if (anchorNode.nodeValue) {\n anchorNode.nodeValue =\n anchorNode.nodeValue.substring(0, startOffset) +\n emoji +\n anchorNode.nodeValue.substring(endOffset);\n } else if (anchorNode === editorRef.current) {\n const newTextNode = document.createTextNode(emoji);\n\n editorRef.current.appendChild(newTextNode);\n\n anchorNode = newTextNode;\n }\n\n const newRange = document.createRange();\n\n if (anchorNode.nodeValue) {\n offset = Math.min(offset, anchorNode.nodeValue.length);\n }\n\n newRange.setStart(anchorNode, offset);\n newRange.setEnd(anchorNode, offset);\n\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n editorRef.current.innerText += emoji;\n }\n\n const event = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(event);\n }, []);\n\n /**\n * This function ensures that the input field does not lose focus when the popup is opened or an\n * emoji is selected in it. For this purpose the corresponding elements get the class\n * 'prevent-lose-focus'.\n *\n * The class can also be set to any other elements that should also not cause the input field to\n * lose focus.\n */\n const handlePreventLoseFocus = useCallback((event: MouseEvent) => {\n const element = event.target as Element;\n\n if (\n element.classList.contains('prevent-lose-focus') ||\n element.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n }, []);\n\n useEffect(() => {\n handleUpdateText(value);\n }, [handleUpdateText, value]);\n\n useEffect(() => {\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, [handlePreventLoseFocus]);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled}>\n <StyledEmojiInputContent isRightElementGiven={!!rightElement}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n onInput={handleInput}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={editorRef}\n />\n {!isMobile && (\n <EmojiPickerPopup\n accessToken={accessToken}\n alignment={popupAlignment}\n onSelect={handlePopupSelect}\n onPopupVisibilityChange={onPopupVisibilityChange}\n personId={personId}\n />\n )}\n </StyledEmojiInputContent>\n {rightElement && (\n <StyledEmojiInputRightWrapper>{rightElement}</StyledEmojiInputRightWrapper>\n )}\n </StyledEmojiInput>\n );\n};\n\nEmojiInput.displayName = 'EmojiInput';\n\nexport default EmojiInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAYA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,Y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M;MACTd,QAAQ,CAACuB,IAAI,CAACE,mBAAmB,CAAC,WAAW,EAAEX,sBAAsB,CAAC;IAC1E,CAAC;EACL,CAAC,EAAE,CAACA,sBAAsB,CAAC,CAAC;EAE5B,oBACIzF,MAAA,CAAAW,OAAA,CAAA0F,aAAA,CAAC7F,WAAA,CAAA8F,gBAAgB;IAACpE,UAAU,EAAEA;EAAW,gBACrClC,MAAA,CAAAW,OAAA,CAAA0F,aAAA,CAAC7F,WAAA,CAAA+F,uBAAuB;IAACC,mBAAmB,EAAE,CAAC,CAAC/D;EAAa,gBACzDzC,MAAA,CAAAW,OAAA,CAAA0F,aAAA,CAAC7F,WAAA,CAAAiG,sBAAsB;IACnBC,eAAe,EAAE,CAACxE,UAAW;IAC7BC,OAAO,EAAEsB,WAAY;IACrBrB,SAAS,EAAEA,SAAU;IACrBG,WAAW,EAAEA,WAAY;IACzBoE,GAAG,EAAE7D;EAAU,EACjB,EACD,CAACH,QAAQ,iBACN3C,MAAA,CAAAW,OAAA,CAAA0F,aAAA,CAAC/F,iBAAA,CAAAK,OAAgB;IACbsB,WAAW,EAAEA,WAAY;IACzB2E,SAAS,EAAEpE,cAAe;IAC1BqE,QAAQ,EAAElD,iBAAkB;IAC5BtB,uBAAuB,EAAEA,uBAAwB;IACjDC,QAAQ,EAAEA;EAAS,EAE1B,CACqB,EACzBG,YAAY,iBACTzC,MAAA,CAAAW,OAAA,CAAA0F,aAAA,CAAC7F,WAAA,CAAAsG,4BAA4B,QAAErE,YAAY,CAC9C,CACc;AAE3B,CAAC;AAEDV,UAAU,CAACgF,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvBjF,UAAU;AAAAkF,OAAA,CAAAtG,OAAA,GAAAqG,QAAA"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
export type EmojiPickerProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Access token of the logged-in user. Is needed to load and save the history of the emojis.
|
|
5
|
+
*/
|
|
6
|
+
accessToken?: string;
|
|
3
7
|
/**
|
|
4
8
|
* Function executed when an emoji is selected in the popup
|
|
5
9
|
* @param {string} emoji - Emoji that was selected
|
|
6
10
|
*/
|
|
7
11
|
onSelect: (emoji: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Person id of the logged-in user. Is needed to load and save the history of the emojis.
|
|
14
|
+
*/
|
|
15
|
+
personId?: string;
|
|
8
16
|
};
|
|
9
17
|
declare const EmojiPicker: FC<EmojiPickerProps>;
|
|
10
18
|
export default EmojiPicker;
|
|
@@ -16,7 +16,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
16
|
const EmojiPicker = _ref => {
|
|
17
17
|
var _emojiCategories$;
|
|
18
18
|
let {
|
|
19
|
-
|
|
19
|
+
accessToken,
|
|
20
|
+
onSelect,
|
|
21
|
+
personId
|
|
20
22
|
} = _ref;
|
|
21
23
|
const [searchString, setSearchString] = (0, _react.useState)('');
|
|
22
24
|
const [selectedCategory, setSelectedCategory] = (0, _react.useState)((_emojiCategories$ = _dataByGroup.default[0]) === null || _emojiCategories$ === void 0 ? void 0 : _emojiCategories$.slug);
|
|
@@ -32,7 +34,9 @@ const EmojiPicker = _ref => {
|
|
|
32
34
|
placeholder: "Suchen",
|
|
33
35
|
value: searchString
|
|
34
36
|
}), /*#__PURE__*/_react.default.createElement(_EmojiPickerEmojis.default, {
|
|
37
|
+
accessToken: accessToken,
|
|
35
38
|
onSelect: onSelect,
|
|
39
|
+
personId: personId,
|
|
36
40
|
searchString: searchString,
|
|
37
41
|
selectedCategory: selectedCategory
|
|
38
42
|
}), /*#__PURE__*/_react.default.createElement(_EmojiPickerCategories.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiPicker.js","names":["_core","require","_react","_interopRequireWildcard","_dataByGroup","_interopRequireDefault","_EmojiPickerCategories","_EmojiPickerEmojis","_EmojiPicker","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPicker","_ref","_emojiCategories$","onSelect","searchString","setSearchString","useState","selectedCategory","setSelectedCategory","emojiCategories","slug","handleCategorySelect","useCallback","category","handleSearchChange","event","target","value","createElement","StyledEmojiPicker","Input","onChange","placeholder","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker/EmojiPicker.tsx"],"sourcesContent":["import { Input } from '@chayns-components/core';\nimport React, { ChangeEvent, FC, useCallback, useState } from 'react';\nimport emojiCategories from 'unicode-emoji-json/data-by-group.json';\nimport type { Category } from '../../types/category';\nimport EmojiPickerCategories from './emoji-picker-categories/EmojiPickerCategories';\nimport EmojiPickerEmojis from './emoji-picker-emojis/EmojiPickerEmojis';\nimport { StyledEmojiPicker } from './EmojiPicker.styles';\n\nexport type EmojiPickerProps = {\n /**\n * Function executed when an emoji is selected in the popup\n * @param {string} emoji - Emoji that was selected\n */\n onSelect: (emoji: string) => void;\n};\nconst EmojiPicker: FC<EmojiPickerProps> = ({ onSelect }) => {\n const [searchString, setSearchString] = useState('');\n const [selectedCategory, setSelectedCategory] = useState(emojiCategories[0]?.slug as Category);\n\n const handleCategorySelect = useCallback((category: Category) => {\n setSearchString('');\n setSelectedCategory(category);\n }, []);\n\n const handleSearchChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {\n setSearchString(event.target.value);\n }, []);\n\n return (\n <StyledEmojiPicker>\n <Input onChange={handleSearchChange} placeholder=\"Suchen\" value={searchString} />\n <EmojiPickerEmojis\n onSelect={onSelect}\n searchString={searchString}\n selectedCategory={selectedCategory}\n />\n <EmojiPickerCategories\n onSelect={handleCategorySelect}\n searchString={searchString}\n selectedCategory={selectedCategory}\n />\n </StyledEmojiPicker>\n );\n};\n\nEmojiPicker.displayName = 'EmojiPicker';\n\nexport default EmojiPicker;\n"],"mappings":";;;;;;AAAA,IAA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AAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAhB,GAAA,CAAAgB,GAAA,SAAAL,MAAA,CAAAT,OAAA,GAAAF,GAAA,MAAAQ,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAArB,GAAA,EAAAW,MAAA,YAAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"EmojiPicker.js","names":["_core","require","_react","_interopRequireWildcard","_dataByGroup","_interopRequireDefault","_EmojiPickerCategories","_EmojiPickerEmojis","_EmojiPicker","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPicker","_ref","_emojiCategories$","accessToken","onSelect","personId","searchString","setSearchString","useState","selectedCategory","setSelectedCategory","emojiCategories","slug","handleCategorySelect","useCallback","category","handleSearchChange","event","target","value","createElement","StyledEmojiPicker","Input","onChange","placeholder","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker/EmojiPicker.tsx"],"sourcesContent":["import { Input } from '@chayns-components/core';\nimport React, { ChangeEvent, FC, useCallback, useState } from 'react';\nimport emojiCategories from 'unicode-emoji-json/data-by-group.json';\nimport type { Category } from '../../types/category';\nimport EmojiPickerCategories from './emoji-picker-categories/EmojiPickerCategories';\nimport EmojiPickerEmojis from './emoji-picker-emojis/EmojiPickerEmojis';\nimport { StyledEmojiPicker } from './EmojiPicker.styles';\n\nexport type EmojiPickerProps = {\n /**\n * Access token of the logged-in user. Is needed to load and save the history of the emojis.\n */\n accessToken?: string;\n /**\n * Function executed when an emoji is selected in the popup\n * @param {string} emoji - Emoji that was selected\n */\n onSelect: (emoji: string) => void;\n /**\n * Person id of the logged-in user. Is needed to load and save the history of the emojis.\n */\n personId?: string;\n};\nconst EmojiPicker: FC<EmojiPickerProps> = ({ accessToken, onSelect, personId }) => {\n const [searchString, setSearchString] = useState('');\n const [selectedCategory, setSelectedCategory] = useState(emojiCategories[0]?.slug as Category);\n\n const handleCategorySelect = useCallback((category: Category) => {\n setSearchString('');\n setSelectedCategory(category);\n }, []);\n\n const handleSearchChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {\n setSearchString(event.target.value);\n }, []);\n\n return (\n <StyledEmojiPicker>\n <Input onChange={handleSearchChange} placeholder=\"Suchen\" value={searchString} />\n <EmojiPickerEmojis\n accessToken={accessToken}\n onSelect={onSelect}\n personId={personId}\n searchString={searchString}\n selectedCategory={selectedCategory}\n />\n <EmojiPickerCategories\n onSelect={handleCategorySelect}\n searchString={searchString}\n selectedCategory={selectedCategory}\n />\n </StyledEmojiPicker>\n );\n};\n\nEmojiPicker.displayName = 'EmojiPicker';\n\nexport default EmojiPicker;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,sBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,kBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAAyD,SAAAI,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAM,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA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IACnBG,mBAAmB,CAACK,QAAQ,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,kBAAkB,GAAG,IAAAF,kBAAW,EAAEG,KAAoC,IAAK;IAC7EV,eAAe,CAACU,KAAK,CAACC,MAAM,CAACC,KAAK,CAAC;EACvC,CAAC,EAAE,EAAE,CAAC;EAEN,oBACIhD,MAAA,CAAAS,OAAA,CAAAwC,aAAA,CAAC3C,YAAA,CAAA4C,iBAAiB,qBACdlD,MAAA,CAAAS,OAAA,CAAAwC,aAAA,CAACnD,KAAA,CAAAqD,KAAK;IAACC,QAAQ,EAAEP,kBAAmB;IAACQ,WAAW,EAAC,QAAQ;IAACL,KAAK,EAAEb;EAAa,EAAG,eACjFnC,MAAA,CAAAS,OAAA,CAAAwC,aAAA,CAAC5C,kBAAA,CAAAI,OAAiB;IACduB,WAAW,EAAEA,WAAY;IACzBC,QAAQ,EAAEA,QAAS;IACnBC,QAAQ,EAAEA,QAAS;IACnBC,YAAY,EAAEA,YAAa;IAC3BG,gBAAgB,EAAEA;EAAiB,EACrC,eACFtC,MAAA,CAAAS,OAAA,CAAAwC,aAAA,CAAC7C,sBAAA,CAAAK,OAAqB;IAClBwB,QAAQ,EAAES,oBAAqB;IAC/BP,YAAY,EAAEA,YAAa;IAC3BG,gBAAgB,EAAEA;EAAiB,EACrC,CACc;AAE5B,CAAC;AAEDT,WAAW,CAACyB,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAEzB1B,WAAW;AAAA2B,OAAA,CAAA/C,OAAA,GAAA8C,QAAA"}
|
|
@@ -18,25 +18,31 @@ const EmojiPickerCategories = _ref => {
|
|
|
18
18
|
selectedCategory
|
|
19
19
|
} = _ref;
|
|
20
20
|
const isSearchStringGiven = searchString.trim() !== '';
|
|
21
|
-
const categories = (0, _react.useMemo)(() =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
const categories = (0, _react.useMemo)(() => {
|
|
22
|
+
const categorySlugs = _dataByGroup.default.map(_ref2 => {
|
|
23
|
+
let {
|
|
24
|
+
slug
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return slug;
|
|
27
|
+
});
|
|
28
|
+
categorySlugs.unshift('history');
|
|
29
|
+
return categorySlugs.map(slug => {
|
|
30
|
+
const isSelected = selectedCategory === slug && !isSearchStringGiven;
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_EmojiPickerCategories.StyledMotionEmojiPickerCategory, {
|
|
32
|
+
animate: {
|
|
33
|
+
filter: `grayscale(${isSelected ? 0 : 0.75})`,
|
|
34
|
+
opacity: isSelected ? 1 : 0.5
|
|
35
|
+
},
|
|
36
|
+
className: "prevent-lose-focus",
|
|
37
|
+
initial: false,
|
|
38
|
+
key: slug,
|
|
39
|
+
onClick: () => onSelect(slug),
|
|
40
|
+
transition: {
|
|
41
|
+
duration: 0.2
|
|
42
|
+
}
|
|
43
|
+
}, _categories.CATEGORY_EMOJIS[slug]);
|
|
44
|
+
});
|
|
45
|
+
}, [isSearchStringGiven, onSelect, selectedCategory]);
|
|
40
46
|
return /*#__PURE__*/_react.default.createElement(_EmojiPickerCategories.StyledEmojiPickerCategories, null, categories);
|
|
41
47
|
};
|
|
42
48
|
EmojiPickerCategories.displayName = 'EmojiPickerCategories';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiPickerCategories.js","names":["_react","_interopRequireWildcard","require","_dataByGroup","_interopRequireDefault","_categories","_EmojiPickerCategories","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerCategories","_ref","onSelect","searchString","selectedCategory","isSearchStringGiven","trim","categories","useMemo","unicodeEmoji","map","_ref2","slug","isSelected","createElement","StyledMotionEmojiPickerCategory","animate","filter","opacity","className","initial","onClick","transition","duration","CATEGORY_EMOJIS","StyledEmojiPickerCategories","displayName","_default","exports"],"sources":["../../../../src/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport unicodeEmoji from 'unicode-emoji-json/data-by-group.json';\nimport { CATEGORY_EMOJIS } from '../../../constants/categories';\nimport type { Category } from '../../../types/category';\nimport {\n StyledEmojiPickerCategories,\n StyledMotionEmojiPickerCategory,\n} from './EmojiPickerCategories.styles';\n\nexport type EmojiPickerCategoriesProps = {\n onSelect: (category: Category) => void;\n searchString: string;\n selectedCategory: Category;\n};\n\nconst EmojiPickerCategories: FC<EmojiPickerCategoriesProps> = ({\n onSelect,\n searchString,\n selectedCategory,\n}) => {\n const isSearchStringGiven = searchString.trim() !== '';\n\n const categories = useMemo(\n
|
|
1
|
+
{"version":3,"file":"EmojiPickerCategories.js","names":["_react","_interopRequireWildcard","require","_dataByGroup","_interopRequireDefault","_categories","_EmojiPickerCategories","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerCategories","_ref","onSelect","searchString","selectedCategory","isSearchStringGiven","trim","categories","useMemo","categorySlugs","unicodeEmoji","map","_ref2","slug","unshift","isSelected","createElement","StyledMotionEmojiPickerCategory","animate","filter","opacity","className","initial","onClick","transition","duration","CATEGORY_EMOJIS","StyledEmojiPickerCategories","displayName","_default","exports"],"sources":["../../../../src/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport unicodeEmoji from 'unicode-emoji-json/data-by-group.json';\nimport { CATEGORY_EMOJIS } from '../../../constants/categories';\nimport type { Category } from '../../../types/category';\nimport {\n StyledEmojiPickerCategories,\n StyledMotionEmojiPickerCategory,\n} from './EmojiPickerCategories.styles';\n\nexport type EmojiPickerCategoriesProps = {\n onSelect: (category: Category) => void;\n searchString: string;\n selectedCategory: Category;\n};\n\nconst EmojiPickerCategories: FC<EmojiPickerCategoriesProps> = ({\n onSelect,\n searchString,\n selectedCategory,\n}) => {\n const isSearchStringGiven = searchString.trim() !== '';\n\n const categories = useMemo(() => {\n const categorySlugs = unicodeEmoji.map(({ slug }) => slug);\n\n categorySlugs.unshift('history');\n\n return categorySlugs.map((slug) => {\n const isSelected = selectedCategory === slug && !isSearchStringGiven;\n\n return (\n <StyledMotionEmojiPickerCategory\n animate={{\n filter: `grayscale(${isSelected ? 0 : 0.75})`,\n opacity: isSelected ? 1 : 0.5,\n }}\n className=\"prevent-lose-focus\"\n initial={false}\n key={slug}\n onClick={() => onSelect(slug as Category)}\n transition={{ duration: 0.2 }}\n >\n {CATEGORY_EMOJIS[slug as Category]}\n </StyledMotionEmojiPickerCategory>\n );\n });\n }, [isSearchStringGiven, onSelect, selectedCategory]);\n\n return <StyledEmojiPickerCategories>{categories}</StyledEmojiPickerCategories>;\n};\n\nEmojiPickerCategories.displayName = 'EmojiPickerCategories';\n\nexport default EmojiPickerCategories;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAGwC,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA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M;IAC7B,MAAMC,aAAa,GAAGC,oBAAY,CAACC,GAAG,CAACC,KAAA;MAAA,IAAC;QAAEC;MAAK,CAAC,GAAAD,KAAA;MAAA,OAAKC,IAAI;IAAA,EAAC;IAE1DJ,aAAa,CAACK,OAAO,CAAC,SAAS,CAAC;IAEhC,OAAOL,aAAa,CAACE,GAAG,CAAEE,IAAI,IAAK;MAC/B,MAAME,UAAU,GAAGX,gBAAgB,KAAKS,IAAI,IAAI,CAACR,mBAAmB;MAEpE,oBACIlC,MAAA,CAAAS,OAAA,CAAAoC,aAAA,CAACvC,sBAAA,CAAAwC,+BAA+B;QAC5BC,OAAO,EAAE;UACLC,MAAM,EAAG,aAAYJ,UAAU,GAAG,CAAC,GAAG,IAAK,GAAE;UAC7CK,OAAO,EAAEL,UAAU,GAAG,CAAC,GAAG;QAC9B,CAAE;QACFM,SAAS,EAAC,oBAAoB;QAC9BC,OAAO,EAAE,KAAM;QACf5B,GAAG,EAAEmB,IAAK;QACVU,OAAO,EAAEA,CAAA,KAAMrB,QAAQ,CAACW,IAAI,CAAc;QAC1CW,UAAU,EAAE;UAAEC,QAAQ,EAAE;QAAI;MAAE,GAE7BC,2BAAe,CAACb,IAAI,CAAa,CACJ;IAE1C,CAAC,CAAC;EACN,CAAC,EAAE,CAACR,mBAAmB,EAAEH,QAAQ,EAAEE,gBAAgB,CAAC,CAAC;EAErD,oBAAOjC,MAAA,CAAAS,OAAA,CAAAoC,aAAA,CAACvC,sBAAA,CAAAkD,2BAA2B,QAAEpB,UAAU,CAA+B;AAClF,CAAC;AAEDP,qBAAqB,CAAC4B,WAAW,GAAG,uBAAuB;AAAC,IAAAC,QAAA,GAE7C7B,qBAAqB;AAAA8B,OAAA,CAAAlD,OAAA,GAAAiD,QAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import type { Category } from '../../../types/category';
|
|
3
3
|
export type EmojiPickerEmojisProps = {
|
|
4
|
+
accessToken?: string;
|
|
4
5
|
onSelect: (emoji: string) => void;
|
|
6
|
+
personId?: string;
|
|
5
7
|
searchString: string;
|
|
6
8
|
selectedCategory: Category;
|
|
7
9
|
};
|
|
@@ -9,55 +9,112 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _dataByEmoji = _interopRequireDefault(require("unicode-emoji-json/data-by-emoji.json"));
|
|
10
10
|
var _dataByGroup = _interopRequireDefault(require("unicode-emoji-json/data-by-group.json"));
|
|
11
11
|
var _emojiDeDE = _interopRequireDefault(require("../../../constants/emoji-de-DE.json"));
|
|
12
|
+
var _emojiHistory = require("../../../hooks/emojiHistory");
|
|
13
|
+
var _Emoji = _interopRequireDefault(require("./emoji/Emoji"));
|
|
12
14
|
var _EmojiPickerEmojis = require("./EmojiPickerEmojis.styles");
|
|
13
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
18
|
const EmojiPickerEmojis = _ref => {
|
|
17
19
|
let {
|
|
20
|
+
accessToken,
|
|
18
21
|
onSelect,
|
|
22
|
+
personId,
|
|
19
23
|
searchString,
|
|
20
24
|
selectedCategory
|
|
21
25
|
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
addOrUpdateEmojiInHistory,
|
|
28
|
+
historyEmojis
|
|
29
|
+
} = (0, _emojiHistory.useEmojiHistory)({
|
|
30
|
+
accessToken,
|
|
31
|
+
personId,
|
|
32
|
+
selectedCategory
|
|
33
|
+
});
|
|
34
|
+
const handleSelect = (0, _react.useCallback)(_ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
emoji,
|
|
37
|
+
name,
|
|
38
|
+
skin_tone_support
|
|
39
|
+
} = _ref2;
|
|
40
|
+
onSelect(emoji);
|
|
41
|
+
void addOrUpdateEmojiInHistory({
|
|
42
|
+
emoji,
|
|
43
|
+
name,
|
|
44
|
+
skin_tone_support
|
|
45
|
+
});
|
|
46
|
+
}, [addOrUpdateEmojiInHistory, onSelect]);
|
|
22
47
|
const emojis = (0, _react.useMemo)(() => {
|
|
23
48
|
var _emojiCategories$find;
|
|
24
49
|
if (searchString.trim() !== '') {
|
|
25
50
|
const lowerSearchString = searchString.toLowerCase();
|
|
26
51
|
const searchResults = [];
|
|
27
|
-
Object.entries(_dataByEmoji.default).forEach(
|
|
52
|
+
Object.entries(_dataByEmoji.default).forEach(_ref3 => {
|
|
28
53
|
let [emoji, {
|
|
29
|
-
name
|
|
30
|
-
|
|
54
|
+
name,
|
|
55
|
+
skin_tone_support
|
|
56
|
+
}] = _ref3;
|
|
31
57
|
// @ts-expect-error: Type is correct here
|
|
32
58
|
const keywords = _emojilib.default[emoji];
|
|
33
59
|
// @ts-expect-error: Type is correct here
|
|
34
60
|
const germanKeywords = _emojiDeDE.default[emoji];
|
|
35
61
|
if (name.includes(lowerSearchString) || keywords !== null && keywords !== void 0 && keywords.some(keyword => keyword.includes(lowerSearchString)) || germanKeywords !== null && germanKeywords !== void 0 && germanKeywords.some(keyword => keyword.includes(lowerSearchString))) {
|
|
36
|
-
searchResults.push( /*#__PURE__*/_react.default.createElement(
|
|
37
|
-
|
|
62
|
+
searchResults.push( /*#__PURE__*/_react.default.createElement(_Emoji.default, {
|
|
63
|
+
emoji: emoji,
|
|
64
|
+
isSkinToneSupported: skin_tone_support,
|
|
38
65
|
key: name,
|
|
39
|
-
|
|
40
|
-
|
|
66
|
+
onSelect: e => handleSelect({
|
|
67
|
+
emoji: e,
|
|
68
|
+
name,
|
|
69
|
+
skin_tone_support
|
|
70
|
+
})
|
|
71
|
+
}));
|
|
41
72
|
}
|
|
42
73
|
});
|
|
43
74
|
return searchResults;
|
|
44
75
|
}
|
|
45
|
-
|
|
76
|
+
if (selectedCategory === 'history') {
|
|
77
|
+
return historyEmojis.map(_ref4 => {
|
|
78
|
+
let {
|
|
79
|
+
emoji,
|
|
80
|
+
name,
|
|
81
|
+
skin_tone_support
|
|
82
|
+
} = _ref4;
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement(_Emoji.default, {
|
|
84
|
+
emoji: emoji,
|
|
85
|
+
key: name,
|
|
86
|
+
onSelect: e => handleSelect({
|
|
87
|
+
emoji: e,
|
|
88
|
+
name,
|
|
89
|
+
skin_tone_support
|
|
90
|
+
}),
|
|
91
|
+
isSkinToneSupported: false
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return (_emojiCategories$find = _dataByGroup.default.find(_ref5 => {
|
|
46
96
|
let {
|
|
47
97
|
slug
|
|
48
|
-
} =
|
|
98
|
+
} = _ref5;
|
|
49
99
|
return slug === selectedCategory;
|
|
50
|
-
})) === null || _emojiCategories$find === void 0 ? void 0 : _emojiCategories$find.emojis.map(
|
|
100
|
+
})) === null || _emojiCategories$find === void 0 ? void 0 : _emojiCategories$find.emojis.map(_ref6 => {
|
|
51
101
|
let {
|
|
52
102
|
emoji,
|
|
53
|
-
name
|
|
54
|
-
|
|
55
|
-
|
|
103
|
+
name,
|
|
104
|
+
skin_tone_support
|
|
105
|
+
} = _ref6;
|
|
106
|
+
return /*#__PURE__*/_react.default.createElement(_Emoji.default, {
|
|
107
|
+
emoji: emoji,
|
|
108
|
+
isSkinToneSupported: skin_tone_support,
|
|
56
109
|
key: name,
|
|
57
|
-
|
|
58
|
-
|
|
110
|
+
onSelect: e => handleSelect({
|
|
111
|
+
emoji: e,
|
|
112
|
+
name,
|
|
113
|
+
skin_tone_support
|
|
114
|
+
})
|
|
115
|
+
});
|
|
59
116
|
});
|
|
60
|
-
}, [
|
|
117
|
+
}, [handleSelect, historyEmojis, searchString, selectedCategory]);
|
|
61
118
|
return /*#__PURE__*/_react.default.createElement(_EmojiPickerEmojis.StyledEmojiPickerEmojis, null, emojis);
|
|
62
119
|
};
|
|
63
120
|
EmojiPickerEmojis.displayName = 'EmojiPickerEmojis';
|