@chayns-components/emoji-input 5.0.0-beta.221 → 5.0.0-beta.222
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/components/emoji-input/EmojiInput.js +12 -2
- package/lib/components/emoji-input/EmojiInput.js.map +1 -1
- package/lib/components/emoji-input/EmojiInput.styles.d.ts +4 -1
- package/lib/components/emoji-input/EmojiInput.styles.js +15 -9
- package/lib/components/emoji-input/EmojiInput.styles.js.map +1 -1
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.d.ts +4 -0
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +5 -2
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -1
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +5 -1
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js +13 -7
- package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -1
- package/package.json +2 -2
|
@@ -34,7 +34,9 @@ const EmojiInput = _ref => {
|
|
|
34
34
|
} = _ref;
|
|
35
35
|
const [isMobile] = (0, _react.useState)((0, _environment.getIsMobile)());
|
|
36
36
|
const [plainTextValue, setPlainTextValue] = (0, _react.useState)(value);
|
|
37
|
+
const [width, setWidth] = (0, _react.useState)(0);
|
|
37
38
|
const editorRef = (0, _react.useRef)(null);
|
|
39
|
+
const wrapperRef = (0, _react.useRef)(null);
|
|
38
40
|
const shouldDeleteOneMoreBackwards = (0, _react.useRef)(false);
|
|
39
41
|
const shouldDeleteOneMoreForwards = (0, _react.useRef)(false);
|
|
40
42
|
|
|
@@ -182,8 +184,14 @@ const EmojiInput = _ref => {
|
|
|
182
184
|
document.body.removeEventListener('mousedown', handlePreventLoseFocus);
|
|
183
185
|
};
|
|
184
186
|
}, []);
|
|
187
|
+
(0, _react.useEffect)(() => {
|
|
188
|
+
if (wrapperRef.current) {
|
|
189
|
+
setWidth(wrapperRef.current.offsetWidth);
|
|
190
|
+
}
|
|
191
|
+
}, []);
|
|
185
192
|
return /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInput, {
|
|
186
|
-
isDisabled: isDisabled
|
|
193
|
+
isDisabled: isDisabled,
|
|
194
|
+
ref: wrapperRef
|
|
187
195
|
}, /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputContent, {
|
|
188
196
|
isRightElementGiven: !!rightElement
|
|
189
197
|
}, /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputEditor, {
|
|
@@ -195,12 +203,14 @@ const EmojiInput = _ref => {
|
|
|
195
203
|
onKeyDown: handleKeyDown,
|
|
196
204
|
onPaste: handlePaste,
|
|
197
205
|
placeholder: placeholder,
|
|
198
|
-
ref: editorRef
|
|
206
|
+
ref: editorRef,
|
|
207
|
+
width: width - 50
|
|
199
208
|
}), !isMobile && !shouldPreventEmojiPicker && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.default, {
|
|
200
209
|
accessToken: accessToken,
|
|
201
210
|
alignment: popupAlignment,
|
|
202
211
|
onSelect: handlePopupSelect,
|
|
203
212
|
onPopupVisibilityChange: onPopupVisibilityChange,
|
|
213
|
+
parentWidth: width,
|
|
204
214
|
personId: personId
|
|
205
215
|
})), rightElement && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputRightWrapper, null, rightElement));
|
|
206
216
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_insert","_selection","_text","_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","inputId","isDisabled","onBlur","onFocus","onInput","onKeyDown","onPopupVisibilityChange","personId","placeholder","popupAlignment","rightElement","shouldPreventEmojiPicker","value","isMobile","useState","getIsMobile","plainTextValue","setPlainTextValue","editorRef","useRef","shouldDeleteOneMoreBackwards","shouldDeleteOneMoreForwards","handleUpdateHTML","useCallback","html","current","newInnerHTML","convertEmojisToUnicode","convertTextToHTML","innerHTML","saveSelection","shouldIgnoreEmptyTextNodes","restoreSelection","handleInput","event","preventDefault","stopPropagation","document","execCommand","text","convertHTMLToText","handleKeyDown","shiftKey","isPropagationStopped","charCodeThatWillBeDeleted","getCharCodeThatWillBeDeleted","handlePaste","clipboardData","getData","insertTextAtCursorPosition","editorElement","newEvent","Event","bubbles","dispatchEvent","handlePopupSelect","emoji","useEffect","handlePreventLoseFocus","_element$parentElemen","_element$parentElemen2","element","target","classList","contains","parentElement","body","addEventListener","removeEventListener","createElement","StyledEmojiInput","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","id","onPaste","ref","alignment","onSelect","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ClipboardEvent,\n FC,\n FocusEventHandler,\n KeyboardEvent,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { PopupAlignment } from '../../constants/alignment';\nimport { convertEmojisToUnicode } from '../../utils/emoji';\nimport { getIsMobile } from '../../utils/environment';\nimport { insertTextAtCursorPosition } from '../../utils/insert';\nimport {\n getCharCodeThatWillBeDeleted,\n restoreSelection,\n saveSelection,\n} from '../../utils/selection';\nimport { convertHTMLToText, convertTextToHTML } from '../../utils/text';\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 * HTML id of the input element\n */\n inputId?: 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 input field loses focus.\n */\n onBlur?: FocusEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the input field gets the focus.\n */\n onFocus?: FocusEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the text of the input changes. In addition to the original\n * event, the original text is returned as second parameter, in which the internally used HTML\n * elements have been converted back to BB codes.\n */\n onInput?: (event: ChangeEvent<HTMLDivElement>, originalText: string) => void;\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 * Prevents the EmojiPickerPopup icon from being displayed\n */\n shouldPreventEmojiPicker?: boolean;\n /**\n * The plain text value of the input field. Instead of HTML elements BB codes must be used at\n * this point. These are then converted by the input field into corresponding HTML elements.\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n accessToken,\n inputId,\n isDisabled,\n onBlur,\n onFocus,\n onInput,\n onKeyDown,\n onPopupVisibilityChange,\n personId,\n placeholder,\n popupAlignment,\n rightElement,\n shouldPreventEmojiPicker,\n value,\n}) => {\n const [isMobile] = useState(getIsMobile());\n const [plainTextValue, setPlainTextValue] = useState(value);\n\n const editorRef = useRef<HTMLDivElement>(null);\n\n const shouldDeleteOneMoreBackwards = useRef(false);\n const shouldDeleteOneMoreForwards = useRef(false);\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 handleUpdateHTML = useCallback((html: string) => {\n if (!editorRef.current) {\n return;\n }\n\n let newInnerHTML = convertEmojisToUnicode(html);\n\n newInnerHTML = convertTextToHTML(newInnerHTML);\n\n if (newInnerHTML !== editorRef.current.innerHTML) {\n saveSelection(editorRef.current, { shouldIgnoreEmptyTextNodes: true });\n\n editorRef.current.innerHTML = newInnerHTML;\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 if (shouldDeleteOneMoreBackwards.current) {\n shouldDeleteOneMoreBackwards.current = false;\n shouldDeleteOneMoreForwards.current = false;\n\n event.preventDefault();\n event.stopPropagation();\n\n document.execCommand('delete', false);\n\n return;\n }\n\n if (shouldDeleteOneMoreForwards.current) {\n shouldDeleteOneMoreBackwards.current = false;\n shouldDeleteOneMoreForwards.current = false;\n\n event.preventDefault();\n event.stopPropagation();\n\n document.execCommand('forwardDelete', false);\n\n return;\n }\n\n handleUpdateHTML(editorRef.current.innerHTML);\n\n const text = convertHTMLToText(editorRef.current.innerHTML);\n\n setPlainTextValue(text);\n\n if (typeof onInput === 'function') {\n onInput(event, text);\n }\n },\n [handleUpdateHTML, onInput]\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (typeof onKeyDown === 'function') {\n onKeyDown(event);\n }\n\n if (\n event.key === 'Enter' &&\n !event.shiftKey &&\n !event.isPropagationStopped() &&\n editorRef.current\n ) {\n event.preventDefault();\n\n document.execCommand('insertLineBreak', false);\n }\n\n if (event.key === 'Backspace' || event.key === 'Delete') {\n const charCodeThatWillBeDeleted = getCharCodeThatWillBeDeleted(event);\n\n if (charCodeThatWillBeDeleted === 8203) {\n if (event.key === 'Backspace') {\n shouldDeleteOneMoreBackwards.current = true;\n } else {\n shouldDeleteOneMoreForwards.current = true;\n }\n }\n }\n },\n [onKeyDown]\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 let text = event.clipboardData.getData('text/plain');\n\n text = convertEmojisToUnicode(text);\n\n insertTextAtCursorPosition({ editorElement: editorRef.current, text });\n\n const newEvent = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(newEvent);\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 useEffect(() => {\n if (value !== plainTextValue) {\n setPlainTextValue(value);\n\n handleUpdateHTML(value);\n }\n }, [handleUpdateHTML, plainTextValue, value]);\n\n useEffect(() => {\n /**\n * This function ensures that the input field does not lose focus when the popup is opened\n * or an 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\n * field to lose focus.\n */\n const handlePreventLoseFocus = (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 element.parentElement?.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, []);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled}>\n <StyledEmojiInputContent isRightElementGiven={!!rightElement}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n id={inputId}\n onBlur={onBlur}\n onFocus={onFocus}\n onInput={handleInput}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={editorRef}\n />\n {!isMobile && !shouldPreventEmojiPicker && (\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;AAcA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,KAAA,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,CAAA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CAAC/F,WAAA,CAAAgG,gBAAgB;IAACrE,UAAU,EAAEA;EAAW,gBACrCrC,MAAA,CAAAa,OAAA,CAAA4F,aAAA,CAAC/F,WAAA,CAAAiG,uBAAuB;IAACC,mBAAmB,EAAE,CAAC,CAAC9D;EAAa,gBACzD9C,MAAA,CAAAa,OAAA,CAAA4F,aAAA,CAAC/F,WAAA,CAAAmG,sBAAsB;IACnBC,eAAe,EAAE,CAACzE,UAAW;IAC7B0E,EAAE,EAAE3E,OAAQ;IACZE,MAAM,EAAEA,MAAO;IACfC,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAE6B,WAAY;IACrB5B,SAAS,EAAEoC,aAAc;IACzBmC,OAAO,EAAE9B,WAAY;IACrBtC,WAAW,EAAEA,WAAY;IACzBqE,GAAG,EAAE3D;EAAU,CAClB,CAAC,EACD,CAACL,QAAQ,IAAI,CAACF,wBAAwB,iBACnC/C,MAAA,CAAAa,OAAA,CAAA4F,aAAA,CAACjG,iBAAA,CAAAK,OAAgB;IACbsB,WAAW,EAAEA,WAAY;IACzB+E,SAAS,EAAErE,cAAe;IAC1BsE,QAAQ,EAAExB,iBAAkB;IAC5BjD,uBAAuB,EAAEA,uBAAwB;IACjDC,QAAQ,EAAEA;EAAS,CACtB,CAEgB,CAAC,EACzBG,YAAY,iBACT9C,MAAA,CAAAa,OAAA,CAAA4F,aAAA,CAAC/F,WAAA,CAAA0G,4BAA4B,QAAEtE,YAA2C,CAEhE,CAAC;AAE3B,CAAC;AAEDb,UAAU,CAACoF,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvBrF,UAAU;AAAAsF,OAAA,CAAA1G,OAAA,GAAAyG,QAAA"}
|
|
1
|
+
{"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_insert","_selection","_text","_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","inputId","isDisabled","onBlur","onFocus","onInput","onKeyDown","onPopupVisibilityChange","personId","placeholder","popupAlignment","rightElement","shouldPreventEmojiPicker","value","isMobile","useState","getIsMobile","plainTextValue","setPlainTextValue","width","setWidth","editorRef","useRef","wrapperRef","shouldDeleteOneMoreBackwards","shouldDeleteOneMoreForwards","handleUpdateHTML","useCallback","html","current","newInnerHTML","convertEmojisToUnicode","convertTextToHTML","innerHTML","saveSelection","shouldIgnoreEmptyTextNodes","restoreSelection","handleInput","event","preventDefault","stopPropagation","document","execCommand","text","convertHTMLToText","handleKeyDown","shiftKey","isPropagationStopped","charCodeThatWillBeDeleted","getCharCodeThatWillBeDeleted","handlePaste","clipboardData","getData","insertTextAtCursorPosition","editorElement","newEvent","Event","bubbles","dispatchEvent","handlePopupSelect","emoji","useEffect","handlePreventLoseFocus","_element$parentElemen","_element$parentElemen2","element","target","classList","contains","parentElement","body","addEventListener","removeEventListener","offsetWidth","createElement","StyledEmojiInput","ref","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","id","onPaste","alignment","onSelect","parentWidth","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ClipboardEvent,\n FC,\n FocusEventHandler,\n KeyboardEvent,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { PopupAlignment } from '../../constants/alignment';\nimport { convertEmojisToUnicode } from '../../utils/emoji';\nimport { getIsMobile } from '../../utils/environment';\nimport { insertTextAtCursorPosition } from '../../utils/insert';\nimport {\n getCharCodeThatWillBeDeleted,\n restoreSelection,\n saveSelection,\n} from '../../utils/selection';\nimport { convertHTMLToText, convertTextToHTML } from '../../utils/text';\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 * HTML id of the input element\n */\n inputId?: 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 input field loses focus.\n */\n onBlur?: FocusEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the input field gets the focus.\n */\n onFocus?: FocusEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the text of the input changes. In addition to the original\n * event, the original text is returned as second parameter, in which the internally used HTML\n * elements have been converted back to BB codes.\n */\n onInput?: (event: ChangeEvent<HTMLDivElement>, originalText: string) => void;\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 * Prevents the EmojiPickerPopup icon from being displayed\n */\n shouldPreventEmojiPicker?: boolean;\n /**\n * The plain text value of the input field. Instead of HTML elements BB codes must be used at\n * this point. These are then converted by the input field into corresponding HTML elements.\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n accessToken,\n inputId,\n isDisabled,\n onBlur,\n onFocus,\n onInput,\n onKeyDown,\n onPopupVisibilityChange,\n personId,\n placeholder,\n popupAlignment,\n rightElement,\n shouldPreventEmojiPicker,\n value,\n}) => {\n const [isMobile] = useState(getIsMobile());\n const [plainTextValue, setPlainTextValue] = useState(value);\n const [width, setWidth] = useState(0);\n\n const editorRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const shouldDeleteOneMoreBackwards = useRef(false);\n const shouldDeleteOneMoreForwards = useRef(false);\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 handleUpdateHTML = useCallback((html: string) => {\n if (!editorRef.current) {\n return;\n }\n\n let newInnerHTML = convertEmojisToUnicode(html);\n\n newInnerHTML = convertTextToHTML(newInnerHTML);\n\n if (newInnerHTML !== editorRef.current.innerHTML) {\n saveSelection(editorRef.current, { shouldIgnoreEmptyTextNodes: true });\n\n editorRef.current.innerHTML = newInnerHTML;\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 if (shouldDeleteOneMoreBackwards.current) {\n shouldDeleteOneMoreBackwards.current = false;\n shouldDeleteOneMoreForwards.current = false;\n\n event.preventDefault();\n event.stopPropagation();\n\n document.execCommand('delete', false);\n\n return;\n }\n\n if (shouldDeleteOneMoreForwards.current) {\n shouldDeleteOneMoreBackwards.current = false;\n shouldDeleteOneMoreForwards.current = false;\n\n event.preventDefault();\n event.stopPropagation();\n\n document.execCommand('forwardDelete', false);\n\n return;\n }\n\n handleUpdateHTML(editorRef.current.innerHTML);\n\n const text = convertHTMLToText(editorRef.current.innerHTML);\n\n setPlainTextValue(text);\n\n if (typeof onInput === 'function') {\n onInput(event, text);\n }\n },\n [handleUpdateHTML, onInput]\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (typeof onKeyDown === 'function') {\n onKeyDown(event);\n }\n\n if (\n event.key === 'Enter' &&\n !event.shiftKey &&\n !event.isPropagationStopped() &&\n editorRef.current\n ) {\n event.preventDefault();\n\n document.execCommand('insertLineBreak', false);\n }\n\n if (event.key === 'Backspace' || event.key === 'Delete') {\n const charCodeThatWillBeDeleted = getCharCodeThatWillBeDeleted(event);\n\n if (charCodeThatWillBeDeleted === 8203) {\n if (event.key === 'Backspace') {\n shouldDeleteOneMoreBackwards.current = true;\n } else {\n shouldDeleteOneMoreForwards.current = true;\n }\n }\n }\n },\n [onKeyDown]\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 let text = event.clipboardData.getData('text/plain');\n\n text = convertEmojisToUnicode(text);\n\n insertTextAtCursorPosition({ editorElement: editorRef.current, text });\n\n const newEvent = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(newEvent);\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 useEffect(() => {\n if (value !== plainTextValue) {\n setPlainTextValue(value);\n\n handleUpdateHTML(value);\n }\n }, [handleUpdateHTML, plainTextValue, value]);\n\n useEffect(() => {\n /**\n * This function ensures that the input field does not lose focus when the popup is opened\n * or an 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\n * field to lose focus.\n */\n const handlePreventLoseFocus = (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 element.parentElement?.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, []);\n\n useEffect(() => {\n if (wrapperRef.current) {\n setWidth(wrapperRef.current.offsetWidth);\n }\n }, []);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled} ref={wrapperRef}>\n <StyledEmojiInputContent isRightElementGiven={!!rightElement}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n id={inputId}\n onBlur={onBlur}\n onFocus={onFocus}\n onInput={handleInput}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={editorRef}\n width={width - 50}\n />\n {!isMobile && !shouldPreventEmojiPicker && (\n <EmojiPickerPopup\n accessToken={accessToken}\n alignment={popupAlignment}\n onSelect={handlePopupSelect}\n onPopupVisibilityChange={onPopupVisibilityChange}\n parentWidth={width}\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;AAcA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAA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G;EAAG,CACrB,CAAC,EACD,CAACL,QAAQ,IAAI,CAACF,wBAAwB,iBACnC/C,MAAA,CAAAa,OAAA,CAAAgG,aAAA,CAACrG,iBAAA,CAAAK,OAAgB;IACbsB,WAAW,EAAEA,WAAY;IACzBmF,SAAS,EAAEzE,cAAe;IAC1B0E,QAAQ,EAAEzB,iBAAkB;IAC5BpD,uBAAuB,EAAEA,uBAAwB;IACjD8E,WAAW,EAAElE,KAAM;IACnBX,QAAQ,EAAEA;EAAS,CACtB,CAEgB,CAAC,EACzBG,YAAY,iBACT9C,MAAA,CAAAa,OAAA,CAAAgG,aAAA,CAACnG,WAAA,CAAA+G,4BAA4B,QAAE3E,YAA2C,CAEhE,CAAC;AAE3B,CAAC;AAEDb,UAAU,CAACyF,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvB1F,UAAU;AAAA2F,OAAA,CAAA/G,OAAA,GAAA8G,QAAA"}
|
|
@@ -6,7 +6,10 @@ type StyledEmojiInputContentProps = {
|
|
|
6
6
|
isRightElementGiven: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare const StyledEmojiInputContent: import("styled-components").StyledComponent<"div", any, StyledEmojiInputContentProps, never>;
|
|
9
|
-
export declare const StyledEmojiInputEditor: import("styled-components").StyledComponent<"div", any,
|
|
9
|
+
export declare const StyledEmojiInputEditor: import("styled-components").StyledComponent<"div", any, {
|
|
10
|
+
width: number;
|
|
11
|
+
placeholder: EmojiInputProps['placeholder'];
|
|
12
|
+
} & {
|
|
10
13
|
theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
|
|
11
14
|
}, never>;
|
|
12
15
|
export declare const StyledEmojiInputRightWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -31,7 +31,7 @@ const StyledEmojiInput = _styledComponents.default.div`
|
|
|
31
31
|
} = _ref3;
|
|
32
32
|
return isDisabled ? 'none' : 'initial';
|
|
33
33
|
}};
|
|
34
|
-
position: relative;
|
|
34
|
+
//position: relative;
|
|
35
35
|
transition: opacity 0.3s ease;
|
|
36
36
|
`;
|
|
37
37
|
exports.StyledEmojiInput = StyledEmojiInput;
|
|
@@ -69,6 +69,12 @@ const StyledEmojiInputEditor = _styledComponents.default.div`
|
|
|
69
69
|
max-height: 210px;
|
|
70
70
|
overflow-y: scroll;
|
|
71
71
|
word-break: break-word;
|
|
72
|
+
max-width: ${_ref6 => {
|
|
73
|
+
let {
|
|
74
|
+
width
|
|
75
|
+
} = _ref6;
|
|
76
|
+
return width;
|
|
77
|
+
}}px;
|
|
72
78
|
|
|
73
79
|
// This fixes a bug where the field is not editable in certain browsers.
|
|
74
80
|
// This is for example the case on iOS 15 or older.
|
|
@@ -76,16 +82,16 @@ const StyledEmojiInputEditor = _styledComponents.default.div`
|
|
|
76
82
|
-webkit-user-select: text;
|
|
77
83
|
|
|
78
84
|
&:empty:not(:focus):before {
|
|
79
|
-
content: '${
|
|
85
|
+
content: '${_ref7 => {
|
|
80
86
|
let {
|
|
81
87
|
placeholder
|
|
82
|
-
} =
|
|
88
|
+
} = _ref7;
|
|
83
89
|
return placeholder;
|
|
84
90
|
}}';
|
|
85
|
-
color: ${
|
|
91
|
+
color: ${_ref8 => {
|
|
86
92
|
let {
|
|
87
93
|
theme
|
|
88
|
-
} =
|
|
94
|
+
} = _ref8;
|
|
89
95
|
return theme['006'];
|
|
90
96
|
}};
|
|
91
97
|
pointer-events: none;
|
|
@@ -115,10 +121,10 @@ const StyledEmojiInputEditor = _styledComponents.default.div`
|
|
|
115
121
|
|
|
116
122
|
::-webkit-scrollbar-thumb {
|
|
117
123
|
background-color: rgba(
|
|
118
|
-
${
|
|
124
|
+
${_ref9 => {
|
|
119
125
|
let {
|
|
120
126
|
theme
|
|
121
|
-
} =
|
|
127
|
+
} = _ref9;
|
|
122
128
|
return theme['text-rgb'];
|
|
123
129
|
}},
|
|
124
130
|
0.15
|
|
@@ -130,10 +136,10 @@ const StyledEmojiInputEditor = _styledComponents.default.div`
|
|
|
130
136
|
// only supported in Firefox:
|
|
131
137
|
* {
|
|
132
138
|
scrollbar-color: rgba(
|
|
133
|
-
${
|
|
139
|
+
${_ref10 => {
|
|
134
140
|
let {
|
|
135
141
|
theme
|
|
136
|
-
} =
|
|
142
|
+
} = _ref10;
|
|
137
143
|
return theme['text-rgb'];
|
|
138
144
|
}},
|
|
139
145
|
0.15
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiInput.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_font","_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","getFontFamily","_ref6","
|
|
1
|
+
{"version":3,"file":"EmojiInput.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_font","_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","getFontFamily","_ref6","width","_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 { getFontFamily } from '../../utils/font';\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 padding-right: 0;\n `}\n`;\n\ntype StyledEmojiInputEditorProps = WithTheme<{\n width: number;\n placeholder: EmojiInputProps['placeholder'];\n}>;\n\nexport const StyledEmojiInputEditor = styled.div<StyledEmojiInputEditorProps>`\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme.text};\n flex: 1 1 auto;\n font-family: ${getFontFamily};\n max-height: 210px;\n overflow-y: scroll;\n word-break: break-word;\n max-width: ${({ width }) => width}px;\n\n // This fixes a bug where the field is not editable in certain browsers.\n // This is for example the case on iOS 15 or older.\n -webkit-user-modify: read-write;\n -webkit-user-select: text;\n\n &:empty:not(:focus):before {\n content: '${({ placeholder }) => placeholder}';\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme['006']};\n pointer-events: none;\n }\n\n lc_mention {\n font-weight: bold;\n\n span {\n opacity: 0.5;\n }\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;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAiD,SAAAE,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,SAAAJ,wBAAAQ,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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ACA,mBAAmBC,mBAAc;AACjC;AACA;AACA;AACA,iBAAiBC,KAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK;AAAA,CAAC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoBC,KAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,KAAA;EAAA,OAAKC,WAAW;AAAA,CAAC;AACrD,iBAAiBC,KAAA;EAAA,IAAC;IAAEjB;EAAmC,CAAC,GAAAiB,KAAA;EAAA,OAAKjB,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAckB,KAAA;EAAA,IAAC;IAAElB;EAAmC,CAAC,GAAAkB,KAAA;EAAA,OAAKlB,KAAK,CAAC,UAAU,CAAC;AAAA,CAAC;AAC5E;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"}
|
|
@@ -25,6 +25,10 @@ export type EmojiPickerPopupProps = {
|
|
|
25
25
|
* @param {string} emoji - Emoji that was selected
|
|
26
26
|
*/
|
|
27
27
|
onSelect: (emoji: string) => void;
|
|
28
|
+
/**
|
|
29
|
+
* The width of the parent element.
|
|
30
|
+
*/
|
|
31
|
+
parentWidth: number;
|
|
28
32
|
};
|
|
29
33
|
export type PopupPosition = {
|
|
30
34
|
bottom?: number;
|
|
@@ -20,7 +20,8 @@ const EmojiPickerPopup = _ref => {
|
|
|
20
20
|
alignment,
|
|
21
21
|
onPopupVisibilityChange,
|
|
22
22
|
onSelect,
|
|
23
|
-
personId
|
|
23
|
+
personId,
|
|
24
|
+
parentWidth
|
|
24
25
|
} = _ref;
|
|
25
26
|
const [internalAlignment, setInternalAlignment] = (0, _react.useState)(_alignment.PopupAlignment.TopLeft);
|
|
26
27
|
const [shouldShowPopup, setShouldShowPopup] = (0, _react.useState)(false);
|
|
@@ -111,7 +112,9 @@ const EmojiPickerPopup = _ref => {
|
|
|
111
112
|
}
|
|
112
113
|
}, [onPopupVisibilityChange, shouldShowPopup]);
|
|
113
114
|
const exitAndInitialY = internalAlignment === _alignment.PopupAlignment.TopLeft || internalAlignment === _alignment.PopupAlignment.TopRight ? -16 : 16;
|
|
114
|
-
return /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledEmojiPickerPopup,
|
|
115
|
+
return /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledEmojiPickerPopup, {
|
|
116
|
+
width: parentWidth - 40
|
|
117
|
+
}, /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
|
|
115
118
|
initial: false
|
|
116
119
|
}, shouldShowPopup && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledMotionEmojiPickerPopupContent, {
|
|
117
120
|
alignment: internalAlignment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiPickerPopup.js","names":["_core","require","_framerMotion","_react","_interopRequireWildcard","_alignment","_EmojiPicker","_interopRequireDefault","_EmojiPicker2","_EmojiPickerPopup","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","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","Icon","className","icons","onClick","size","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker-popup/EmojiPickerPopup.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\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,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AAGmC,SAAAM,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA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E;IAAE,CAAE;IAC9BC,IAAI,EAAE;MAAEF,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAER;IAAgB,CAAE;IACzCI,OAAO,EAAE;MAAEG,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAER;IAAgB,CAAE;IAC5CpD,GAAG,EAAC,yBAAyB;IAC7B8D,GAAG,EAAExC,UAAW;IAChByC,KAAK,EAAE3C,QAAS;IAChB4C,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9BxF,MAAA,CAAAS,OAAA,CAAAmE,aAAA,CAACzE,YAAA,CAAAM,OAAW;IACRsB,WAAW,EAAEA,WAAY;IACzBG,QAAQ,EAAEA,QAAS;IACnBC,QAAQ,EAAEA;EAAS,CACtB,CACgC,CAE5B,CAAC,eAClBnC,MAAA,CAAAS,OAAA,CAAAmE,aAAA,CAAC/E,KAAA,CAAA4F,IAAI;IACDC,SAAS,EAAC,oBAAoB;IAC9BC,KAAK,EAAE,CAAC,cAAc,CAAE;IACxBC,OAAO,EAAEnC,oBAAqB;IAC9BoC,IAAI,EAAE;EAAG,CACZ,CACmB,CAAC;AAEjC,CAAC;AAEDhE,gBAAgB,CAACiE,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnClE,gBAAgB;AAAAmE,OAAA,CAAAvF,OAAA,GAAAsF,QAAA"}
|
|
1
|
+
{"version":3,"file":"EmojiPickerPopup.js","names":["_core","require","_framerMotion","_react","_interopRequireWildcard","_alignment","_EmojiPicker","_interopRequireDefault","_EmojiPicker2","_EmojiPickerPopup","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerPopup","_ref","accessToken","alignment","onPopupVisibilityChange","onSelect","personId","parentWidth","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","Icon","className","icons","onClick","size","displayName","_default","exports"],"sources":["../../../src/components/emoji-picker-popup/EmojiPickerPopup.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\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 * The width of the parent element.\n */\n parentWidth: number;\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 parentWidth,\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 width={parentWidth - 40}>\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,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AAGmC,SAAAM,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA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AAE,CAAC;MAAEC,CAAC,EAAE;IAAE,CAAE;IAC9BC,IAAI,EAAE;MAAEF,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAER;IAAgB,CAAE;IACzCI,OAAO,EAAE;MAAEG,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAER;IAAgB,CAAE;IAC5CrD,GAAG,EAAC,yBAAyB;IAC7B+D,GAAG,EAAExC,UAAW;IAChByC,KAAK,EAAE3C,QAAS;IAChB4C,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9BzF,MAAA,CAAAS,OAAA,CAAAoE,aAAA,CAAC1E,YAAA,CAAAM,OAAW;IACRsB,WAAW,EAAEA,WAAY;IACzBG,QAAQ,EAAEA,QAAS;IACnBC,QAAQ,EAAEA;EAAS,CACtB,CACgC,CAE5B,CAAC,eAClBnC,MAAA,CAAAS,OAAA,CAAAoE,aAAA,CAAChF,KAAA,CAAA6F,IAAI;IACDC,SAAS,EAAC,oBAAoB;IAC9BC,KAAK,EAAE,CAAC,cAAc,CAAE;IACxBC,OAAO,EAAEnC,oBAAqB;IAC9BoC,IAAI,EAAE;EAAG,CACZ,CACmB,CAAC;AAEjC,CAAC;AAEDjE,gBAAgB,CAACkE,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnCnE,gBAAgB;AAAAoE,OAAA,CAAAxF,OAAA,GAAAuF,QAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { PopupAlignment } from '../../constants/alignment';
|
|
2
|
-
export declare const StyledEmojiPickerPopup: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
export declare const StyledEmojiPickerPopup: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
width: number;
|
|
4
|
+
} & {
|
|
5
|
+
theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
|
|
6
|
+
}, never>;
|
|
3
7
|
export declare const StyledMotionEmojiPickerPopupContent: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {
|
|
4
8
|
alignment: PopupAlignment;
|
|
5
9
|
} & {
|
|
@@ -13,23 +13,29 @@ const StyledEmojiPickerPopup = _styledComponents.default.div`
|
|
|
13
13
|
align-items: center;
|
|
14
14
|
display: flex;
|
|
15
15
|
height: ${() => getComputedStyle(document.body).getPropertyValue('line-height')};
|
|
16
|
-
position:
|
|
16
|
+
position: absolute;
|
|
17
|
+
translate: ${_ref => {
|
|
18
|
+
let {
|
|
19
|
+
width
|
|
20
|
+
} = _ref;
|
|
21
|
+
return width;
|
|
22
|
+
}}px;
|
|
17
23
|
`;
|
|
18
24
|
exports.StyledEmojiPickerPopup = StyledEmojiPickerPopup;
|
|
19
25
|
const StyledMotionEmojiPickerPopupContent = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
20
|
-
background-color: ${
|
|
26
|
+
background-color: ${_ref2 => {
|
|
21
27
|
let {
|
|
22
28
|
theme
|
|
23
|
-
} =
|
|
29
|
+
} = _ref2;
|
|
24
30
|
return theme['001'];
|
|
25
31
|
}};
|
|
26
32
|
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
27
33
|
border-radius: 3px;
|
|
28
34
|
box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);
|
|
29
|
-
color: ${
|
|
35
|
+
color: ${_ref3 => {
|
|
30
36
|
let {
|
|
31
37
|
theme
|
|
32
|
-
} =
|
|
38
|
+
} = _ref3;
|
|
33
39
|
return theme.text;
|
|
34
40
|
}};
|
|
35
41
|
position: absolute;
|
|
@@ -47,10 +53,10 @@ const StyledMotionEmojiPickerPopupContent = (0, _styledComponents.default)(_fram
|
|
|
47
53
|
width: 14px;
|
|
48
54
|
z-index: -2;
|
|
49
55
|
|
|
50
|
-
${
|
|
56
|
+
${_ref4 => {
|
|
51
57
|
let {
|
|
52
58
|
alignment
|
|
53
|
-
} =
|
|
59
|
+
} = _ref4;
|
|
54
60
|
switch (alignment) {
|
|
55
61
|
case _alignment.PopupAlignment.TopLeft:
|
|
56
62
|
return (0, _styledComponents.css)`
|
|
@@ -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","motion","
|
|
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","_ref","width","exports","StyledMotionEmojiPickerPopupContent","motion","_ref2","theme","_ref3","text","_ref4","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\ntype StyledEmojiPickerPopupProps = WithTheme<{ width: number }>;\n\nexport const StyledEmojiPickerPopup = styled.div<StyledEmojiPickerPopupProps>`\n align-items: center;\n display: flex;\n height: ${() => getComputedStyle(document.body).getPropertyValue('line-height')};\n position: absolute;\n translate: ${({ width }) => width}px;\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: 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 ${({ 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,IAAA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,wBAAwBU,KAAA;EAAA,IAAC;IAAEC;EAAgD,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC9F;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAED;EAAgD,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK,CAACE,IAAI;AAAA,CAAC;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUC,KAAA,IAAmB;EAAA,IAAlB;IAAEC;EAAU,CAAC,GAAAD,KAAA;EACZ,QAAQC,SAAS;IACb,KAAKC,yBAAc,CAACC,OAAO;MACvB,OAAO,IAAAC,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,yBAAc,CAACG,UAAU;MAC1B,OAAO,IAAAD,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,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;EACxB;AACJ,CAAE;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACf,OAAA,CAAAC,mCAAA,GAAAA,mCAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/emoji-input",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.222",
|
|
4
4
|
"description": "Input field that supports HTML elements and emojis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chayns",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "49b9e6422041f5af4227a480f9efd2af1fe01bd5"
|
|
73
73
|
}
|