@chayns-components/emoji-input 5.0.0-beta.89 → 5.0.0-beta.91

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.
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _emoji = require("../../utils/emoji");
9
9
  var _environment = require("../../utils/environment");
10
10
  var _font = require("../../utils/font");
11
+ var _insert = require("../../utils/insert");
11
12
  var _selection = require("../../utils/selection");
12
13
  var _EmojiPickerPopup = _interopRequireDefault(require("../emoji-picker-popup/EmojiPickerPopup"));
13
14
  var _EmojiInput = require("./EmojiInput.styles");
@@ -66,55 +67,41 @@ const EmojiInput = _ref => {
66
67
  }, [handleUpdateText, onInput]);
67
68
 
68
69
  /**
69
- * This function processes the selection of an emoji via the popup. If the 'contentEditable'
70
- * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
71
- * will be appended to the back of the input field content.
72
- *
73
- * In addition, this function also sets the cursor to the correct position when the input field
74
- * has the focus. For this purpose, the current position of the cursor or a selection is read to
75
- * calculate the cursor position after inserting the emoji.
70
+ * This function prevents formatting from being adopted when texts are inserted. To do this, the
71
+ * plain text is read from the event after the default behavior has been prevented. The plain
72
+ * text is then inserted at the correct position in the input field using the
73
+ * 'insertTextAtCursorPosition' function.
74
+ */
75
+ const handlePaste = (0, _react.useCallback)(event => {
76
+ if (editorRef.current) {
77
+ event.preventDefault();
78
+ const text = event.clipboardData.getData('text/plain');
79
+ (0, _insert.insertTextAtCursorPosition)({
80
+ editorElement: editorRef.current,
81
+ text
82
+ });
83
+ }
84
+ }, []);
85
+
86
+ /**
87
+ * This function uses the 'insertTextAtCursorPosition' function to insert the emoji at the
88
+ * correct position in the editor element.
76
89
  *
77
90
  * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,
78
91
  * which in turn executes the 'onInput' function from the props. So this serves to ensure that
79
92
  * the event is also passed through to the top when inserting via the popup.
80
93
  */
81
94
  const handlePopupSelect = (0, _react.useCallback)(emoji => {
82
- if (!editorRef.current) {
83
- return;
84
- }
85
- const selection = window.getSelection();
86
- if (selection !== null && selection !== void 0 && selection.anchorNode && editorRef.current.contains(selection.anchorNode)) {
87
- const {
88
- endOffset,
89
- startOffset
90
- } = selection.getRangeAt(0);
91
- const rangeDistance = endOffset - startOffset;
92
- let offset = endOffset + emoji.length - rangeDistance;
93
- let {
94
- anchorNode
95
- } = selection;
96
- if (anchorNode.nodeValue) {
97
- anchorNode.nodeValue = anchorNode.nodeValue.substring(0, startOffset) + emoji + anchorNode.nodeValue.substring(endOffset);
98
- } else if (anchorNode === editorRef.current) {
99
- const newTextNode = document.createTextNode(emoji);
100
- editorRef.current.appendChild(newTextNode);
101
- anchorNode = newTextNode;
102
- }
103
- const newRange = document.createRange();
104
- if (anchorNode.nodeValue) {
105
- offset = Math.min(offset, anchorNode.nodeValue.length);
106
- }
107
- newRange.setStart(anchorNode, offset);
108
- newRange.setEnd(anchorNode, offset);
109
- selection.removeAllRanges();
110
- selection.addRange(newRange);
111
- } else {
112
- editorRef.current.innerText += emoji;
95
+ if (editorRef.current) {
96
+ (0, _insert.insertTextAtCursorPosition)({
97
+ editorElement: editorRef.current,
98
+ text: emoji
99
+ });
100
+ const event = new Event('input', {
101
+ bubbles: true
102
+ });
103
+ editorRef.current.dispatchEvent(event);
113
104
  }
114
- const event = new Event('input', {
115
- bubbles: true
116
- });
117
- editorRef.current.dispatchEvent(event);
118
105
  }, []);
119
106
 
120
107
  /**
@@ -151,6 +138,7 @@ const EmojiInput = _ref => {
151
138
  isMobile: isMobile,
152
139
  onInput: handleInput,
153
140
  onKeyDown: onKeyDown,
141
+ onPaste: handlePaste,
154
142
  placeholder: placeholder,
155
143
  ref: editorRef,
156
144
  rootFontFamily: rootFontFamily
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_font","_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","rootFontFamily","getRootFontFamily","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 { getRootFontFamily } from '../../utils/font';\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 const [rootFontFamily] = useState(getRootFontFamily());\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 isMobile={isMobile}\n onInput={handleInput}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={editorRef}\n rootFontFamily={rootFontFamily}\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,YAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAK6B,SAAAM,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD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AACtE,UAAU,EAAEA;EAAW,gBACrCnC,MAAA,CAAAY,OAAA,CAAA4F,aAAA,CAAC/F,WAAA,CAAAiG,uBAAuB;IAACC,mBAAmB,EAAE,CAAC,CAACjE;EAAa,gBACzD1C,MAAA,CAAAY,OAAA,CAAA4F,aAAA,CAAC/F,WAAA,CAAAmG,sBAAsB;IACnBC,eAAe,EAAE,CAAC1E,UAAW;IAC7BS,QAAQ,EAAEA,QAAS;IACnBR,OAAO,EAAEwB,WAAY;IACrBvB,SAAS,EAAEA,SAAU;IACrBG,WAAW,EAAEA,WAAY;IACzBsE,GAAG,EAAE7D,SAAU;IACfF,cAAc,EAAEA;EAAe,EACjC,EACD,CAACH,QAAQ,iBACN5C,MAAA,CAAAY,OAAA,CAAA4F,aAAA,CAACjG,iBAAA,CAAAK,OAAgB;IACbsB,WAAW,EAAEA,WAAY;IACzB6E,SAAS,EAAEtE,cAAe;IAC1BuE,QAAQ,EAAElD,iBAAkB;IAC5BxB,uBAAuB,EAAEA,uBAAwB;IACjDC,QAAQ,EAAEA;EAAS,EAE1B,CACqB,EACzBG,YAAY,iBACT1C,MAAA,CAAAY,OAAA,CAAA4F,aAAA,CAAC/F,WAAA,CAAAwG,4BAA4B,QAAEvE,YAAY,CAC9C,CACc;AAE3B,CAAC;AAEDV,UAAU,CAACkF,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvBnF,UAAU;AAAAoF,OAAA,CAAAxG,OAAA,GAAAuG,QAAA"}
1
+ {"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_font","_insert","_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","rootFontFamily","getRootFontFamily","editorRef","useRef","handleUpdateText","useCallback","text","current","newInnerText","convertAsciiToUnicode","innerText","saveSelection","restoreSelection","handleInput","event","handlePaste","preventDefault","clipboardData","getData","insertTextAtCursorPosition","editorElement","handlePopupSelect","emoji","Event","bubbles","dispatchEvent","handlePreventLoseFocus","_element$parentElemen","element","target","classList","contains","parentElement","stopPropagation","useEffect","document","body","addEventListener","removeEventListener","createElement","StyledEmojiInput","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","onPaste","ref","alignment","onSelect","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n ClipboardEvent,\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 { getRootFontFamily } from '../../utils/font';\nimport { insertTextAtCursorPosition } from '../../utils/insert';\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 const [rootFontFamily] = useState(getRootFontFamily());\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 prevents formatting from being adopted when texts are inserted. To do this, the\n * plain text is read from the event after the default behavior has been prevented. The plain\n * text is then inserted at the correct position in the input field using the\n * 'insertTextAtCursorPosition' function.\n */\n const handlePaste = useCallback((event: ClipboardEvent<HTMLDivElement>) => {\n if (editorRef.current) {\n event.preventDefault();\n\n const text = event.clipboardData.getData('text/plain');\n\n insertTextAtCursorPosition({ editorElement: editorRef.current, text });\n }\n }, []);\n\n /**\n * This function uses the 'insertTextAtCursorPosition' function to insert the emoji at the\n * correct position in the editor element.\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 insertTextAtCursorPosition({ editorElement: editorRef.current, text: emoji });\n\n const event = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(event);\n }\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 isMobile={isMobile}\n onInput={handleInput}\n onKeyDown={onKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={editorRef}\n rootFontFamily={rootFontFamily}\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;AAaA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAK6B,SAAAO,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,SAAAd,wBAAAU,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,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAhB,GAAA,QAAAgB,GA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W;IAC7BS,QAAQ,EAAEA,QAAS;IACnBR,OAAO,EAAEwB,WAAY;IACrBvB,SAAS,EAAEA,SAAU;IACrBuD,OAAO,EAAE9B,WAAY;IACrBtB,WAAW,EAAEA,WAAY;IACzBqD,GAAG,EAAE5C,SAAU;IACfF,cAAc,EAAEA;EAAe,EACjC,EACD,CAACH,QAAQ,iBACN7C,MAAA,CAAAa,OAAA,CAAA0E,aAAA,CAAC/E,iBAAA,CAAAK,OAAgB;IACbsB,WAAW,EAAEA,WAAY;IACzB4D,SAAS,EAAErD,cAAe;IAC1BsD,QAAQ,EAAE3B,iBAAkB;IAC5B9B,uBAAuB,EAAEA,uBAAwB;IACjDC,QAAQ,EAAEA;EAAS,EAE1B,CACqB,EACzBG,YAAY,iBACT3C,MAAA,CAAAa,OAAA,CAAA0E,aAAA,CAAC7E,WAAA,CAAAuF,4BAA4B,QAAEtD,YAAY,CAC9C,CACc;AAE3B,CAAC;AAEDV,UAAU,CAACiE,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvBlE,UAAU;AAAAmE,OAAA,CAAAvF,OAAA,GAAAsF,QAAA"}
@@ -95,6 +95,7 @@ const StyledEmojiInputEditor = _styledComponents.default.div`
95
95
  } = _ref8;
96
96
  return theme['006'];
97
97
  }};
98
+ pointer-events: none;
98
99
  }
99
100
 
100
101
  // Styles for custom scrollbar
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiInput.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledEmojiInput","styled","div","_ref","theme","_ref2","isDisabled","_ref3","exports","StyledEmojiInputContent","_ref4","isRightElementGiven","css","StyledEmojiInputEditor","_ref5","text","_ref6","isMobile","rootFontFamily","_ref7","placeholder","_ref8","_ref9","_ref10","StyledEmojiInputRightWrapper"],"sources":["../../../src/components/emoji-input/EmojiInput.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled, { css } from 'styled-components';\nimport type { EmojiInputProps } from './EmojiInput';\n\ntype StyledEmojiInputProps = WithTheme<Pick<EmojiInputProps, 'isDisabled'>>;\n\nexport const StyledEmojiInput = styled.div<StyledEmojiInputProps>`\n align-items: center;\n background-color: ${({ theme }: StyledEmojiInputProps) => theme['100']};\n border-radius: 3px;\n display: flex;\n min-height: 42px;\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n pointer-events: ${({ isDisabled }) => (isDisabled ? 'none' : 'initial')};\n position: relative;\n transition: opacity 0.3s ease;\n`;\n\ntype StyledEmojiInputContentProps = {\n isRightElementGiven: boolean;\n};\n\nexport const StyledEmojiInputContent = styled.div<StyledEmojiInputContentProps>`\n align-items: end;\n border: 1px solid rgba(160, 160, 160, 0.3);\n border-radius: 3px;\n display: flex;\n flex: 1 1 auto;\n gap: 10px;\n padding: 8px 10px;\n\n ${({ isRightElementGiven }) =>\n isRightElementGiven &&\n css`\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n border-right-width: 0;\n `}\n`;\n\ntype StyledEmojiInputEditorProps = WithTheme<Pick<EmojiInputProps, 'placeholder'>> & {\n isMobile: boolean;\n rootFontFamily: string;\n};\n\nexport const StyledEmojiInputEditor = styled.div<StyledEmojiInputEditorProps>`\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme.text};\n flex: 1 1 auto;\n max-height: 210px;\n overflow-y: scroll;\n word-break: break-word;\n\n ${({ isMobile, rootFontFamily }) => {\n if (isMobile) {\n return css`\n font-family: ${rootFontFamily};\n `;\n }\n\n return css`\n font-family: ${rootFontFamily}, 'Noto Color Emoji';\n `;\n }}\n\n &:empty:not(:focus):before {\n content: '${({ placeholder }) => placeholder}';\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme['006']};\n }\n\n // Styles for custom scrollbar\n ::-webkit-scrollbar {\n width: 5px;\n }\n\n ::-webkit-scrollbar-track {\n background-color: transparent;\n }\n\n ::-webkit-scrollbar-button {\n background-color: transparent;\n height: 5px;\n }\n\n ::-webkit-scrollbar-thumb {\n background-color: rgba(\n ${({ theme }: StyledEmojiInputEditorProps) => theme['text-rgb']},\n 0.15\n );\n border-radius: 20px;\n }\n\n // Scrollbar styles for Firefox. The above styles are not supported in Firefox, these styles are\n // only supported in Firefox:\n * {\n scrollbar-color: rgba(\n ${({ theme }: StyledEmojiInputEditorProps) => theme['text-rgb']},\n 0.15\n )\n transparent;\n scrollbar-width: thin;\n }\n`;\n\nexport const StyledEmojiInputRightWrapper = styled.div`\n align-self: stretch;\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n flex: 0 0 auto;\n overflow: hidden;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAC,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,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAA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3,"file":"EmojiInput.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledEmojiInput","styled","div","_ref","theme","_ref2","isDisabled","_ref3","exports","StyledEmojiInputContent","_ref4","isRightElementGiven","css","StyledEmojiInputEditor","_ref5","text","_ref6","isMobile","rootFontFamily","_ref7","placeholder","_ref8","_ref9","_ref10","StyledEmojiInputRightWrapper"],"sources":["../../../src/components/emoji-input/EmojiInput.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled, { css } from 'styled-components';\nimport type { EmojiInputProps } from './EmojiInput';\n\ntype StyledEmojiInputProps = WithTheme<Pick<EmojiInputProps, 'isDisabled'>>;\n\nexport const StyledEmojiInput = styled.div<StyledEmojiInputProps>`\n align-items: center;\n background-color: ${({ theme }: StyledEmojiInputProps) => theme['100']};\n border-radius: 3px;\n display: flex;\n min-height: 42px;\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n pointer-events: ${({ isDisabled }) => (isDisabled ? 'none' : 'initial')};\n position: relative;\n transition: opacity 0.3s ease;\n`;\n\ntype StyledEmojiInputContentProps = {\n isRightElementGiven: boolean;\n};\n\nexport const StyledEmojiInputContent = styled.div<StyledEmojiInputContentProps>`\n align-items: end;\n border: 1px solid rgba(160, 160, 160, 0.3);\n border-radius: 3px;\n display: flex;\n flex: 1 1 auto;\n gap: 10px;\n padding: 8px 10px;\n\n ${({ isRightElementGiven }) =>\n isRightElementGiven &&\n css`\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n border-right-width: 0;\n `}\n`;\n\ntype StyledEmojiInputEditorProps = WithTheme<Pick<EmojiInputProps, 'placeholder'>> & {\n isMobile: boolean;\n rootFontFamily: string;\n};\n\nexport const StyledEmojiInputEditor = styled.div<StyledEmojiInputEditorProps>`\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme.text};\n flex: 1 1 auto;\n max-height: 210px;\n overflow-y: scroll;\n word-break: break-word;\n\n ${({ isMobile, rootFontFamily }) => {\n if (isMobile) {\n return css`\n font-family: ${rootFontFamily};\n `;\n }\n\n return css`\n font-family: ${rootFontFamily}, 'Noto Color Emoji';\n `;\n }}\n\n &:empty:not(:focus):before {\n content: '${({ placeholder }) => placeholder}';\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme['006']};\n pointer-events: none;\n }\n\n // Styles for custom scrollbar\n ::-webkit-scrollbar {\n width: 5px;\n }\n\n ::-webkit-scrollbar-track {\n background-color: transparent;\n }\n\n ::-webkit-scrollbar-button {\n background-color: transparent;\n height: 5px;\n }\n\n ::-webkit-scrollbar-thumb {\n background-color: rgba(\n ${({ theme }: StyledEmojiInputEditorProps) => theme['text-rgb']},\n 0.15\n );\n border-radius: 20px;\n }\n\n // Scrollbar styles for Firefox. The above styles are not supported in Firefox, these styles are\n // only supported in Firefox:\n * {\n scrollbar-color: rgba(\n ${({ theme }: StyledEmojiInputEditorProps) => theme['text-rgb']},\n 0.15\n )\n transparent;\n scrollbar-width: thin;\n }\n`;\n\nexport const StyledEmojiInputRightWrapper = styled.div`\n align-self: stretch;\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n flex: 0 0 auto;\n overflow: hidden;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAC,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,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QA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C5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBmB,MAAA;EAAA,IAAC;IAAEnB;EAAmC,CAAC,GAAAmB,MAAA;EAAA,OAAKnB,KAAK,CAAC,UAAU,CAAC;AAAA,CAAC;AAChF;AACA;AACA;AACA;AACA;AACA,CAAC;AAACI,OAAA,CAAAK,sBAAA,GAAAA,sBAAA;AAEK,MAAMW,4BAA4B,GAAGvB,yBAAM,CAACC,GAAI;AACvD;AACA;AACA;AACA;AACA;AACA,CAAC;AAACM,OAAA,CAAAgB,4BAAA,GAAAA,4BAAA"}
@@ -29,7 +29,7 @@ const EmojiPicker = _ref => {
29
29
  const handleSearchChange = (0, _react.useCallback)(event => {
30
30
  setSearchString(event.target.value);
31
31
  }, []);
32
- return /*#__PURE__*/_react.default.createElement(_core.LazyMotionWrapper, null, /*#__PURE__*/_react.default.createElement(_EmojiPicker.StyledEmojiPicker, null, /*#__PURE__*/_react.default.createElement(_core.Input, {
32
+ return /*#__PURE__*/_react.default.createElement(_EmojiPicker.StyledEmojiPicker, null, /*#__PURE__*/_react.default.createElement(_core.Input, {
33
33
  onChange: handleSearchChange,
34
34
  placeholder: "Suchen",
35
35
  value: searchString
@@ -43,7 +43,7 @@ const EmojiPicker = _ref => {
43
43
  onSelect: handleCategorySelect,
44
44
  searchString: searchString,
45
45
  selectedCategory: selectedCategory
46
- })));
46
+ }));
47
47
  };
48
48
  EmojiPicker.displayName = 'EmojiPicker';
49
49
  var _default = EmojiPicker;
@@ -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$","accessToken","onSelect","personId","searchString","setSearchString","useState","selectedCategory","setSelectedCategory","emojiCategories","slug","handleCategorySelect","useCallback","category","handleSearchChange","event","target","value","createElement","LazyMotionWrapper","StyledEmojiPicker","Input","onChange","placeholder","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker/EmojiPicker.tsx"],"sourcesContent":["import { Input, LazyMotionWrapper } 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 <LazyMotionWrapper>\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 </LazyMotionWrapper>\n );\n};\n\nE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AAmB;IAACS,WAAW,EAAC,QAAQ;IAACN,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,CACJ;AAE5B,CAAC;AAEDT,WAAW,CAAC0B,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAEzB3B,WAAW;AAAA4B,OAAA,CAAAhD,OAAA,GAAA+C,QAAA"}
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,EAA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WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAEzB1B,WAAW;AAAA2B,OAAA,CAAA/C,OAAA,GAAA8C,QAAA"}
@@ -17,7 +17,7 @@ const StyledEmojiPickerCategories = _styledComponents.default.div`
17
17
  width: 100%;
18
18
  `;
19
19
  exports.StyledEmojiPickerCategories = StyledEmojiPickerCategories;
20
- const StyledMotionEmojiPickerCategory = (0, _styledComponents.default)(_framerMotion.m.div)`
20
+ const StyledMotionEmojiPickerCategory = (0, _styledComponents.default)(_framerMotion.motion.div)`
21
21
  cursor: pointer;
22
22
  font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;
23
23
  font-size: 20px;
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPickerCategories.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","obj","__esModule","default","StyledEmojiPickerCategories","styled","div","exports","StyledMotionEmojiPickerCategory","m"],"sources":["../../../../src/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.ts"],"sourcesContent":["import { m } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledEmojiPickerCategories = styled.div`\n align-items: center;\n border-top: 1px solid rgba(160, 160, 160, 0.3);\n display: flex;\n flex: 0 0 auto;\n justify-content: space-between;\n padding-top: 10px;\n width: 100%;\n`;\n\nexport const StyledMotionEmojiPickerCategory = styled(m.div)`\n cursor: pointer;\n font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;\n font-size: 20px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,2BAA2B,GAAGC,yBAAM,CAACC,GAAI;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAH,2BAAA,GAAAA,2BAAA;AAEK,MAAMI,+BAA+B,GAAG,IAAAH,yBAAM,EAACI,eAAC,CAACH,GAAG,CAAE;AAC7D;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAC,+BAAA,GAAAA,+BAAA"}
1
+ {"version":3,"file":"EmojiPickerCategories.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","obj","__esModule","default","StyledEmojiPickerCategories","styled","div","exports","StyledMotionEmojiPickerCategory","motion"],"sources":["../../../../src/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledEmojiPickerCategories = styled.div`\n align-items: center;\n border-top: 1px solid rgba(160, 160, 160, 0.3);\n display: flex;\n flex: 0 0 auto;\n justify-content: space-between;\n padding-top: 10px;\n width: 100%;\n`;\n\nexport const StyledMotionEmojiPickerCategory = styled(motion.div)`\n cursor: pointer;\n font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;\n font-size: 20px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,2BAA2B,GAAGC,yBAAM,CAACC,GAAI;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAH,2BAAA,GAAAA,2BAAA;AAEK,MAAMI,+BAA+B,GAAG,IAAAH,yBAAM,EAACI,oBAAM,CAACH,GAAG,CAAE;AAClE;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAC,+BAAA,GAAAA,+BAAA"}
@@ -9,7 +9,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
  var _alignment = require("../../../../../constants/alignment");
10
10
  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); }
11
11
  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; }
12
- const StyledMotionSkinTonePopup = (0, _styledComponents.default)(_framerMotion.m.div)`
12
+ const StyledMotionSkinTonePopup = (0, _styledComponents.default)(_framerMotion.motion.div)`
13
13
  z-index: 1;
14
14
  `;
15
15
  exports.StyledMotionSkinTonePopup = StyledMotionSkinTonePopup;
@@ -1 +1 @@
1
- {"version":3,"file":"SkinTonePopup.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_alignment","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledMotionSkinTonePopup","styled","m","div","exports","skinTonePopupContentSize","height","width","StyledSkinTonePopupContent","_ref","theme","_ref2","anchorAlignment","anchorOffset","AnchorAlignment","Bottom","css","Top","undefined","StyledSkinTonePopupContentEmoji","StyledSkinTonePopupOverlay"],"sources":["../../../../../../src/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { m } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { AnchorAlignment } from '../../../../../constants/alignment';\nimport type { SkinTonePopupProps } from './SkinTonePopup';\n\nexport const StyledMotionSkinTonePopup = styled(m.div)`\n z-index: 1;\n`;\n\nexport const skinTonePopupContentSize = {\n height: 48,\n width: 200,\n};\n\ntype StyledSkinTonePopupContentProps = WithTheme<\n Pick<SkinTonePopupProps, 'anchorAlignment' | 'anchorOffset'>\n>;\n\nexport const StyledSkinTonePopupContent = styled.div<StyledSkinTonePopupContentProps>`\n align-items: stretch;\n background-color: ${({ theme }: StyledSkinTonePopupContentProps) => theme['001']};\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n display: flex;\n height: ${skinTonePopupContentSize.height}px;\n justify-content: stretch;\n position: absolute;\n width: ${skinTonePopupContentSize.width}px;\n z-index: 2;\n\n ::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-bottom-right-radius: 3px;\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ anchorAlignment, anchorOffset }) => {\n switch (anchorAlignment) {\n case AnchorAlignment.Bottom:\n return css`\n bottom: -7px;\n left: calc(50% - 7px + ${anchorOffset}px);\n transform: rotate(45deg);\n `;\n case AnchorAlignment.Top:\n return css`\n top: -7px;\n left: calc(50% - 7px + ${anchorOffset}px);\n transform: rotate(225deg);\n `;\n default:\n return undefined;\n }\n }}\n }\n\n ::before {\n background-color: inherit;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n\nexport const StyledSkinTonePopupContentEmoji = styled.div`\n align-items: center;\n display: flex;\n flex: 1 1 auto;\n font-size: 24px;\n justify-content: center;\n`;\n\nexport const StyledSkinTonePopupOverlay = styled.div`\n cursor: default;\n height: 100%;\n left: 0;\n position: absolute;\n width: 100%;\n z-index: 1;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAqE,SAAAI,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,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAA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BAA+B,GAAGlB,yBAAM,CAACE,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAe,+BAAA,GAAAA,+BAAA;AAEK,MAAMC,0BAA0B,GAAGnB,yBAAM,CAACE,GAAI;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAgB,0BAAA,GAAAA,0BAAA"}
1
+ {"version":3,"file":"SkinTonePopup.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_alignment","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledMotionSkinTonePopup","styled","motion","div","exports","skinTonePopupContentSize","height","width","StyledSkinTonePopupContent","_ref","theme","_ref2","anchorAlignment","anchorOffset","AnchorAlignment","Bottom","css","Top","undefined","StyledSkinTonePopupContentEmoji","StyledSkinTonePopupOverlay"],"sources":["../../../../../../src/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { AnchorAlignment } from '../../../../../constants/alignment';\nimport type { SkinTonePopupProps } from './SkinTonePopup';\n\nexport const StyledMotionSkinTonePopup = styled(motion.div)`\n z-index: 1;\n`;\n\nexport const skinTonePopupContentSize = {\n height: 48,\n width: 200,\n};\n\ntype StyledSkinTonePopupContentProps = WithTheme<\n Pick<SkinTonePopupProps, 'anchorAlignment' | 'anchorOffset'>\n>;\n\nexport const StyledSkinTonePopupContent = styled.div<StyledSkinTonePopupContentProps>`\n align-items: stretch;\n background-color: ${({ theme }: StyledSkinTonePopupContentProps) => theme['001']};\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n display: flex;\n height: ${skinTonePopupContentSize.height}px;\n justify-content: stretch;\n position: absolute;\n width: ${skinTonePopupContentSize.width}px;\n z-index: 2;\n\n ::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-bottom-right-radius: 3px;\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ anchorAlignment, anchorOffset }) => {\n switch (anchorAlignment) {\n case AnchorAlignment.Bottom:\n return css`\n bottom: -7px;\n left: calc(50% - 7px + ${anchorOffset}px);\n transform: rotate(45deg);\n `;\n case AnchorAlignment.Top:\n return css`\n top: -7px;\n left: calc(50% - 7px + ${anchorOffset}px);\n transform: rotate(225deg);\n `;\n default:\n return undefined;\n }\n }}\n }\n\n ::before {\n background-color: inherit;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n\nexport const StyledSkinTonePopupContentEmoji = styled.div`\n align-items: center;\n display: flex;\n flex: 1 1 auto;\n font-size: 24px;\n justify-content: center;\n`;\n\nexport const StyledSkinTonePopupOverlay = styled.div`\n cursor: default;\n height: 100%;\n left: 0;\n position: absolute;\n width: 100%;\n z-index: 1;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAqE,SAAAI,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,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC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AAAA,CAAC;AACrF;AACA;AACA;AACA;AACA,cAAcL,wBAAwB,CAACC,MAAO;AAC9C;AACA;AACA,aAAaD,wBAAwB,CAACE,KAAM;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUI,KAAA,IAAuC;EAAA,IAAtC;IAAEC,eAAe;IAAEC;EAAa,CAAC,GAAAF,KAAA;EAChC,QAAQC,eAAe;IACnB,KAAKE,0BAAe,CAACC,MAAM;MACvB,OAAO,IAAAC,qBAAG,CAAC;AAC/B;AACA,iDAAiDH,YAAa;AAC9D;AACA,qBAAqB;IACL,KAAKC,0BAAe,CAACG,GAAG;MACpB,OAAO,IAAAD,qBAAG,CAAC;AAC/B;AACA,iDAAiDH,YAAa;AAC9D;AACA,qBAAqB;IACL;MACI,OAAOK,SAAS;EAAC;AAE7B,CAAE;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACd,OAAA,CAAAI,0BAAA,GAAAA,0BAAA;AAEK,MAAMW,+BAA+B,GAAGlB,yBAAM,CAACE,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAe,+BAAA,GAAAA,+BAAA;AAEK,MAAMC,0BAA0B,GAAGnB,yBAAM,CAACE,GAAI;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAgB,0BAAA,GAAAA,0BAAA"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _core = require("@chayns-components/core");
8
7
  var _Icon = _interopRequireDefault(require("@chayns-components/core/lib/components/icon/Icon"));
9
8
  var _framerMotion = require("framer-motion");
10
9
  var _react = _interopRequireWildcard(require("react"));
@@ -112,7 +111,7 @@ const EmojiPickerPopup = _ref => {
112
111
  }
113
112
  }, [onPopupVisibilityChange, shouldShowPopup]);
114
113
  const exitAndInitialY = internalAlignment === _alignment.PopupAlignment.TopLeft || internalAlignment === _alignment.PopupAlignment.TopRight ? -16 : 16;
115
- return /*#__PURE__*/_react.default.createElement(_core.LazyMotionWrapper, null, /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledEmojiPickerPopup, null, /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
114
+ return /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledEmojiPickerPopup, null, /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
116
115
  initial: false
117
116
  }, shouldShowPopup && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledMotionEmojiPickerPopupContent, {
118
117
  alignment: internalAlignment,
@@ -143,7 +142,7 @@ const EmojiPickerPopup = _ref => {
143
142
  icons: ['far fa-smile'],
144
143
  onClick: handlePopupIconClick,
145
144
  size: 18
146
- })));
145
+ }));
147
146
  };
148
147
  EmojiPickerPopup.displayName = 'EmojiPickerPopup';
149
148
  var _default = EmojiPickerPopup;
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPickerPopup.js","names":["_core","require","_Icon","_interopRequireDefault","_framerMotion","_react","_interopRequireWildcard","_alignment","_EmojiPicker","_EmojiPicker2","_EmojiPickerPopup","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerPopup","_ref","accessToken","alignment","onPopupVisibilityChange","onSelect","personId","internalAlignment","setInternalAlignment","useState","PopupAlignment","TopLeft","shouldShowPopup","setShouldShowPopup","position","setPosition","contentRef","useRef","handleHide","useCallback","handleDocumentClick","event","_contentRef$current","current","contains","target","preventDefault","stopPropagation","handlePopupIconClick","height","left","top","width","currentTarget","getBoundingClientRect","newInternalAlignment","emojiPickerSize","BottomRight","BottomLeft","TopRight","newPosition","useEffect","document","addEventListener","window","removeEventListener","exitAndInitialY","createElement","LazyMotionWrapper","StyledEmojiPickerPopup","AnimatePresence","initial","StyledMotionEmojiPickerPopupContent","animate","opacity","y","exit","ref","style","transition","type","className","icons","onClick","size","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker-popup/EmojiPickerPopup.tsx"],"sourcesContent":["import { LazyMotionWrapper } from '@chayns-components/core';\nimport Icon from '@chayns-components/core/lib/components/icon/Icon';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { PopupAlignment } from '../../constants/alignment';\nimport EmojiPicker from '../emoji-picker/EmojiPicker';\nimport { emojiPickerSize } from '../emoji-picker/EmojiPicker.styles';\nimport {\n StyledEmojiPickerPopup,\n StyledMotionEmojiPickerPopupContent,\n} from './EmojiPickerPopup.styles';\n\nexport type EmojiPickerPopupProps = {\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 * 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 alignment?: PopupAlignment;\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 * 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\nexport type PopupPosition = {\n bottom?: number;\n left?: number;\n right?: number;\n top?: number;\n};\n\nconst EmojiPickerPopup: FC<EmojiPickerPopupProps> = ({\n accessToken,\n alignment,\n onPopupVisibilityChange,\n onSelect,\n personId,\n}) => {\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft\n );\n const [shouldShowPopup, setShouldShowPopup] = useState(false);\n const [position, setPosition] = useState({} as PopupPosition);\n\n const contentRef = useRef<HTMLDivElement>(null);\n\n const handleHide = useCallback(() => {\n setShouldShowPopup(false);\n }, []);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!contentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n\n handleHide();\n }\n },\n [handleHide]\n );\n\n const handlePopupIconClick = useCallback(\n (event: MouseEvent<HTMLSpanElement>) => {\n if (shouldShowPopup) {\n setShouldShowPopup(false);\n\n return;\n }\n\n const { height, left, top, width } = event.currentTarget.getBoundingClientRect();\n\n let newInternalAlignment: PopupAlignment | undefined = alignment;\n\n if (typeof newInternalAlignment !== 'number') {\n if (top < emojiPickerSize.height + 16) {\n if (left < emojiPickerSize.width + 16) {\n newInternalAlignment = PopupAlignment.BottomRight;\n } else {\n newInternalAlignment = PopupAlignment.BottomLeft;\n }\n } else if (left < emojiPickerSize.width + 16) {\n newInternalAlignment = PopupAlignment.TopRight;\n } else {\n newInternalAlignment = PopupAlignment.TopLeft;\n }\n }\n\n let newPosition: PopupPosition = {};\n\n switch (newInternalAlignment) {\n case PopupAlignment.BottomLeft:\n newPosition = { left: 8 + width - emojiPickerSize.width, top: 12 + height };\n break;\n case PopupAlignment.BottomRight:\n newPosition = { left: -10, top: 12 + height };\n break;\n case PopupAlignment.TopLeft:\n newPosition = {\n left: 8 + width - emojiPickerSize.width,\n top: -12 - emojiPickerSize.height,\n };\n break;\n case PopupAlignment.TopRight:\n newPosition = { left: -10, top: -12 - emojiPickerSize.height };\n break;\n default:\n break;\n }\n\n setInternalAlignment(newInternalAlignment);\n setPosition(newPosition);\n setShouldShowPopup(true);\n },\n [alignment, shouldShowPopup]\n );\n\n useEffect(() => {\n if (shouldShowPopup) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, shouldShowPopup]);\n\n useEffect(() => {\n if (typeof onPopupVisibilityChange === 'function') {\n onPopupVisibilityChange(shouldShowPopup);\n }\n }, [onPopupVisibilityChange, shouldShowPopup]);\n\n const exitAndInitialY =\n internalAlignment === PopupAlignment.TopLeft ||\n internalAlignment === PopupAlignment.TopRight\n ? -16\n : 16;\n\n return (\n <LazyMotionWrapper>\n <StyledEmojiPickerPopup>\n <AnimatePresence initial={false}>\n {shouldShowPopup && (\n <StyledMotionEmojiPickerPopupContent\n alignment={internalAlignment}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n key=\"emojiPickerPopupContent\"\n ref={contentRef}\n style={position}\n transition={{ type: 'tween' }}\n >\n <EmojiPicker\n accessToken={accessToken}\n onSelect={onSelect}\n personId={personId}\n />\n </StyledMotionEmojiPickerPopupContent>\n )}\n </AnimatePresence>\n <Icon\n className=\"prevent-lose-focus\"\n icons={['far fa-smile']}\n onClick={handlePopupIconClick}\n size={18}\n />\n </StyledEmojiPickerPopup>\n </LazyMotionWrapper>\n );\n};\n\nEmojiPickerPopup.displayName = 'EmojiPickerPopup';\n\nexport default EmojiPickerPopup;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AAGmC,SAAAU,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,SAAA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AAO,EAAE;MAAEG,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAET;IAAgB,CAAE;IAC5CpD,GAAG,EAAC,yBAAyB;IAC7B+D,GAAG,EAAEzC,UAAW;IAChB0C,KAAK,EAAE5C,QAAS;IAChB6C,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9BxF,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAACxE,YAAA,CAAAU,OAAW;IACRiB,WAAW,EAAEA,WAAY;IACzBG,QAAQ,EAAEA,QAAS;IACnBC,QAAQ,EAAEA;EAAS,EACrB,CAET,CACa,eAClBlC,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAAC9E,KAAA,CAAAgB,OAAI;IACD4E,SAAS,EAAC,oBAAoB;IAC9BC,KAAK,EAAE,CAAC,cAAc,CAAE;IACxBC,OAAO,EAAEnC,oBAAqB;IAC9BoC,IAAI,EAAE;EAAG,EACX,CACmB,CACT;AAE5B,CAAC;AAEDhE,gBAAgB,CAACiE,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnClE,gBAAgB;AAAAmE,OAAA,CAAAlF,OAAA,GAAAiF,QAAA"}
1
+ {"version":3,"file":"EmojiPickerPopup.js","names":["_Icon","_interopRequireDefault","require","_framerMotion","_react","_interopRequireWildcard","_alignment","_EmojiPicker","_EmojiPicker2","_EmojiPickerPopup","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerPopup","_ref","accessToken","alignment","onPopupVisibilityChange","onSelect","personId","internalAlignment","setInternalAlignment","useState","PopupAlignment","TopLeft","shouldShowPopup","setShouldShowPopup","position","setPosition","contentRef","useRef","handleHide","useCallback","handleDocumentClick","event","_contentRef$current","current","contains","target","preventDefault","stopPropagation","handlePopupIconClick","height","left","top","width","currentTarget","getBoundingClientRect","newInternalAlignment","emojiPickerSize","BottomRight","BottomLeft","TopRight","newPosition","useEffect","document","addEventListener","window","removeEventListener","exitAndInitialY","createElement","StyledEmojiPickerPopup","AnimatePresence","initial","StyledMotionEmojiPickerPopupContent","animate","opacity","y","exit","ref","style","transition","type","className","icons","onClick","size","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker-popup/EmojiPickerPopup.tsx"],"sourcesContent":["import Icon from '@chayns-components/core/lib/components/icon/Icon';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { PopupAlignment } from '../../constants/alignment';\nimport EmojiPicker from '../emoji-picker/EmojiPicker';\nimport { emojiPickerSize } from '../emoji-picker/EmojiPicker.styles';\nimport {\n StyledEmojiPickerPopup,\n StyledMotionEmojiPickerPopupContent,\n} from './EmojiPickerPopup.styles';\n\nexport type EmojiPickerPopupProps = {\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 * 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 alignment?: PopupAlignment;\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 * 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\nexport type PopupPosition = {\n bottom?: number;\n left?: number;\n right?: number;\n top?: number;\n};\n\nconst EmojiPickerPopup: FC<EmojiPickerPopupProps> = ({\n accessToken,\n alignment,\n onPopupVisibilityChange,\n onSelect,\n personId,\n}) => {\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft\n );\n const [shouldShowPopup, setShouldShowPopup] = useState(false);\n const [position, setPosition] = useState({} as PopupPosition);\n\n const contentRef = useRef<HTMLDivElement>(null);\n\n const handleHide = useCallback(() => {\n setShouldShowPopup(false);\n }, []);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!contentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n\n handleHide();\n }\n },\n [handleHide]\n );\n\n const handlePopupIconClick = useCallback(\n (event: MouseEvent<HTMLSpanElement>) => {\n if (shouldShowPopup) {\n setShouldShowPopup(false);\n\n return;\n }\n\n const { height, left, top, width } = event.currentTarget.getBoundingClientRect();\n\n let newInternalAlignment: PopupAlignment | undefined = alignment;\n\n if (typeof newInternalAlignment !== 'number') {\n if (top < emojiPickerSize.height + 16) {\n if (left < emojiPickerSize.width + 16) {\n newInternalAlignment = PopupAlignment.BottomRight;\n } else {\n newInternalAlignment = PopupAlignment.BottomLeft;\n }\n } else if (left < emojiPickerSize.width + 16) {\n newInternalAlignment = PopupAlignment.TopRight;\n } else {\n newInternalAlignment = PopupAlignment.TopLeft;\n }\n }\n\n let newPosition: PopupPosition = {};\n\n switch (newInternalAlignment) {\n case PopupAlignment.BottomLeft:\n newPosition = { left: 8 + width - emojiPickerSize.width, top: 12 + height };\n break;\n case PopupAlignment.BottomRight:\n newPosition = { left: -10, top: 12 + height };\n break;\n case PopupAlignment.TopLeft:\n newPosition = {\n left: 8 + width - emojiPickerSize.width,\n top: -12 - emojiPickerSize.height,\n };\n break;\n case PopupAlignment.TopRight:\n newPosition = { left: -10, top: -12 - emojiPickerSize.height };\n break;\n default:\n break;\n }\n\n setInternalAlignment(newInternalAlignment);\n setPosition(newPosition);\n setShouldShowPopup(true);\n },\n [alignment, shouldShowPopup]\n );\n\n useEffect(() => {\n if (shouldShowPopup) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, shouldShowPopup]);\n\n useEffect(() => {\n if (typeof onPopupVisibilityChange === 'function') {\n onPopupVisibilityChange(shouldShowPopup);\n }\n }, [onPopupVisibilityChange, shouldShowPopup]);\n\n const exitAndInitialY =\n internalAlignment === PopupAlignment.TopLeft ||\n internalAlignment === PopupAlignment.TopRight\n ? -16\n : 16;\n\n return (\n <StyledEmojiPickerPopup>\n <AnimatePresence initial={false}>\n {shouldShowPopup && (\n <StyledMotionEmojiPickerPopupContent\n alignment={internalAlignment}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n key=\"emojiPickerPopupContent\"\n ref={contentRef}\n style={position}\n transition={{ type: 'tween' }}\n >\n <EmojiPicker\n accessToken={accessToken}\n onSelect={onSelect}\n personId={personId}\n />\n </StyledMotionEmojiPickerPopupContent>\n )}\n </AnimatePresence>\n <Icon\n className=\"prevent-lose-focus\"\n icons={['far fa-smile']}\n onClick={handlePopupIconClick}\n size={18}\n />\n </StyledEmojiPickerPopup>\n );\n};\n\nEmojiPickerPopup.displayName = 'EmojiPickerPopup';\n\nexport default EmojiPickerPopup;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAGmC,SAAAQ,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,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA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G,EAAExC,UAAW;IAChByC,KAAK,EAAE3C,QAAS;IAChB4C,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9BvF,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAACxE,YAAA,CAAAU,OAAW;IACRiB,WAAW,EAAEA,WAAY;IACzBG,QAAQ,EAAEA,QAAS;IACnBC,QAAQ,EAAEA;EAAS,EACrB,CAET,CACa,eAClBlC,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAAC/E,KAAA,CAAAiB,OAAI;IACD2E,SAAS,EAAC,oBAAoB;IAC9BC,KAAK,EAAE,CAAC,cAAc,CAAE;IACxBC,OAAO,EAAElC,oBAAqB;IAC9BmC,IAAI,EAAE;EAAG,EACX,CACmB;AAEjC,CAAC;AAED/D,gBAAgB,CAACgE,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnCjE,gBAAgB;AAAAkE,OAAA,CAAAjF,OAAA,GAAAgF,QAAA"}
@@ -16,7 +16,7 @@ const StyledEmojiPickerPopup = _styledComponents.default.div`
16
16
  position: relative;
17
17
  `;
18
18
  exports.StyledEmojiPickerPopup = StyledEmojiPickerPopup;
19
- const StyledMotionEmojiPickerPopupContent = (0, _styledComponents.default)(_framerMotion.m.div)`
19
+ const StyledMotionEmojiPickerPopupContent = (0, _styledComponents.default)(_framerMotion.motion.div)`
20
20
  background-color: ${_ref => {
21
21
  let {
22
22
  theme
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPickerPopup.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_alignment","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledEmojiPickerPopup","styled","div","getComputedStyle","document","body","getPropertyValue","exports","StyledMotionEmojiPickerPopupContent","m","_ref","theme","_ref2","text","_ref3","alignment","PopupAlignment","TopLeft","css","BottomLeft","TopRight","BottomRight","undefined"],"sources":["../../../src/components/emoji-picker-popup/EmojiPickerPopup.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { m } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { PopupAlignment } from '../../constants/alignment';\n\nexport const StyledEmojiPickerPopup = styled.div`\n align-items: center;\n display: flex;\n height: ${() => getComputedStyle(document.body).getPropertyValue('line-height')};\n position: relative;\n`;\n\ntype StyledMotionEmojiPickerPopupContentProps = WithTheme<{\n alignment: PopupAlignment;\n}>;\n\nexport const StyledMotionEmojiPickerPopupContent = styled(\n m.div\n)<StyledMotionEmojiPickerPopupContentProps>`\n background-color: ${({ theme }: StyledMotionEmojiPickerPopupContentProps) => theme['001']};\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionEmojiPickerPopupContentProps) => theme.text};\n position: absolute;\n z-index: 0;\n\n ::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-bottom-right-radius: 3px;\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ alignment }) => {\n switch (alignment) {\n case PopupAlignment.TopLeft:\n return css`\n bottom: -7px;\n right: 12px;\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomLeft:\n return css`\n top: -7px;\n right: 12px;\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopRight:\n return css`\n transform: rotate(45deg);\n bottom: -7px;\n left: 12px;\n `;\n case PopupAlignment.BottomRight:\n return css`\n transform: rotate(225deg);\n top: -7px;\n left: 12px;\n `;\n default:\n return undefined;\n }\n }}\n }\n\n ::before {\n background-color: inherit;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 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1
+ {"version":3,"file":"EmojiPickerPopup.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_alignment","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledEmojiPickerPopup","styled","div","getComputedStyle","document","body","getPropertyValue","exports","StyledMotionEmojiPickerPopupContent","motion","_ref","theme","_ref2","text","_ref3","alignment","PopupAlignment","TopLeft","css","BottomLeft","TopRight","BottomRight","undefined"],"sources":["../../../src/components/emoji-picker-popup/EmojiPickerPopup.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { PopupAlignment } from '../../constants/alignment';\n\nexport const StyledEmojiPickerPopup = styled.div`\n align-items: center;\n display: flex;\n height: ${() => getComputedStyle(document.body).getPropertyValue('line-height')};\n position: relative;\n`;\n\ntype StyledMotionEmojiPickerPopupContentProps = WithTheme<{\n alignment: PopupAlignment;\n}>;\n\nexport const StyledMotionEmojiPickerPopupContent = styled(\n motion.div\n)<StyledMotionEmojiPickerPopupContentProps>`\n background-color: ${({ theme }: StyledMotionEmojiPickerPopupContentProps) => theme['001']};\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionEmojiPickerPopupContentProps) => theme.text};\n position: absolute;\n z-index: 0;\n\n ::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-bottom-right-radius: 3px;\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ alignment }) => {\n switch (alignment) {\n case PopupAlignment.TopLeft:\n return css`\n bottom: -7px;\n right: 12px;\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomLeft:\n return css`\n top: -7px;\n right: 12px;\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopRight:\n return css`\n transform: rotate(45deg);\n bottom: -7px;\n left: 12px;\n `;\n case PopupAlignment.BottomRight:\n return css`\n transform: rotate(225deg);\n top: -7px;\n left: 12px;\n `;\n default:\n return undefined;\n }\n }}\n }\n\n ::before {\n background-color: inherit;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA2D,SAAAI,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,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAA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AKF,yBAAc,CAACI,QAAQ;MACxB,OAAO,IAAAF,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,yBAAc,CAACK,WAAW;MAC3B,OAAO,IAAAH,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL;MACI,OAAOI,SAAS;EAAC;AAE7B,CAAE;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACf,OAAA,CAAAC,mCAAA,GAAAA,mCAAA"}
@@ -0,0 +1,19 @@
1
+ interface InsertTextAtCursorPositionOptions {
2
+ editorElement: HTMLDivElement;
3
+ text: string;
4
+ }
5
+ /**
6
+ * This function inserts the passed text at the correct position in the editor element. If the
7
+ * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
8
+ * will be appended to the back of the input field content.
9
+ *
10
+ * In addition, this function also sets the cursor to the correct position when the input field
11
+ * has the focus. For this purpose, the current position of the cursor or a selection is read to
12
+ * calculate the cursor position after inserting the text.
13
+ *
14
+ * @param {Object} options - Object with element and text to insert
15
+ * @param {HTMLDivElement} options.editorElement - Element to insert text into
16
+ * @param {string} options.text - Text to insert into element
17
+ */
18
+ export declare const insertTextAtCursorPosition: ({ editorElement, text, }: InsertTextAtCursorPositionOptions) => void;
19
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.insertTextAtCursorPosition = void 0;
7
+ /**
8
+ * This function inserts the passed text at the correct position in the editor element. If the
9
+ * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji
10
+ * will be appended to the back of the input field content.
11
+ *
12
+ * In addition, this function also sets the cursor to the correct position when the input field
13
+ * has the focus. For this purpose, the current position of the cursor or a selection is read to
14
+ * calculate the cursor position after inserting the text.
15
+ *
16
+ * @param {Object} options - Object with element and text to insert
17
+ * @param {HTMLDivElement} options.editorElement - Element to insert text into
18
+ * @param {string} options.text - Text to insert into element
19
+ */
20
+ const insertTextAtCursorPosition = _ref => {
21
+ let {
22
+ editorElement,
23
+ text
24
+ } = _ref;
25
+ const selection = window.getSelection();
26
+ if (selection !== null && selection !== void 0 && selection.anchorNode && editorElement.contains(selection.anchorNode)) {
27
+ const {
28
+ endOffset,
29
+ startOffset
30
+ } = selection.getRangeAt(0);
31
+ const rangeDistance = endOffset - startOffset;
32
+ let offset = endOffset + text.length - rangeDistance;
33
+ let {
34
+ anchorNode
35
+ } = selection;
36
+ if (anchorNode.nodeValue) {
37
+ anchorNode.nodeValue = anchorNode.nodeValue.substring(0, startOffset) + text + anchorNode.nodeValue.substring(endOffset);
38
+ } else if (anchorNode === editorElement) {
39
+ const newTextNode = document.createTextNode(text);
40
+ editorElement.appendChild(newTextNode);
41
+ anchorNode = newTextNode;
42
+ }
43
+ const newRange = document.createRange();
44
+ if (anchorNode.nodeValue) {
45
+ offset = Math.min(offset, anchorNode.nodeValue.length);
46
+ }
47
+ newRange.setStart(anchorNode, offset);
48
+ newRange.setEnd(anchorNode, offset);
49
+ selection.removeAllRanges();
50
+ selection.addRange(newRange);
51
+ } else {
52
+ // eslint-disable-next-line no-param-reassign
53
+ editorElement.innerText += text;
54
+ }
55
+ };
56
+ exports.insertTextAtCursorPosition = insertTextAtCursorPosition;
57
+ //# sourceMappingURL=insert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.js","names":["insertTextAtCursorPosition","_ref","editorElement","text","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","innerText","exports"],"sources":["../../src/utils/insert.ts"],"sourcesContent":["interface InsertTextAtCursorPositionOptions {\n editorElement: HTMLDivElement;\n text: string;\n}\n\n/**\n * This function inserts the passed text at the correct position in the editor element. If the\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 text.\n *\n * @param {Object} options - Object with element and text to insert\n * @param {HTMLDivElement} options.editorElement - Element to insert text into\n * @param {string} options.text - Text to insert into element\n */\nexport const insertTextAtCursorPosition = ({\n editorElement,\n text,\n}: InsertTextAtCursorPositionOptions) => {\n const selection = window.getSelection();\n\n if (selection?.anchorNode && editorElement.contains(selection.anchorNode)) {\n const { endOffset, startOffset } = selection.getRangeAt(0);\n\n const rangeDistance = endOffset - startOffset;\n\n let offset = endOffset + text.length - rangeDistance;\n\n let { anchorNode } = selection;\n\n if (anchorNode.nodeValue) {\n anchorNode.nodeValue =\n anchorNode.nodeValue.substring(0, startOffset) +\n text +\n anchorNode.nodeValue.substring(endOffset);\n } else if (anchorNode === editorElement) {\n const newTextNode = document.createTextNode(text);\n\n editorElement.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 // eslint-disable-next-line no-param-reassign\n editorElement.innerText += text;\n }\n};\n"],"mappings":";;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GAAGC,IAAA,IAGD;EAAA,IAHE;IACvCC,aAAa;IACbC;EAC+B,CAAC,GAAAF,IAAA;EAChC,MAAMG,SAAS,GAAGC,MAAM,CAACC,YAAY,EAAE;EAEvC,IAAIF,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEG,UAAU,IAAIL,aAAa,CAACM,QAAQ,CAACJ,SAAS,CAACG,UAAU,CAAC,EAAE;IACvE,MAAM;MAAEE,SAAS;MAAEC;IAAY,CAAC,GAAGN,SAAS,CAACO,UAAU,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4
  "description": "Input field that supports HTML elements and emojis",
5
5
  "keywords": [
6
6
  "chayns",
@@ -52,7 +52,7 @@
52
52
  "typescript": "^4.9.5"
53
53
  },
54
54
  "dependencies": {
55
- "@chayns-components/core": "^5.0.0-beta.89",
55
+ "@chayns-components/core": "^5.0.0-beta.90",
56
56
  "@chayns/colors": "^2.0.0",
57
57
  "clsx": "^1.2.1",
58
58
  "emojilib": "^3.0.8",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "6762ce977ccf926ce6a2e0e0ae513d5709395758"
71
+ "gitHead": "1a8425eda31892864b98de72de0aff346c218e40"
72
72
  }