@chayns-components/emoji-input 5.0.0-beta.72 → 5.0.0-beta.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- import { ChangeEventHandler, FC } from 'react';
1
+ import { ChangeEventHandler, FC, ReactNode } from 'react';
2
+ import type { PopupAlignment } from '../../constants/alignment';
2
3
  export type EmojiInputProps = {
3
4
  /**
4
5
  * Disables the input so that it cannot be changed anymore
@@ -17,6 +18,16 @@ export type EmojiInputProps = {
17
18
  * Placeholder for the input field
18
19
  */
19
20
  placeholder?: string;
21
+ /**
22
+ * Sets the alignment of the popup to a fixed value. If this value is not set, the component
23
+ * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this
24
+ * value.
25
+ */
26
+ popupAlignment?: PopupAlignment;
27
+ /**
28
+ * Element that is rendered inside the EmojiInput on the right side.
29
+ */
30
+ rightElement?: ReactNode;
20
31
  /**
21
32
  * Value of the input field
22
33
  */
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _emoji = require("../../utils/emoji");
9
+ var _environment = require("../../utils/environment");
9
10
  var _selection = require("../../utils/selection");
10
11
  var _EmojiPickerPopup = _interopRequireDefault(require("../emoji-picker-popup/EmojiPickerPopup"));
11
12
  var _EmojiInput = require("./EmojiInput.styles");
@@ -18,8 +19,11 @@ const EmojiInput = _ref => {
18
19
  onInput,
19
20
  onPopupVisibilityChange,
20
21
  placeholder,
22
+ popupAlignment,
23
+ rightElement,
21
24
  value
22
25
  } = _ref;
26
+ const [isMobile] = (0, _react.useState)((0, _environment.getIsMobile)());
23
27
  const editorRef = (0, _react.useRef)(null);
24
28
 
25
29
  /**
@@ -81,11 +85,15 @@ const EmojiInput = _ref => {
81
85
  } = selection.getRangeAt(0);
82
86
  const rangeDistance = endOffset - startOffset;
83
87
  let offset = endOffset + emoji.length - rangeDistance;
84
- const {
88
+ let {
85
89
  anchorNode
86
90
  } = selection;
87
91
  if (anchorNode.nodeValue) {
88
92
  anchorNode.nodeValue = anchorNode.nodeValue.substring(0, startOffset) + emoji + anchorNode.nodeValue.substring(endOffset);
93
+ } else if (anchorNode === editorRef.current) {
94
+ const newTextNode = document.createTextNode(emoji);
95
+ editorRef.current.appendChild(newTextNode);
96
+ anchorNode = newTextNode;
89
97
  }
90
98
  const newRange = document.createRange();
91
99
  if (anchorNode.nodeValue) {
@@ -131,14 +139,18 @@ const EmojiInput = _ref => {
131
139
  }, [handlePreventLoseFocus]);
132
140
  return /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInput, {
133
141
  isDisabled: isDisabled
142
+ }, /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputContent, {
143
+ isRightElementGiven: !!rightElement
134
144
  }, /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputEditor, {
135
145
  contentEditable: !isDisabled,
136
146
  onInput: handleInput,
137
147
  placeholder: placeholder,
138
148
  ref: editorRef
139
- }), /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.default, {
140
- onSelect: handlePopupSelect
141
- }));
149
+ }), !isMobile && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.default, {
150
+ alignment: popupAlignment,
151
+ onSelect: handlePopupSelect,
152
+ onPopupVisibilityChange: onPopupVisibilityChange
153
+ })), rightElement && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputRightWrapper, null, rightElement));
142
154
  };
143
155
  EmojiInput.displayName = 'EmojiInput';
144
156
  var _default = EmojiInput;
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_selection","_EmojiPickerPopup","_interopRequireDefault","_EmojiInput","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiInput","_ref","isDisabled","onInput","onPopupVisibilityChange","placeholder","value","editorRef","useRef","handleUpdateText","useCallback","text","current","newHtml","convertAsciiToUnicode","innerHTML","saveSelection","restoreSelection","handleInput","event","handlePopupSelect","emoji","selection","window","getSelection","anchorNode","contains","endOffset","startOffset","getRangeAt","rangeDistance","offset","length","nodeValue","substring","newRange","document","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","StyledEmojiInputEditor","contentEditable","ref","onSelect","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, { ChangeEvent, ChangeEventHandler, FC, useCallback, useEffect, useRef } from 'react';\nimport { convertAsciiToUnicode } from '../../utils/emoji';\nimport { restoreSelection, saveSelection } from '../../utils/selection';\nimport EmojiPickerPopup from '../emoji-picker-popup/EmojiPickerPopup';\nimport { StyledEmojiInput, StyledEmojiInputEditor } from './EmojiInput.styles';\n\nexport type EmojiInputProps = {\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled: boolean;\n /**\n * Function that is executed when the text of the input changes\n */\n onInput?: ChangeEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the visibility of the popup changes.\n * @param {boolean} isVisible - Whether the popup is visible or not\n */\n onPopupVisibilityChange?: (isVisible: boolean) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Value of the input field\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n isDisabled,\n onInput,\n onPopupVisibilityChange,\n placeholder,\n value,\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n\n /**\n * This function updates the content of the 'contentEditable' element if the new text is\n * different from the previous content. So this is only true if, for example, a text like \":-)\"\n * has been replaced to the corresponding emoji.\n *\n * When updating the HTML, the current cursor position is saved before replacing the content, so\n * that it can be set again afterward.\n */\n const handleUpdateText = useCallback((text: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const newHtml = convertAsciiToUnicode(text);\n\n if (newHtml !== editorRef.current.innerHTML) {\n saveSelection(editorRef.current);\n\n editorRef.current.innerHTML = newHtml;\n\n restoreSelection(editorRef.current);\n }\n }, []);\n\n /**\n * This function handles the 'input' events of the 'contentEditable' element and also passes the\n * respective event up accordingly if the 'onInput' property is a function.\n */\n const handleInput = useCallback(\n (event: ChangeEvent<HTMLDivElement>) => {\n if (!editorRef.current) {\n return;\n }\n\n handleUpdateText(editorRef.current.innerHTML);\n\n if (typeof onInput === 'function') {\n onInput(event);\n }\n },\n [handleUpdateText, onInput]\n );\n\n /**\n * This function processes the selection of an emoji via the popup. If the 'contentEditable'\n * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji\n * will be appended to the back of the input field content.\n *\n * In addition, this function also sets the cursor to the correct position when the input field\n * has the focus. For this purpose, the current position of the cursor or a selection is read to\n * calculate the cursor position after inserting the emoji.\n *\n * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,\n * which in turn executes the 'onInput' function from the props. So this serves to ensure that\n * the event is also passed through to the top when inserting via the popup.\n */\n const handlePopupSelect = useCallback((emoji: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const selection = window.getSelection();\n\n if (selection?.anchorNode && editorRef.current.contains(selection.anchorNode)) {\n const { endOffset, startOffset } = selection.getRangeAt(0);\n\n const rangeDistance = endOffset - startOffset;\n\n let offset = endOffset + emoji.length - rangeDistance;\n\n const { anchorNode } = selection;\n\n if (anchorNode.nodeValue) {\n anchorNode.nodeValue =\n anchorNode.nodeValue.substring(0, startOffset) +\n emoji +\n anchorNode.nodeValue.substring(endOffset);\n }\n\n const newRange = document.createRange();\n\n if (anchorNode.nodeValue) {\n offset = Math.min(offset, anchorNode.nodeValue.length);\n }\n\n newRange.setStart(anchorNode, offset);\n newRange.setEnd(anchorNode, offset);\n\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n editorRef.current.innerHTML += emoji;\n }\n\n const event = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(event);\n }, []);\n\n /**\n * This function ensures that the input field does not lose focus when the popup is opened or an\n * emoji is selected in it. For this purpose the corresponding elements get the class\n * 'prevent-lose-focus'.\n *\n * The class can also be set to any other elements that should also not cause the input field to\n * lose focus.\n */\n const handlePreventLoseFocus = useCallback((event: MouseEvent) => {\n const element = event.target as Element;\n\n if (\n element.classList.contains('prevent-lose-focus') ||\n element.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n }, []);\n\n useEffect(() => {\n handleUpdateText(value);\n }, [handleUpdateText, value]);\n\n useEffect(() => {\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, [handlePreventLoseFocus]);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n onInput={handleInput}\n placeholder={placeholder}\n ref={editorRef}\n />\n <EmojiPickerPopup onSelect={handlePopupSelect} />\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,UAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAA+E,SAAAI,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,YAAA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ildcard","require","_emoji","_environment","_selection","_EmojiPickerPopup","_interopRequireDefault","_EmojiInput","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiInput","_ref","isDisabled","onInput","onPopupVisibilityChange","placeholder","popupAlignment","rightElement","value","isMobile","useState","getIsMobile","editorRef","useRef","handleUpdateText","useCallback","text","current","newHtml","convertAsciiToUnicode","innerHTML","saveSelection","restoreSelection","handleInput","event","handlePopupSelect","emoji","selection","window","getSelection","anchorNode","contains","endOffset","startOffset","getRangeAt","rangeDistance","offset","length","nodeValue","substring","newTextNode","document","createTextNode","appendChild","newRange","createRange","Math","min","setStart","setEnd","removeAllRanges","addRange","Event","bubbles","dispatchEvent","handlePreventLoseFocus","_element$parentElemen","element","target","classList","parentElement","preventDefault","stopPropagation","useEffect","body","addEventListener","removeEventListener","createElement","StyledEmojiInput","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","ref","alignment","onSelect","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { PopupAlignment } from '../../constants/alignment';\nimport { convertAsciiToUnicode } from '../../utils/emoji';\nimport { getIsMobile } from '../../utils/environment';\nimport { restoreSelection, saveSelection } from '../../utils/selection';\nimport EmojiPickerPopup from '../emoji-picker-popup/EmojiPickerPopup';\nimport {\n StyledEmojiInput,\n StyledEmojiInputContent,\n StyledEmojiInputEditor,\n StyledEmojiInputRightWrapper,\n} from './EmojiInput.styles';\n\nexport type EmojiInputProps = {\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled: boolean;\n /**\n * Function that is executed when the text of the input changes\n */\n onInput?: ChangeEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the visibility of the popup changes.\n * @param {boolean} isVisible - Whether the popup is visible or not\n */\n onPopupVisibilityChange?: (isVisible: boolean) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Sets the alignment of the popup to a fixed value. If this value is not set, the component\n * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this\n * value.\n */\n popupAlignment?: PopupAlignment;\n /**\n * Element that is rendered inside the EmojiInput on the right side.\n */\n rightElement?: ReactNode;\n /**\n * Value of the input field\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n isDisabled,\n onInput,\n onPopupVisibilityChange,\n placeholder,\n popupAlignment,\n rightElement,\n value,\n}) => {\n const [isMobile] = useState(getIsMobile());\n\n const editorRef = useRef<HTMLDivElement>(null);\n\n /**\n * This function updates the content of the 'contentEditable' element if the new text is\n * different from the previous content. So this is only true if, for example, a text like \":-)\"\n * has been replaced to the corresponding emoji.\n *\n * When updating the HTML, the current cursor position is saved before replacing the content, so\n * that it can be set again afterward.\n */\n const handleUpdateText = useCallback((text: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const newHtml = convertAsciiToUnicode(text);\n\n if (newHtml !== editorRef.current.innerHTML) {\n saveSelection(editorRef.current);\n\n editorRef.current.innerHTML = newHtml;\n\n restoreSelection(editorRef.current);\n }\n }, []);\n\n /**\n * This function handles the 'input' events of the 'contentEditable' element and also passes the\n * respective event up accordingly if the 'onInput' property is a function.\n */\n const handleInput = useCallback(\n (event: ChangeEvent<HTMLDivElement>) => {\n if (!editorRef.current) {\n return;\n }\n\n handleUpdateText(editorRef.current.innerHTML);\n\n if (typeof onInput === 'function') {\n onInput(event);\n }\n },\n [handleUpdateText, onInput]\n );\n\n /**\n * This function processes the selection of an emoji via the popup. If the 'contentEditable'\n * element has the focus, the new emoji is inserted at the cursor position. If not, the emoji\n * will be appended to the back of the input field content.\n *\n * In addition, this function also sets the cursor to the correct position when the input field\n * has the focus. For this purpose, the current position of the cursor or a selection is read to\n * calculate the cursor position after inserting the emoji.\n *\n * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,\n * which in turn executes the 'onInput' function from the props. So this serves to ensure that\n * the event is also passed through to the top when inserting via the popup.\n */\n const handlePopupSelect = useCallback((emoji: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const selection = window.getSelection();\n\n if (selection?.anchorNode && editorRef.current.contains(selection.anchorNode)) {\n const { endOffset, startOffset } = selection.getRangeAt(0);\n\n const rangeDistance = endOffset - startOffset;\n\n let offset = endOffset + emoji.length - rangeDistance;\n\n let { anchorNode } = selection;\n\n if (anchorNode.nodeValue) {\n anchorNode.nodeValue =\n anchorNode.nodeValue.substring(0, startOffset) +\n emoji +\n anchorNode.nodeValue.substring(endOffset);\n } else if (anchorNode === editorRef.current) {\n const newTextNode = document.createTextNode(emoji);\n\n editorRef.current.appendChild(newTextNode);\n\n anchorNode = newTextNode;\n }\n\n const newRange = document.createRange();\n\n if (anchorNode.nodeValue) {\n offset = Math.min(offset, anchorNode.nodeValue.length);\n }\n\n newRange.setStart(anchorNode, offset);\n newRange.setEnd(anchorNode, offset);\n\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n editorRef.current.innerHTML += emoji;\n }\n\n const event = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(event);\n }, []);\n\n /**\n * This function ensures that the input field does not lose focus when the popup is opened or an\n * emoji is selected in it. For this purpose the corresponding elements get the class\n * 'prevent-lose-focus'.\n *\n * The class can also be set to any other elements that should also not cause the input field to\n * lose focus.\n */\n const handlePreventLoseFocus = useCallback((event: MouseEvent) => {\n const element = event.target as Element;\n\n if (\n element.classList.contains('prevent-lose-focus') ||\n element.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n }, []);\n\n useEffect(() => {\n handleUpdateText(value);\n }, [handleUpdateText, value]);\n\n useEffect(() => {\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, [handlePreventLoseFocus]);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled}>\n <StyledEmojiInputContent isRightElementGiven={!!rightElement}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n onInput={handleInput}\n placeholder={placeholder}\n ref={editorRef}\n />\n {!isMobile && (\n <EmojiPickerPopup\n alignment={popupAlignment}\n onSelect={handlePopupSelect}\n onPopupVisibilityChange={onPopupVisibilityChange}\n />\n )}\n </StyledEmojiInputContent>\n {rightElement && (\n <StyledEmojiInputRightWrapper>{rightElement}</StyledEmojiInputRightWrapper>\n )}\n </StyledEmojiInput>\n );\n};\n\nEmojiInput.displayName = 'EmojiInput';\n\nexport default EmojiInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAK6B,SAAAK,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAZ,wBAAAQ,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,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,QAAQ,EAAElD,iBAAkB;IAC5BrB,uBAAuB,EAAEA;EAAwB,EAExD,CACqB,EACzBG,YAAY,iBACTtC,MAAA,CAAAW,OAAA,CAAAuF,aAAA,CAAC1F,WAAA,CAAAmG,4BAA4B,QAAErE,YAAY,CAC9C,CACc;AAE3B,CAAC;AAEDP,UAAU,CAAC6E,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAEvB9E,UAAU;AAAA+E,OAAA,CAAAnG,OAAA,GAAAkG,QAAA"}
@@ -2,6 +2,12 @@ import type { EmojiInputProps } from './EmojiInput';
2
2
  export declare const StyledEmojiInput: import("styled-components").StyledComponent<"div", any, Pick<EmojiInputProps, "isDisabled"> & {
3
3
  theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
4
4
  }, never>;
5
+ type StyledEmojiInputContentProps = {
6
+ isRightElementGiven: boolean;
7
+ };
8
+ export declare const StyledEmojiInputContent: import("styled-components").StyledComponent<"div", any, StyledEmojiInputContentProps, never>;
5
9
  export declare const StyledEmojiInputEditor: import("styled-components").StyledComponent<"div", any, Pick<EmojiInputProps, "placeholder"> & {
6
10
  theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
7
11
  }, never>;
12
+ export declare const StyledEmojiInputRightWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
13
+ export {};
@@ -3,9 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledEmojiInputEditor = exports.StyledEmojiInput = void 0;
7
- var _styledComponents = _interopRequireDefault(require("styled-components"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+ exports.StyledEmojiInputRightWrapper = exports.StyledEmojiInputEditor = exports.StyledEmojiInputContent = exports.StyledEmojiInput = void 0;
7
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
+ var _environment = require("../../utils/environment");
9
+ 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); }
10
+ 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; }
9
11
  const StyledEmojiInput = _styledComponents.default.div`
10
12
  align-items: center;
11
13
  background-color: ${_ref => {
@@ -14,11 +16,8 @@ const StyledEmojiInput = _styledComponents.default.div`
14
16
  } = _ref;
15
17
  return theme['100'];
16
18
  }};
17
- border: 1px solid rgba(160, 160, 160, 0.3);
18
19
  border-radius: 3px;
19
20
  display: flex;
20
- gap: 10px;
21
- justify-content: space-between;
22
21
  min-height: 42px;
23
22
  opacity: ${_ref2 => {
24
23
  let {
@@ -26,35 +25,78 @@ const StyledEmojiInput = _styledComponents.default.div`
26
25
  } = _ref2;
27
26
  return isDisabled ? 0.5 : 1;
28
27
  }};
29
- padding: 8px 10px;
28
+ pointer-events: ${_ref3 => {
29
+ let {
30
+ isDisabled
31
+ } = _ref3;
32
+ return isDisabled ? 'none' : 'initial';
33
+ }};
30
34
  position: relative;
31
35
  transition: opacity 0.3s ease;
32
36
  `;
33
37
  exports.StyledEmojiInput = StyledEmojiInput;
38
+ const StyledEmojiInputContent = _styledComponents.default.div`
39
+ border: 1px solid rgba(160, 160, 160, 0.3);
40
+ border-radius: 3px;
41
+ display: flex;
42
+ flex: 1 1 auto;
43
+ gap: 10px;
44
+ padding: 8px 10px;
45
+
46
+ ${_ref4 => {
47
+ let {
48
+ isRightElementGiven
49
+ } = _ref4;
50
+ return isRightElementGiven && (0, _styledComponents.css)`
51
+ border-top-right-radius: 0;
52
+ border-bottom-right-radius: 0;
53
+ border-right-width: 0;
54
+ `;
55
+ }}
56
+ `;
57
+ exports.StyledEmojiInputContent = StyledEmojiInputContent;
34
58
  const StyledEmojiInputEditor = _styledComponents.default.div`
35
- color: ${_ref3 => {
59
+ color: ${_ref5 => {
36
60
  let {
37
61
  theme
38
- } = _ref3;
62
+ } = _ref5;
39
63
  return theme.text;
40
64
  }};
41
65
  flex: 1 1 auto;
42
- font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;
66
+ word-break: break-word;
67
+
68
+ ${() => {
69
+ if ((0, _environment.getIsMobile)()) {
70
+ return (0, _styledComponents.css)`
71
+ font-family: 'Roboto Regular', 'Tahoma', serif;
72
+ `;
73
+ }
74
+ return (0, _styledComponents.css)`
75
+ font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;
76
+ `;
77
+ }}
43
78
 
44
79
  &:empty:not(:focus):before {
45
- content: '${_ref4 => {
80
+ content: '${_ref6 => {
46
81
  let {
47
82
  placeholder
48
- } = _ref4;
83
+ } = _ref6;
49
84
  return placeholder;
50
85
  }}';
51
- color: ${_ref5 => {
86
+ color: ${_ref7 => {
52
87
  let {
53
88
  theme
54
- } = _ref5;
89
+ } = _ref7;
55
90
  return theme['006'];
56
91
  }};
57
92
  }
58
93
  `;
59
94
  exports.StyledEmojiInputEditor = StyledEmojiInputEditor;
95
+ const StyledEmojiInputRightWrapper = _styledComponents.default.div`
96
+ align-self: stretch;
97
+ border-bottom-right-radius: 3px;
98
+ border-top-right-radius: 3px;
99
+ overflow: hidden;
100
+ `;
101
+ exports.StyledEmojiInputRightWrapper = StyledEmojiInputRightWrapper;
60
102
  //# sourceMappingURL=EmojiInput.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiInput.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledEmojiInput","styled","div","_ref","theme","_ref2","isDisabled","exports","StyledEmojiInputEditor","_ref3","text","_ref4","placeholder","_ref5"],"sources":["../../../src/components/emoji-input/EmojiInput.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled 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: 1px solid rgba(160, 160, 160, 0.3);\n border-radius: 3px;\n display: flex;\n gap: 10px;\n justify-content: space-between;\n min-height: 42px;\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n padding: 8px 10px;\n position: relative;\n transition: opacity 0.3s ease;\n`;\n\ntype StyledEmojiInputEditorProps = WithTheme<Pick<EmojiInputProps, 'placeholder'>>;\n\nexport const StyledEmojiInputEditor = styled.div<StyledEmojiInputEditorProps>`\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme.text};\n flex: 1 1 auto;\n font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;\n\n &:empty:not(:focus):before {\n content: '${({ placeholder }) => placeholder}';\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme['006']};\n }\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAKhC,MAAMG,gBAAgB,GAAGC,yBAAM,CAACC,GAA2B;AAClE;AACA,wBAAwBC,IAAA;EAAA,IAAC;IAAEC;EAA6B,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,KAAA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,KAAA;EAAA,OAAMC,UAAU,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AAC1D;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAP,gBAAA,GAAAA,gBAAA;AAIK,MAAMQ,sBAAsB,GAAGP,yBAAM,CAACC,GAAiC;AAC9E,aAAaO,KAAA;EAAA,IAAC;IAAEL;EAAmC,CAAC,GAAAK,KAAA;EAAA,OAAKL,KAAK,CAACM,IAAI;AAAA,CAAC;AACpE;AACA;AACA;AACA;AACA,oBAAoBC,KAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,KAAA;EAAA,OAAKC,WAAW;AAAA,CAAC;AACrD,iBAAiBC,KAAA;EAAA,IAAC;IAAET;EAAmC,CAAC,GAAAS,KAAA;EAAA,OAAKT,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC1E;AACA,CAAC;AAACG,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"file":"EmojiInput.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_environment","_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","getIsMobile","_ref6","placeholder","_ref7","StyledEmojiInputRightWrapper"],"sources":["../../../src/components/emoji-input/EmojiInput.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled, { css } from 'styled-components';\nimport { getIsMobile } from '../../utils/environment';\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 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\nexport const StyledEmojiInputEditor = styled.div<StyledEmojiInputEditorProps>`\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme.text};\n flex: 1 1 auto;\n word-break: break-word;\n\n ${() => {\n if (getIsMobile()) {\n return css`\n font-family: 'Roboto Regular', 'Tahoma', serif;\n `;\n }\n\n return css`\n font-family: 'Noto Color Emoji', 'Roboto Regular', 'Tahoma', serif;\n `;\n }}\n\n &:empty:not(:focus):before {\n content: '${({ placeholder }) => placeholder}';\n color: ${({ theme }: StyledEmojiInputEditorProps) => theme['006']};\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 overflow: hidden;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;A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I,OAAA,CAAAK,sBAAA,GAAAA,sBAAA;AAEK,MAAMO,4BAA4B,GAAGnB,yBAAM,CAACC,GAAI;AACvD;AACA;AACA;AACA;AACA,CAAC;AAACM,OAAA,CAAAY,4BAAA,GAAAA,4BAAA"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _dataByGroup = _interopRequireDefault(require("unicode-emoji-json/data-by-group.json"));
9
+ var _categories = require("../../../constants/categories");
9
10
  var _EmojiPickerCategories = require("./EmojiPickerCategories.styles");
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  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); }
@@ -18,9 +19,7 @@ const EmojiPickerCategories = _ref => {
18
19
  } = _ref;
19
20
  const isSearchStringGiven = searchString.trim() !== '';
20
21
  const categories = (0, _react.useMemo)(() => _dataByGroup.default.map(_ref2 => {
21
- var _emojis$;
22
22
  let {
23
- emojis,
24
23
  slug
25
24
  } = _ref2;
26
25
  const isSelected = selectedCategory === slug && !isSearchStringGiven;
@@ -36,7 +35,7 @@ const EmojiPickerCategories = _ref => {
36
35
  transition: {
37
36
  duration: 0.2
38
37
  }
39
- }, (_emojis$ = emojis[0]) === null || _emojis$ === void 0 ? void 0 : _emojis$.emoji);
38
+ }, _categories.CATEGORY_EMOJIS[slug]);
40
39
  }), [isSearchStringGiven, onSelect, selectedCategory]);
41
40
  return /*#__PURE__*/_react.default.createElement(_EmojiPickerCategories.StyledEmojiPickerCategories, null, categories);
42
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPickerCategories.js","names":["_react","_interopRequireWildcard","require","_dataByGroup","_interopRequireDefault","_EmojiPickerCategories","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerCategories","_ref","onSelect","searchString","selectedCategory","isSearchStringGiven","trim","categories","useMemo","unicodeEmoji","map","_ref2","_emojis$","emojis","slug","isSelected","createElement","StyledMotionEmojiPickerCategory","animate","filter","opacity","className","initial","onClick","transition","duration","emoji","StyledEmojiPickerCategories","displayName","_default","exports"],"sources":["../../../../src/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport unicodeEmoji from 'unicode-emoji-json/data-by-group.json';\nimport type { Category } from '../../../types/category';\nimport {\n StyledEmojiPickerCategories,\n StyledMotionEmojiPickerCategory,\n} from './EmojiPickerCategories.styles';\n\nexport type EmojiPickerCategoriesProps = {\n onSelect: (category: Category) => void;\n searchString: string;\n selectedCategory: Category;\n};\n\nconst EmojiPickerCategories: FC<EmojiPickerCategoriesProps> = ({\n onSelect,\n searchString,\n selectedCategory,\n}) => {\n const isSearchStringGiven = searchString.trim() !== '';\n\n const categories = useMemo(\n () =>\n unicodeEmoji.map(({ emojis, slug }) => {\n const isSelected = selectedCategory === slug && !isSearchStringGiven;\n\n return (\n <StyledMotionEmojiPickerCategory\n animate={{\n filter: `grayscale(${isSelected ? 0 : 0.75})`,\n opacity: isSelected ? 1 : 0.5,\n }}\n className=\"prevent-lose-focus\"\n initial={false}\n key={slug}\n onClick={() => onSelect(slug as Category)}\n transition={{ duration: 0.2 }}\n >\n {emojis[0]?.emoji}\n </StyledMotionEmojiPickerCategory>\n );\n }),\n [isSearchStringGiven, onSelect, selectedCategory]\n );\n\n return <StyledEmojiPickerCategories>{categories}</StyledEmojiPickerCategories>;\n};\n\nEmojiPickerCategories.displayName = 'EmojiPickerCategories';\n\nexport default EmojiPickerCategories;\n"],"mappings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EDP,qBAAqB,CAAC4B,WAAW,GAAG,uBAAuB;AAAC,IAAAC,QAAA,GAE7C7B,qBAAqB;AAAA8B,OAAA,CAAAlD,OAAA,GAAAiD,QAAA"}
1
+ {"version":3,"file":"EmojiPickerCategories.js","names":["_react","_interopRequireWildcard","require","_dataByGroup","_interopRequireDefault","_categories","_EmojiPickerCategories","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiPickerCategories","_ref","onSelect","searchString","selectedCategory","isSearchStringGiven","trim","categories","useMemo","unicodeEmoji","map","_ref2","slug","isSelected","createElement","StyledMotionEmojiPickerCategory","animate","filter","opacity","className","initial","onClick","transition","duration","CATEGORY_EMOJIS","StyledEmojiPickerCategories","displayName","_default","exports"],"sources":["../../../../src/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport unicodeEmoji from 'unicode-emoji-json/data-by-group.json';\nimport { CATEGORY_EMOJIS } from '../../../constants/categories';\nimport type { Category } from '../../../types/category';\nimport {\n StyledEmojiPickerCategories,\n StyledMotionEmojiPickerCategory,\n} from './EmojiPickerCategories.styles';\n\nexport type EmojiPickerCategoriesProps = {\n onSelect: (category: Category) => void;\n searchString: string;\n selectedCategory: Category;\n};\n\nconst EmojiPickerCategories: FC<EmojiPickerCategoriesProps> = ({\n onSelect,\n searchString,\n selectedCategory,\n}) => {\n const isSearchStringGiven = searchString.trim() !== '';\n\n const categories = useMemo(\n () =>\n unicodeEmoji.map(({ slug }) => {\n const isSelected = selectedCategory === slug && !isSearchStringGiven;\n\n return (\n <StyledMotionEmojiPickerCategory\n animate={{\n filter: `grayscale(${isSelected ? 0 : 0.75})`,\n opacity: isSelected ? 1 : 0.5,\n }}\n className=\"prevent-lose-focus\"\n initial={false}\n key={slug}\n onClick={() => onSelect(slug as Category)}\n transition={{ duration: 0.2 }}\n >\n {CATEGORY_EMOJIS[slug as Category]}\n </StyledMotionEmojiPickerCategory>\n );\n }),\n [isSearchStringGiven, onSelect, selectedCategory]\n );\n\n return <StyledEmojiPickerCategories>{categories}</StyledEmojiPickerCategories>;\n};\n\nEmojiPickerCategories.displayName = 'EmojiPickerCategories';\n\nexport default EmojiPickerCategories;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAGwC,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAM,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,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,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAnB,GAAA,EAAAgB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J;EAE1C,CAAC,CAAC,EACN,CAACP,mBAAmB,EAAEH,QAAQ,EAAEE,gBAAgB,CAAC,CACpD;EAED,oBAAOjC,MAAA,CAAAS,OAAA,CAAAkC,aAAA,CAACrC,sBAAA,CAAAgD,2BAA2B,QAAElB,UAAU,CAA+B;AAClF,CAAC;AAEDP,qBAAqB,CAAC0B,WAAW,GAAG,uBAAuB;AAAC,IAAAC,QAAA,GAE7C3B,qBAAqB;AAAA4B,OAAA,CAAAhD,OAAA,GAAA+C,QAAA"}
@@ -1,5 +1,12 @@
1
1
  import { FC } from 'react';
2
+ import { PopupAlignment } from '../../constants/alignment';
2
3
  export type EmojiPickerPopupProps = {
4
+ /**
5
+ * Sets the alignment of the popup to a fixed value. If this value is not set, the component
6
+ * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this
7
+ * value.
8
+ */
9
+ alignment?: PopupAlignment;
3
10
  /**
4
11
  * Function that is executed when the visibility of the popup changes.
5
12
  * @param {boolean} isVisible - Whether the popup is visible or not
@@ -16,10 +16,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
  const EmojiPickerPopup = _ref => {
18
18
  let {
19
+ alignment,
19
20
  onPopupVisibilityChange,
20
21
  onSelect
21
22
  } = _ref;
22
- const [alignment, setAlignment] = (0, _react.useState)(_alignment.PopupAlignment.TopLeft);
23
+ const [internalAlignment, setInternalAlignment] = (0, _react.useState)(_alignment.PopupAlignment.TopLeft);
23
24
  const [shouldShowPopup, setShouldShowPopup] = (0, _react.useState)(false);
24
25
  const [position, setPosition] = (0, _react.useState)({});
25
26
  const contentRef = (0, _react.useRef)(null);
@@ -45,29 +46,53 @@ const EmojiPickerPopup = _ref => {
45
46
  top,
46
47
  width
47
48
  } = event.currentTarget.getBoundingClientRect();
48
- const newPosition = {};
49
- if (top < _EmojiPicker2.emojiPickerSize.height + 16) {
50
- newPosition.top = 12 + height;
51
- if (left < _EmojiPicker2.emojiPickerSize.width + 16) {
52
- newPosition.left = -10;
53
- setAlignment(_alignment.PopupAlignment.BottomRight);
49
+ let newInternalAlignment = alignment;
50
+ if (!newInternalAlignment) {
51
+ if (top < _EmojiPicker2.emojiPickerSize.height + 16) {
52
+ if (left < _EmojiPicker2.emojiPickerSize.width + 16) {
53
+ newInternalAlignment = _alignment.PopupAlignment.BottomRight;
54
+ } else {
55
+ newInternalAlignment = _alignment.PopupAlignment.BottomLeft;
56
+ }
57
+ } else if (left < _EmojiPicker2.emojiPickerSize.width + 16) {
58
+ newInternalAlignment = _alignment.PopupAlignment.TopRight;
54
59
  } else {
55
- newPosition.left = 8 + width - _EmojiPicker2.emojiPickerSize.width;
56
- setAlignment(_alignment.PopupAlignment.BottomLeft);
57
- }
58
- } else {
59
- newPosition.top = -12 - _EmojiPicker2.emojiPickerSize.height;
60
- if (left < _EmojiPicker2.emojiPickerSize.width + 16) {
61
- newPosition.left = -10;
62
- setAlignment(_alignment.PopupAlignment.TopRight);
63
- } else {
64
- newPosition.left = 8 + width - _EmojiPicker2.emojiPickerSize.width;
65
- setAlignment(_alignment.PopupAlignment.TopLeft);
60
+ newInternalAlignment = _alignment.PopupAlignment.TopLeft;
66
61
  }
67
62
  }
63
+ let newPosition = {};
64
+ switch (newInternalAlignment) {
65
+ case _alignment.PopupAlignment.BottomLeft:
66
+ newPosition = {
67
+ left: 8 + width - _EmojiPicker2.emojiPickerSize.width,
68
+ top: 12 + height
69
+ };
70
+ break;
71
+ case _alignment.PopupAlignment.BottomRight:
72
+ newPosition = {
73
+ left: -10,
74
+ top: 12 + height
75
+ };
76
+ break;
77
+ case _alignment.PopupAlignment.TopLeft:
78
+ newPosition = {
79
+ left: 8 + width - _EmojiPicker2.emojiPickerSize.width,
80
+ top: -12 - _EmojiPicker2.emojiPickerSize.height
81
+ };
82
+ break;
83
+ case _alignment.PopupAlignment.TopRight:
84
+ newPosition = {
85
+ left: -10,
86
+ top: -12 - _EmojiPicker2.emojiPickerSize.height
87
+ };
88
+ break;
89
+ default:
90
+ break;
91
+ }
92
+ setInternalAlignment(newInternalAlignment);
68
93
  setPosition(newPosition);
69
94
  setShouldShowPopup(true);
70
- }, [shouldShowPopup]);
95
+ }, [alignment, shouldShowPopup]);
71
96
  (0, _react.useEffect)(() => {
72
97
  if (shouldShowPopup) {
73
98
  document.addEventListener('click', handleDocumentClick, true);
@@ -83,11 +108,11 @@ const EmojiPickerPopup = _ref => {
83
108
  onPopupVisibilityChange(shouldShowPopup);
84
109
  }
85
110
  }, [onPopupVisibilityChange, shouldShowPopup]);
86
- const exitAndInitialY = alignment === _alignment.PopupAlignment.TopLeft || alignment === _alignment.PopupAlignment.TopRight ? -16 : 16;
111
+ const exitAndInitialY = internalAlignment === _alignment.PopupAlignment.TopLeft || internalAlignment === _alignment.PopupAlignment.TopRight ? -16 : 16;
87
112
  return /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledEmojiPickerPopup, null, /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
88
113
  initial: false
89
114
  }, shouldShowPopup && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.StyledMotionEmojiPickerPopupContent, {
90
- alignment: alignment,
115
+ alignment: internalAlignment,
91
116
  animate: {
92
117
  opacity: 1,
93
118
  y: 0
@@ -1 +1 @@
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","onPopupVisibilityChange","onSelect","alignment","setAlignment","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","newPosition","emojiPickerSize","BottomRight","BottomLeft","TopRight","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 * 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 * 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> = ({ onPopupVisibilityChange, onSelect }) => {\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\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 const newPosition: PopupPosition = {};\n\n if (top < emojiPickerSize.height + 16) {\n newPosition.top = 12 + height;\n\n if (left < emojiPickerSize.width + 16) {\n newPosition.left = -10;\n\n setAlignment(PopupAlignment.BottomRight);\n } else {\n newPosition.left = 8 + width - emojiPickerSize.width;\n\n setAlignment(PopupAlignment.BottomLeft);\n }\n } else {\n newPosition.top = -12 - emojiPickerSize.height;\n\n if (left < emojiPickerSize.width + 16) {\n newPosition.left = -10;\n\n setAlignment(PopupAlignment.TopRight);\n } else {\n newPosition.left = 8 + width - emojiPickerSize.width;\n\n setAlignment(PopupAlignment.TopLeft);\n }\n }\n\n setPosition(newPosition);\n setShouldShowPopup(true);\n },\n [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 alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.TopRight ? -16 : 16;\n\n return (\n <StyledEmojiPickerPopup>\n <AnimatePresence initial={false}>\n {shouldShowPopup && (\n <StyledMotionEmojiPickerPopupContent\n alignment={alignment}\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 onSelect={onSelect} />\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,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,GAAA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EAAE,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;IAC5ChD,GAAG,EAAC,yBAAyB;IAC7B0D,GAAG,EAAEvC,UAAW;IAChBwC,KAAK,EAAE1C,QAAS;IAChB2C,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9BnF,MAAA,CAAAa,OAAA,CAAA0D,aAAA,CAACpE,YAAA,CAAAU,OAAW;IAACkB,QAAQ,EAAEA;EAAS,EAAG,CAE1C,CACa,eAClB/B,MAAA,CAAAa,OAAA,CAAA0D,aAAA,CAAC3E,KAAA,CAAAiB,OAAI;IACDuE,SAAS,EAAC,oBAAoB;IAC9BC,KAAK,EAAE,CAAC,cAAc,CAAE;IACxBC,OAAO,EAAEjC,oBAAqB;IAC9BkC,IAAI,EAAE;EAAG,EACX,CACmB;AAEjC,CAAC;AAED3D,gBAAgB,CAAC4D,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnC7D,gBAAgB;AAAA8D,OAAA,CAAA7E,OAAA,GAAA4E,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","alignment","onPopupVisibilityChange","onSelect","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 * 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 * 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 alignment,\n onPopupVisibilityChange,\n onSelect,\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 (!newInternalAlignment) {\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 onSelect={onSelect} />\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,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,G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,aAAA,CAACtE,YAAA,CAAAU,OAAW;IAACmB,QAAQ,EAAEA;EAAS,EAAG,CAE1C,CACa,eAClBhC,MAAA,CAAAa,OAAA,CAAA4D,aAAA,CAAC7E,KAAA,CAAAiB,OAAI;IACDyE,SAAS,EAAC,oBAAoB;IAC9BC,KAAK,EAAE,CAAC,cAAc,CAAE;IACxBC,OAAO,EAAElC,oBAAqB;IAC9BmC,IAAI,EAAE;EAAG,EACX,CACmB;AAEjC,CAAC;AAED7D,gBAAgB,CAAC8D,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnC/D,gBAAgB;AAAAgE,OAAA,CAAA/E,OAAA,GAAA8E,QAAA"}
@@ -0,0 +1,11 @@
1
+ export declare const CATEGORY_EMOJIS: {
2
+ smileys_emotion: string;
3
+ people_body: string;
4
+ animals_nature: string;
5
+ food_drink: string;
6
+ travel_places: string;
7
+ activities: string;
8
+ objects: string;
9
+ symbols: string;
10
+ flags: string;
11
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CATEGORY_EMOJIS = void 0;
7
+ const CATEGORY_EMOJIS = {
8
+ smileys_emotion: '😀',
9
+ people_body: '👦',
10
+ animals_nature: '🐶',
11
+ food_drink: '🍔',
12
+ travel_places: '🏠',
13
+ activities: '⚽',
14
+ objects: '💡',
15
+ symbols: '🔣',
16
+ flags: '🏴'
17
+ };
18
+ exports.CATEGORY_EMOJIS = CATEGORY_EMOJIS;
19
+ //# sourceMappingURL=categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.js","names":["CATEGORY_EMOJIS","smileys_emotion","people_body","animals_nature","food_drink","travel_places","activities","objects","symbols","flags","exports"],"sources":["../../src/constants/categories.ts"],"sourcesContent":["export const CATEGORY_EMOJIS = {\n smileys_emotion: '😀',\n people_body: '👦',\n animals_nature: '🐶',\n food_drink: '🍔',\n travel_places: '🏠',\n activities: '⚽',\n objects: '💡',\n symbols: '🔣',\n flags: '🏴',\n};\n"],"mappings":";;;;;;AAAO,MAAMA,eAAe,GAAG;EAC3BC,eAAe,EAAE,IAAI;EACrBC,WAAW,EAAE,IAAI;EACjBC,cAAc,EAAE,IAAI;EACpBC,UAAU,EAAE,IAAI;EAChBC,aAAa,EAAE,IAAI;EACnBC,UAAU,EAAE,GAAG;EACfC,OAAO,EAAE,IAAI;EACbC,OAAO,EAAE,IAAI;EACbC,KAAK,EAAE;AACX,CAAC;AAACC,OAAA,CAAAV,eAAA,GAAAA,eAAA"}
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { default as EmojiInput } from './components/emoji-input/EmojiInput';
2
+ export { PopupAlignment } from './constants/alignment';
package/lib/index.js CHANGED
@@ -9,6 +9,13 @@ Object.defineProperty(exports, "EmojiInput", {
9
9
  return _EmojiInput.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "PopupAlignment", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _alignment.PopupAlignment;
16
+ }
17
+ });
12
18
  var _EmojiInput = _interopRequireDefault(require("./components/emoji-input/EmojiInput"));
19
+ var _alignment = require("./constants/alignment");
13
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
21
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_EmojiInput","_interopRequireDefault","require","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { default as EmojiInput } from './components/emoji-input/EmojiInput';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4E,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
1
+ {"version":3,"file":"index.js","names":["_EmojiInput","_interopRequireDefault","require","_alignment","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { default as EmojiInput } from './components/emoji-input/EmojiInput';\nexport { PopupAlignment } from './constants/alignment';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAAuD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
@@ -0,0 +1,8 @@
1
+ declare enum DeviceType {
2
+ Desktop = 0,
3
+ Smartphone = 1,
4
+ Tablet = 2
5
+ }
6
+ export declare const getDeviceType: () => DeviceType;
7
+ export declare const getIsMobile: () => boolean;
8
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIsMobile = exports.getDeviceType = void 0;
7
+ var DeviceType;
8
+ (function (DeviceType) {
9
+ DeviceType[DeviceType["Desktop"] = 0] = "Desktop";
10
+ DeviceType[DeviceType["Smartphone"] = 1] = "Smartphone";
11
+ DeviceType[DeviceType["Tablet"] = 2] = "Tablet";
12
+ })(DeviceType || (DeviceType = {}));
13
+ const getDeviceType = () => {
14
+ const {
15
+ userAgent
16
+ } = navigator;
17
+ if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(userAgent)) {
18
+ return DeviceType.Smartphone;
19
+ }
20
+ if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {
21
+ return DeviceType.Tablet;
22
+ }
23
+ return DeviceType.Desktop;
24
+ };
25
+ exports.getDeviceType = getDeviceType;
26
+ const getIsMobile = () => {
27
+ const deviceType = getDeviceType();
28
+ return deviceType === DeviceType.Smartphone || deviceType === DeviceType.Tablet;
29
+ };
30
+ exports.getIsMobile = getIsMobile;
31
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","names":["DeviceType","getDeviceType","userAgent","navigator","test","Smartphone","Tablet","Desktop","exports","getIsMobile","deviceType"],"sources":["../../src/utils/environment.ts"],"sourcesContent":["enum DeviceType {\n Desktop,\n Smartphone,\n Tablet,\n}\n\nexport const getDeviceType = (): DeviceType => {\n const { userAgent } = navigator;\n\n if (\n /Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(\n userAgent\n )\n ) {\n return DeviceType.Smartphone;\n }\n\n if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {\n return DeviceType.Tablet;\n }\n\n return DeviceType.Desktop;\n};\n\nexport const getIsMobile = (): boolean => {\n const deviceType = getDeviceType();\n\n return deviceType === DeviceType.Smartphone || deviceType === DeviceType.Tablet;\n};\n"],"mappings":";;;;;;IAAKA,UAAU;AAAA,WAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;AAAA,GAAVA,UAAU,KAAVA,UAAU;AAMR,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAM;IAAEC;EAAU,CAAC,GAAGC,SAAS;EAE/B,IACI,qGAAqG,CAACC,IAAI,CACtGF,SAAS,CACZ,EACH;IACE,OAAOF,UAAU,CAACK,UAAU;EAChC;EAEA,IAAI,kDAAkD,CAACD,IAAI,CAACF,SAAS,CAAC,EAAE;IACpE,OAAOF,UAAU,CAACM,MAAM;EAC5B;EAEA,OAAON,UAAU,CAACO,OAAO;AAC7B,CAAC;AAACC,OAAA,CAAAP,aAAA,GAAAA,aAAA;AAEK,MAAMQ,WAAW,GAAGA,CAAA,KAAe;EACtC,MAAMC,UAAU,GAAGT,aAAa,EAAE;EAElC,OAAOS,UAAU,KAAKV,UAAU,CAACK,UAAU,IAAIK,UAAU,KAAKV,UAAU,CAACM,MAAM;AACnF,CAAC;AAACE,OAAA,CAAAC,WAAA,GAAAA,WAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/emoji-input",
3
- "version": "5.0.0-beta.72",
3
+ "version": "5.0.0-beta.74",
4
4
  "description": "Input field that supports HTML elements and emojis",
5
5
  "keywords": [
6
6
  "chayns",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "55df39e5f53814963c9465b7932714a371e9e576"
71
+ "gitHead": "5b4719ada307779b76bd305a0c4de4bdbb59ee6b"
72
72
  }