@chayns-components/emoji-input 5.0.0-beta.85 → 5.0.0-beta.850

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.
Files changed (226) hide show
  1. package/README.md +4 -15
  2. package/lib/{api → cjs/api}/item-storage/get.js +4 -5
  3. package/lib/cjs/api/item-storage/get.js.map +1 -0
  4. package/lib/{api → cjs/api}/item-storage/put.js +5 -6
  5. package/lib/cjs/api/item-storage/put.js.map +1 -0
  6. package/lib/cjs/components/emoji-input/EmojiInput.js +532 -0
  7. package/lib/cjs/components/emoji-input/EmojiInput.js.map +1 -0
  8. package/lib/cjs/components/emoji-input/EmojiInput.styles.js +132 -0
  9. package/lib/cjs/components/emoji-input/EmojiInput.styles.js.map +1 -0
  10. package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.js +45 -0
  11. package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.js.map +1 -0
  12. package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.styles.js +65 -0
  13. package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
  14. package/lib/{components → cjs/components}/emoji-picker/EmojiPicker.js +9 -11
  15. package/lib/cjs/components/emoji-picker/EmojiPicker.js.map +1 -0
  16. package/lib/{components → cjs/components}/emoji-picker/EmojiPicker.styles.js +5 -5
  17. package/lib/cjs/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
  18. package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +102 -0
  19. package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
  20. package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +25 -0
  21. package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
  22. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +240 -0
  23. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
  24. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +69 -0
  25. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
  26. package/lib/{components → cjs/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +49 -21
  27. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  28. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +24 -0
  29. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
  30. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +130 -0
  31. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
  32. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +99 -0
  33. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
  34. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.js +52 -0
  35. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
  36. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.styles.js +15 -0
  37. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
  38. package/lib/{constants → cjs/constants}/alignment.js +6 -8
  39. package/lib/cjs/constants/alignment.js.map +1 -0
  40. package/lib/{constants → cjs/constants}/categories.js +1 -2
  41. package/lib/cjs/constants/categories.js.map +1 -0
  42. package/lib/cjs/constants/emoji.js +3804 -0
  43. package/lib/cjs/constants/emoji.js.map +1 -0
  44. package/lib/cjs/constants/externalServerUrl.js +8 -0
  45. package/lib/cjs/constants/externalServerUrl.js.map +1 -0
  46. package/lib/cjs/constants/regex.js +15 -0
  47. package/lib/cjs/constants/regex.js.map +1 -0
  48. package/lib/{hooks → cjs/hooks}/emojiHistory.js +13 -15
  49. package/lib/cjs/hooks/emojiHistory.js.map +1 -0
  50. package/lib/{index.js → cjs/index.js} +3 -3
  51. package/lib/cjs/index.js.map +1 -0
  52. package/lib/cjs/types/api.js +2 -0
  53. package/lib/cjs/types/api.js.map +1 -0
  54. package/lib/cjs/types/category.js +2 -0
  55. package/lib/cjs/types/category.js.map +1 -0
  56. package/lib/cjs/utils/emoji.js +104 -0
  57. package/lib/cjs/utils/emoji.js.map +1 -0
  58. package/lib/{utils → cjs/utils}/environment.js +6 -4
  59. package/lib/cjs/utils/environment.js.map +1 -0
  60. package/lib/cjs/utils/font.js +17 -0
  61. package/lib/cjs/utils/font.js.map +1 -0
  62. package/lib/cjs/utils/insert.js +110 -0
  63. package/lib/cjs/utils/insert.js.map +1 -0
  64. package/lib/cjs/utils/number.js +17 -0
  65. package/lib/cjs/utils/number.js.map +1 -0
  66. package/lib/cjs/utils/selection.js +214 -0
  67. package/lib/cjs/utils/selection.js.map +1 -0
  68. package/lib/cjs/utils/text.js +57 -0
  69. package/lib/cjs/utils/text.js.map +1 -0
  70. package/lib/esm/api/item-storage/get.js +30 -0
  71. package/lib/esm/api/item-storage/get.js.map +1 -0
  72. package/lib/esm/api/item-storage/put.js +35 -0
  73. package/lib/esm/api/item-storage/put.js.map +1 -0
  74. package/lib/esm/components/emoji-input/EmojiInput.js +519 -0
  75. package/lib/esm/components/emoji-input/EmojiInput.js.map +1 -0
  76. package/lib/esm/components/emoji-input/EmojiInput.styles.js +151 -0
  77. package/lib/esm/components/emoji-input/EmojiInput.styles.js.map +1 -0
  78. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js +38 -0
  79. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js.map +1 -0
  80. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js +69 -0
  81. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
  82. package/lib/esm/components/emoji-picker/EmojiPicker.js +40 -0
  83. package/lib/esm/components/emoji-picker/EmojiPicker.js.map +1 -0
  84. package/lib/esm/components/emoji-picker/EmojiPicker.styles.js +16 -0
  85. package/lib/esm/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
  86. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +96 -0
  87. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
  88. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +18 -0
  89. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
  90. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +240 -0
  91. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
  92. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +76 -0
  93. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
  94. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +136 -0
  95. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  96. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +20 -0
  97. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
  98. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +121 -0
  99. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
  100. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +98 -0
  101. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
  102. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js +43 -0
  103. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
  104. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js +8 -0
  105. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
  106. package/lib/esm/constants/alignment.js +13 -0
  107. package/lib/esm/constants/alignment.js.map +1 -0
  108. package/lib/esm/constants/categories.js +13 -0
  109. package/lib/esm/constants/categories.js.map +1 -0
  110. package/lib/esm/constants/emoji-de-DE.json +3827 -0
  111. package/lib/esm/constants/emoji.js +3798 -0
  112. package/lib/esm/constants/emoji.js.map +1 -0
  113. package/lib/esm/constants/externalServerUrl.js +2 -0
  114. package/lib/esm/constants/externalServerUrl.js.map +1 -0
  115. package/lib/esm/constants/regex.js +9 -0
  116. package/lib/esm/constants/regex.js.map +1 -0
  117. package/lib/esm/hooks/emojiHistory.js +83 -0
  118. package/lib/esm/hooks/emojiHistory.js.map +1 -0
  119. package/lib/{index.d.ts → esm/index.js} +2 -1
  120. package/lib/esm/index.js.map +1 -0
  121. package/lib/esm/types/api.js +2 -0
  122. package/lib/esm/types/api.js.map +1 -0
  123. package/lib/esm/types/category.js +2 -0
  124. package/lib/esm/types/category.js.map +1 -0
  125. package/lib/esm/utils/emoji.js +92 -0
  126. package/lib/esm/utils/emoji.js.map +1 -0
  127. package/lib/esm/utils/environment.js +24 -0
  128. package/lib/esm/utils/environment.js.map +1 -0
  129. package/lib/esm/utils/font.js +10 -0
  130. package/lib/esm/utils/font.js.map +1 -0
  131. package/lib/esm/utils/insert.js +104 -0
  132. package/lib/esm/utils/insert.js.map +1 -0
  133. package/lib/esm/utils/number.js +10 -0
  134. package/lib/esm/utils/number.js.map +1 -0
  135. package/lib/esm/utils/selection.js +197 -0
  136. package/lib/esm/utils/selection.js.map +1 -0
  137. package/lib/esm/utils/text.js +48 -0
  138. package/lib/esm/utils/text.js.map +1 -0
  139. package/lib/types/components/emoji-input/EmojiInput.d.ts +94 -0
  140. package/lib/types/components/emoji-input/EmojiInput.styles.d.ts +549 -0
  141. package/lib/types/components/emoji-input/prefix-element/PrefixElement.d.ts +8 -0
  142. package/lib/types/components/emoji-input/prefix-element/PrefixElement.styles.d.ts +12 -0
  143. package/lib/types/components/emoji-picker/EmojiPicker.styles.d.ts +5 -0
  144. package/lib/types/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +267 -0
  145. package/lib/types/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +10 -0
  146. package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.d.ts +5 -0
  147. package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +6 -0
  148. package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +283 -0
  149. package/lib/{components → types/components}/emoji-picker-popup/EmojiPickerPopup.d.ts +0 -13
  150. package/lib/types/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +1 -0
  151. package/lib/types/constants/emoji.d.ts +8 -0
  152. package/lib/types/constants/regex.d.ts +8 -0
  153. package/lib/types/index.d.ts +6 -0
  154. package/lib/types/utils/emoji.d.ts +4 -0
  155. package/lib/{utils → types/utils}/environment.d.ts +1 -0
  156. package/lib/types/utils/font.d.ts +1 -0
  157. package/lib/types/utils/insert.d.ts +26 -0
  158. package/lib/types/utils/number.d.ts +1 -0
  159. package/lib/types/utils/selection.d.ts +22 -0
  160. package/lib/types/utils/text.d.ts +3 -0
  161. package/package.json +45 -29
  162. package/lib/api/item-storage/get.js.map +0 -1
  163. package/lib/api/item-storage/put.js.map +0 -1
  164. package/lib/components/emoji-input/EmojiInput.d.ts +0 -49
  165. package/lib/components/emoji-input/EmojiInput.js +0 -164
  166. package/lib/components/emoji-input/EmojiInput.js.map +0 -1
  167. package/lib/components/emoji-input/EmojiInput.styles.d.ts +0 -13
  168. package/lib/components/emoji-input/EmojiInput.styles.js +0 -149
  169. package/lib/components/emoji-input/EmojiInput.styles.js.map +0 -1
  170. package/lib/components/emoji-picker/EmojiPicker.js.map +0 -1
  171. package/lib/components/emoji-picker/EmojiPicker.styles.d.ts +0 -5
  172. package/lib/components/emoji-picker/EmojiPicker.styles.js.map +0 -1
  173. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +0 -51
  174. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +0 -1
  175. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +0 -2
  176. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +0 -25
  177. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +0 -1
  178. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +0 -131
  179. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +0 -1
  180. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +0 -7
  181. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +0 -98
  182. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +0 -1
  183. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +0 -1
  184. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +0 -1
  185. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +0 -20
  186. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +0 -1
  187. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +0 -74
  188. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +0 -1
  189. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +0 -11
  190. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +0 -104
  191. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +0 -1
  192. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +0 -150
  193. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +0 -1
  194. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +0 -7
  195. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js +0 -97
  196. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +0 -1
  197. package/lib/constants/alignment.js.map +0 -1
  198. package/lib/constants/categories.js.map +0 -1
  199. package/lib/constants/externalServerUrl.js +0 -9
  200. package/lib/constants/externalServerUrl.js.map +0 -1
  201. package/lib/hooks/emojiHistory.js.map +0 -1
  202. package/lib/index.js.map +0 -1
  203. package/lib/types/api.js +0 -6
  204. package/lib/types/api.js.map +0 -1
  205. package/lib/types/category.js +0 -6
  206. package/lib/types/category.js.map +0 -1
  207. package/lib/utils/emoji.d.ts +0 -2
  208. package/lib/utils/emoji.js +0 -205
  209. package/lib/utils/emoji.js.map +0 -1
  210. package/lib/utils/environment.js.map +0 -1
  211. package/lib/utils/selection.d.ts +0 -2
  212. package/lib/utils/selection.js +0 -43
  213. package/lib/utils/selection.js.map +0 -1
  214. /package/lib/{constants → cjs/constants}/emoji-de-DE.json +0 -0
  215. /package/lib/{api → types/api}/item-storage/get.d.ts +0 -0
  216. /package/lib/{api → types/api}/item-storage/put.d.ts +0 -0
  217. /package/lib/{components → types/components}/emoji-picker/EmojiPicker.d.ts +0 -0
  218. /package/lib/{components → types/components}/emoji-picker/emoji-picker-categories/EmojiPickerCategories.d.ts +0 -0
  219. /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.d.ts +0 -0
  220. /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +0 -0
  221. /package/lib/{constants → types/constants}/alignment.d.ts +0 -0
  222. /package/lib/{constants → types/constants}/categories.d.ts +0 -0
  223. /package/lib/{constants → types/constants}/externalServerUrl.d.ts +0 -0
  224. /package/lib/{hooks → types/hooks}/emojiHistory.d.ts +0 -0
  225. /package/lib/types/{api.d.ts → types/api.d.ts} +0 -0
  226. /package/lib/types/{category.d.ts → types/category.d.ts} +0 -0
package/README.md CHANGED
@@ -15,14 +15,14 @@
15
15
 
16
16
  ## Installation
17
17
 
18
- First you need to install the typewriter part of the chayns-components.
18
+ First you need to install the emoji input part of the chayns-components.
19
19
 
20
20
  ```bash
21
21
  # NPM
22
- npm install @chayns-components/typewriter
22
+ npm install @chayns-components/emoji-input
23
23
 
24
24
  # Yarn
25
- yarn add @chayns-components/typewriter
25
+ yarn add @chayns-components/emoji-input
26
26
  ```
27
27
 
28
28
  > **Information:** Since the components have now been implemented with the styled-components
@@ -31,15 +31,4 @@ yarn add @chayns-components/typewriter
31
31
 
32
32
  ## Usage
33
33
 
34
- You can use the components in your project as in the following example.
35
-
36
- ```typescript jsx
37
- import { Typewriter } from '@chayns-components/typewriter';
38
-
39
- <Typewriter>
40
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt
41
- ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
42
- dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est. Lorem ipsum dolor
43
- sit amet.
44
- </Typewriter>;
45
- ```
34
+ For detailed usage visit the [storybook](https://components.chayns.site/storybook).
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getEmojiHistory = void 0;
7
7
  var _externalServerUrl = require("../../constants/externalServerUrl");
8
- const getEmojiHistory = async _ref => {
9
- let {
10
- accessToken,
11
- personId
12
- } = _ref;
8
+ const getEmojiHistory = async ({
9
+ accessToken,
10
+ personId
11
+ }) => {
13
12
  const requestInit = {
14
13
  headers: {
15
14
  Authorization: `Bearer ${accessToken}`
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","names":["_externalServerUrl","require","getEmojiHistory","accessToken","personId","requestInit","headers","Authorization","method","url","ITEM_STORAGE_BASE_URL","response","fetch","status","data","json","value","e","exports"],"sources":["../../../../src/api/item-storage/get.ts"],"sourcesContent":["import { ITEM_STORAGE_BASE_URL } from '../../constants/externalServerUrl';\nimport type { HistoryItem } from '../../hooks/emojiHistory';\nimport type { ApiFunctionResult } from '../../types/api';\n\ninterface GetEmojiHistoryOptions {\n accessToken: string;\n personId: string;\n}\n\ninterface GetEmojiHistoryResponseData {\n key: string;\n personId: string;\n schemeId: string;\n value: HistoryItem[];\n}\n\nexport const getEmojiHistory = async ({\n accessToken,\n personId,\n}: GetEmojiHistoryOptions): Promise<ApiFunctionResult<HistoryItem[]>> => {\n const requestInit: RequestInit = {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n method: 'GET',\n };\n\n const url = `${ITEM_STORAGE_BASE_URL}/7/users/${personId}/keys/emojis`;\n\n const response = await fetch(url, requestInit);\n\n if (response.status === 200) {\n try {\n const data = (await response.json()) as GetEmojiHistoryResponseData;\n\n return { data: data.value, status: 200 };\n } catch (e) {\n // Do nothing\n }\n }\n\n return { status: response.status };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAgBO,MAAMC,eAAe,GAAG,MAAAA,CAAO;EAClCC,WAAW;EACXC;AACoB,CAAC,KAAgD;EACrE,MAAMC,WAAwB,GAAG;IAC7BC,OAAO,EAAE;MACLC,aAAa,EAAE,UAAUJ,WAAW;IACxC,CAAC;IACDK,MAAM,EAAE;EACZ,CAAC;EAED,MAAMC,GAAG,GAAG,GAAGC,wCAAqB,YAAYN,QAAQ,cAAc;EAEtE,MAAMO,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAG,EAAEJ,WAAW,CAAC;EAE9C,IAAIM,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IACzB,IAAI;MACA,MAAMC,IAAI,GAAI,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAiC;MAEnE,OAAO;QAAED,IAAI,EAAEA,IAAI,CAACE,KAAK;QAAEH,MAAM,EAAE;MAAI,CAAC;IAC5C,CAAC,CAAC,OAAOI,CAAC,EAAE;MACR;IAAA;EAER;EAEA,OAAO;IAAEJ,MAAM,EAAEF,QAAQ,CAACE;EAAO,CAAC;AACtC,CAAC;AAACK,OAAA,CAAAhB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.putEmojiHistory = void 0;
7
7
  var _externalServerUrl = require("../../constants/externalServerUrl");
8
- const putEmojiHistory = async _ref => {
9
- let {
10
- accessToken,
11
- personId,
12
- value
13
- } = _ref;
8
+ const putEmojiHistory = async ({
9
+ accessToken,
10
+ personId,
11
+ value
12
+ }) => {
14
13
  const requestInit = {
15
14
  body: JSON.stringify({
16
15
  value
@@ -0,0 +1 @@
1
+ {"version":3,"file":"put.js","names":["_externalServerUrl","require","putEmojiHistory","accessToken","personId","value","requestInit","body","JSON","stringify","headers","Authorization","method","url","ITEM_STORAGE_BASE_URL","response","fetch","status","data","json","e","exports"],"sources":["../../../../src/api/item-storage/put.ts"],"sourcesContent":["import { ITEM_STORAGE_BASE_URL } from '../../constants/externalServerUrl';\nimport type { HistoryItem } from '../../hooks/emojiHistory';\nimport type { ApiFunctionResult } from '../../types/api';\n\ninterface PutEmojiHistoryOptions {\n accessToken: string;\n personId: string;\n value: HistoryItem[];\n}\n\ninterface PutEmojiHistoryResponseData {\n key: string;\n personId: string;\n schemeId: string;\n value: HistoryItem[];\n}\n\nexport const putEmojiHistory = async ({\n accessToken,\n personId,\n value,\n}: PutEmojiHistoryOptions): Promise<ApiFunctionResult<HistoryItem[]>> => {\n const requestInit: RequestInit = {\n body: JSON.stringify({ value }),\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n };\n\n const url = `${ITEM_STORAGE_BASE_URL}/7/users/${personId}/keys/emojis`;\n\n const response = await fetch(url, requestInit);\n\n if (response.status === 201) {\n try {\n const data = (await response.json()) as PutEmojiHistoryResponseData;\n\n return { data: data.value, status: 200 };\n } catch (e) {\n // Do nothing\n }\n }\n\n return { status: response.status };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAiBO,MAAMC,eAAe,GAAG,MAAAA,CAAO;EAClCC,WAAW;EACXC,QAAQ;EACRC;AACoB,CAAC,KAAgD;EACrE,MAAMC,WAAwB,GAAG;IAC7BC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MAAEJ;IAAM,CAAC,CAAC;IAC/BK,OAAO,EAAE;MACLC,aAAa,EAAE,UAAUR,WAAW,EAAE;MACtC,cAAc,EAAE;IACpB,CAAC;IACDS,MAAM,EAAE;EACZ,CAAC;EAED,MAAMC,GAAG,GAAG,GAAGC,wCAAqB,YAAYV,QAAQ,cAAc;EAEtE,MAAMW,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAG,EAAEP,WAAW,CAAC;EAE9C,IAAIS,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IACzB,IAAI;MACA,MAAMC,IAAI,GAAI,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAiC;MAEnE,OAAO;QAAED,IAAI,EAAEA,IAAI,CAACb,KAAK;QAAEY,MAAM,EAAE;MAAI,CAAC;IAC5C,CAAC,CAAC,OAAOG,CAAC,EAAE;MACR;IAAA;EAER;EAEA,OAAO;IAAEH,MAAM,EAAEF,QAAQ,CAACE;EAAO,CAAC;AACtC,CAAC;AAACI,OAAA,CAAAnB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,532 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _core = require("@chayns-components/core");
8
+ var _chaynsApi = require("chayns-api");
9
+ var _framerMotion = require("framer-motion");
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _emoji = require("../../utils/emoji");
12
+ var _insert = require("../../utils/insert");
13
+ var _selection = require("../../utils/selection");
14
+ var _text = require("../../utils/text");
15
+ var _EmojiPickerPopup = _interopRequireDefault(require("../emoji-picker-popup/EmojiPickerPopup"));
16
+ var _EmojiInput = require("./EmojiInput.styles");
17
+ var _PrefixElement = _interopRequireDefault(require("./prefix-element/PrefixElement"));
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
22
+ const EmojiInput = /*#__PURE__*/(0, _react.forwardRef)(({
23
+ accessToken,
24
+ height,
25
+ inputId,
26
+ isDisabled,
27
+ maxHeight = '190px',
28
+ onBlur,
29
+ onFocus,
30
+ onInput,
31
+ onKeyDown,
32
+ onPrefixElementRemove,
33
+ onPopupVisibilityChange,
34
+ personId,
35
+ placeholder,
36
+ popupAlignment,
37
+ prefixElement,
38
+ rightElement,
39
+ shouldHidePlaceholderOnFocus = true,
40
+ shouldPreventEmojiPicker,
41
+ value
42
+ }, ref) => {
43
+ const [isTouch] = (0, _react.useState)((0, _core.getIsTouch)());
44
+ const [plainTextValue, setPlainTextValue] = (0, _react.useState)(value);
45
+ const [hasFocus, setHasFocus] = (0, _react.useState)(false);
46
+ const [progressDuration, setProgressDuration] = (0, _react.useState)(0);
47
+ const [labelWidth, setLabelWidth] = (0, _react.useState)(0);
48
+ const [isPopupVisible, setIsPopupVisible] = (0, _react.useState)(false);
49
+ const [isPrefixAnimationFinished, setIsPrefixAnimationFinished] = (0, _react.useState)(!prefixElement);
50
+ const [prefixElementWidth, setPrefixElementWidth] = (0, _react.useState)();
51
+ const [textLength, setTextLength] = (0, _react.useState)(0);
52
+ const areaProvider = (0, _react.useContext)(_core.AreaContext);
53
+ const editorRef = (0, _react.useRef)(null);
54
+ const prefixElementRef = (0, _react.useRef)(null);
55
+ const hasPrefixRendered = (0, _react.useRef)(false);
56
+ const hasPrefixChanged = (0, _react.useRef)(false);
57
+ const shouldDeleteOneMoreBackwards = (0, _react.useRef)(false);
58
+ const shouldDeleteOneMoreForwards = (0, _react.useRef)(false);
59
+ const valueRef = (0, _react.useRef)(value);
60
+ const {
61
+ browser
62
+ } = (0, _chaynsApi.getDevice)();
63
+ const shouldChangeColor = (0, _react.useMemo)(() => areaProvider.shouldChangeColor ?? false, [areaProvider.shouldChangeColor]);
64
+
65
+ /**
66
+ * This function updates the content of the 'contentEditable' element if the new text is
67
+ * different from the previous content. So this is only true if, for example, a text like ":-)"
68
+ * has been replaced to the corresponding emoji.
69
+ *
70
+ * When updating the HTML, the current cursor position is saved before replacing the content, so
71
+ * that it can be set again afterward.
72
+ */
73
+ const handleUpdateHTML = (0, _react.useCallback)(html => {
74
+ if (!editorRef.current) {
75
+ return;
76
+ }
77
+ let newInnerHTML = (0, _emoji.convertEmojisToUnicode)(html);
78
+ newInnerHTML = (0, _text.convertTextToHTML)(newInnerHTML);
79
+ if (newInnerHTML !== editorRef.current.innerHTML) {
80
+ (0, _selection.saveSelection)(editorRef.current, {
81
+ shouldIgnoreEmptyTextNodes: true
82
+ });
83
+ editorRef.current.innerHTML = newInnerHTML;
84
+ (0, _selection.restoreSelection)(editorRef.current);
85
+ }
86
+ }, []);
87
+ const handleBeforeInput = (0, _react.useCallback)(event => {
88
+ if (!editorRef.current) {
89
+ return;
90
+ }
91
+ if (isDisabled) {
92
+ event.preventDefault();
93
+ event.stopPropagation();
94
+ return;
95
+ }
96
+ const {
97
+ data,
98
+ type
99
+ } = event.nativeEvent;
100
+ if (type === 'textInput' && data && data.includes('\n')) {
101
+ event.preventDefault();
102
+ event.stopPropagation();
103
+ const text = (0, _emoji.convertEmojisToUnicode)(data);
104
+ (0, _insert.insertTextAtCursorPosition)({
105
+ editorElement: editorRef.current,
106
+ text
107
+ });
108
+ const newEvent = new Event('input', {
109
+ bubbles: true
110
+ });
111
+ editorRef.current.dispatchEvent(newEvent);
112
+ }
113
+ }, [isDisabled]);
114
+
115
+ /**
116
+ * This function handles the 'input' events of the 'contentEditable' element and also passes the
117
+ * respective event up accordingly if the 'onInput' property is a function.
118
+ */
119
+ const handleInput = (0, _react.useCallback)(event => {
120
+ if (!editorRef.current) {
121
+ return;
122
+ }
123
+ if (isDisabled) {
124
+ event.stopPropagation();
125
+ event.preventDefault();
126
+ }
127
+ const {
128
+ target
129
+ } = event;
130
+ const newLength = target.innerHTML.length;
131
+ setTextLength(prevState => {
132
+ if (newLength < prevState) {
133
+ event.preventDefault();
134
+ event.stopPropagation();
135
+ const keyboardEvent = new KeyboardEvent('keydown', {
136
+ key: 'Backspace',
137
+ code: 'Backspace',
138
+ keyCode: 8,
139
+ which: 8,
140
+ location: 0,
141
+ bubbles: true,
142
+ // Ensures the event bubbles up through the DOM
143
+ cancelable: true // Allows the event to be canceled
144
+ });
145
+ target.dispatchEvent(keyboardEvent);
146
+ }
147
+ return newLength;
148
+ });
149
+ if (shouldDeleteOneMoreBackwards.current) {
150
+ shouldDeleteOneMoreBackwards.current = false;
151
+ shouldDeleteOneMoreForwards.current = false;
152
+ event.preventDefault();
153
+ event.stopPropagation();
154
+
155
+ // noinspection JSDeprecatedSymbols
156
+ document.execCommand('delete', false);
157
+ return;
158
+ }
159
+ if (shouldDeleteOneMoreForwards.current) {
160
+ shouldDeleteOneMoreBackwards.current = false;
161
+ shouldDeleteOneMoreForwards.current = false;
162
+ event.preventDefault();
163
+ event.stopPropagation();
164
+
165
+ // noinspection JSDeprecatedSymbols
166
+ document.execCommand('forwardDelete', false);
167
+ return;
168
+ }
169
+ handleUpdateHTML(editorRef.current.innerHTML);
170
+ const text = (0, _text.convertHTMLToText)(editorRef.current.innerHTML);
171
+ setPlainTextValue(text);
172
+ if (typeof onInput === 'function') {
173
+ onInput(event, text);
174
+ }
175
+ }, [handleUpdateHTML, isDisabled, onInput]);
176
+ const handleKeyDown = (0, _react.useCallback)(event => {
177
+ if (isDisabled) {
178
+ event.preventDefault();
179
+ event.stopPropagation();
180
+ return;
181
+ }
182
+ if (event.key === 'Enter' && isPopupVisible) {
183
+ event.preventDefault();
184
+ return;
185
+ }
186
+ if (typeof onKeyDown === 'function') {
187
+ onKeyDown(event);
188
+ }
189
+ if (event.key === 'Enter' && !event.isPropagationStopped() && editorRef.current) {
190
+ event.preventDefault();
191
+
192
+ // noinspection JSDeprecatedSymbols
193
+ document.execCommand('insertLineBreak', false);
194
+ }
195
+ if (event.key === 'Backspace' || event.key === 'Delete') {
196
+ const charCodeThatWillBeDeleted = (0, _selection.getCharCodeThatWillBeDeleted)(event);
197
+ if (charCodeThatWillBeDeleted === 8203) {
198
+ if (event.key === 'Backspace') {
199
+ shouldDeleteOneMoreBackwards.current = true;
200
+ } else {
201
+ shouldDeleteOneMoreForwards.current = true;
202
+ }
203
+ }
204
+ }
205
+ }, [isDisabled, isPopupVisible, onKeyDown]);
206
+ const handlePopupVisibility = (0, _react.useCallback)(isVisible => {
207
+ setIsPopupVisible(isVisible);
208
+ if (editorRef.current && isVisible) {
209
+ (0, _selection.saveSelection)(editorRef.current);
210
+ }
211
+ if (typeof onPopupVisibilityChange === 'function') {
212
+ onPopupVisibilityChange(isVisible);
213
+ }
214
+ }, [onPopupVisibilityChange]);
215
+
216
+ /**
217
+ * This function prevents formatting from being adopted when texts are inserted. To do this, the
218
+ * plain text is read from the event after the default behavior has been prevented. The plain
219
+ * text is then inserted at the correct position in the input field using document.execCommand('insertHTML')
220
+ */
221
+ const handlePaste = (0, _react.useCallback)(event => {
222
+ if (editorRef.current) {
223
+ event.preventDefault();
224
+ if (isDisabled) {
225
+ event.stopPropagation();
226
+ return;
227
+ }
228
+ let text = event.clipboardData.getData('text/plain');
229
+ text = (0, _emoji.convertEmojisToUnicode)(text);
230
+
231
+ // This deprecated function is used, because it causes the inserted content to be added to the undo stack.
232
+ // If the text were to be inserted directly into the 'innerHTML' of the editor element, the undo stack would not be updated.
233
+ // In that case on CTRL+Z the inserted text would not be removed.
234
+ document.execCommand('insertHTML', false, text);
235
+ const newEvent = new Event('input', {
236
+ bubbles: true
237
+ });
238
+ editorRef.current.dispatchEvent(newEvent);
239
+ }
240
+ }, [isDisabled]);
241
+
242
+ /**
243
+ * This function prevents formatting from being adopted when texts are dropped. To do this, the
244
+ * plain text is read from the event after the default behavior has been prevented. The plain
245
+ * text is then inserted at the correct position in the input field using document.execCommand('insertHTML')
246
+ */
247
+ const handleDrop = (0, _react.useCallback)(event => {
248
+ if (editorRef.current) {
249
+ var _event$dataTransfer;
250
+ event.preventDefault();
251
+ if (isDisabled) {
252
+ event.stopPropagation();
253
+ return;
254
+ }
255
+ let text = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.getData('text');
256
+ if (!text) {
257
+ return;
258
+ }
259
+ text = (0, _emoji.convertEmojisToUnicode)(text);
260
+
261
+ // This deprecated function is used, because it causes the inserted content to be added to the undo stack.
262
+ // If the text were to be inserted directly into the 'innerHTML' of the editor element, the undo stack would not be updated.
263
+ // In that case on CTRL+Z the inserted text would not be removed.
264
+ document.execCommand('insertHTML', false, text);
265
+ const newEvent = new Event('input', {
266
+ bubbles: true
267
+ });
268
+ editorRef.current.dispatchEvent(newEvent);
269
+ }
270
+ }, [isDisabled]);
271
+
272
+ /**
273
+ * This function uses the 'insertTextAtCursorPosition' function to insert the emoji at the
274
+ * correct position in the editor element.
275
+ *
276
+ * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,
277
+ * which in turn executes the 'onInput' function from the props. So this serves to ensure that
278
+ * the event is also passed through to the top when inserting via the popup.
279
+ */
280
+ const handlePopupSelect = (0, _react.useCallback)(emoji => {
281
+ if (editorRef.current) {
282
+ (0, _insert.insertTextAtCursorPosition)({
283
+ editorElement: editorRef.current,
284
+ text: emoji,
285
+ shouldUseSavedSelection: true
286
+ });
287
+ const event = new Event('input', {
288
+ bubbles: true
289
+ });
290
+ editorRef.current.dispatchEvent(event);
291
+ }
292
+ }, []);
293
+ (0, _react.useEffect)(() => {
294
+ var _editorRef$current;
295
+ if (typeof onPrefixElementRemove !== 'function') {
296
+ return;
297
+ }
298
+ if (!hasPrefixRendered.current) {
299
+ return;
300
+ }
301
+ const convertedText = (0, _text.convertHTMLToText)(((_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.innerHTML) ?? '').replace('&nbsp;', ' ');
302
+ const convertedPrefix = prefixElement && prefixElement.replace('&nbsp;', ' ');
303
+ if (convertedPrefix && convertedText.includes(convertedPrefix) && convertedText.length > convertedPrefix.length || convertedPrefix === convertedText) {
304
+ return;
305
+ }
306
+ if (hasPrefixChanged.current) {
307
+ hasPrefixChanged.current = false;
308
+ return;
309
+ }
310
+ onPrefixElementRemove();
311
+ hasPrefixRendered.current = false;
312
+ }, [onPrefixElementRemove, plainTextValue.length, prefixElement]);
313
+ (0, _react.useEffect)(() => {
314
+ if (typeof prefixElement === 'string') {
315
+ hasPrefixChanged.current = true;
316
+ }
317
+ }, [prefixElement]);
318
+ (0, _react.useEffect)(() => {
319
+ if (value !== plainTextValue) {
320
+ setPlainTextValue(value);
321
+ handleUpdateHTML(value);
322
+ }
323
+ }, [handleUpdateHTML, plainTextValue, value]);
324
+
325
+ // This effect is used to call the 'handleUpdateHTML' function once after the component has been
326
+ // rendered. This is necessary because the 'contentEditable' element otherwise does not display
327
+ // the HTML content correctly when the component is rendered for the first time.
328
+ useIsomorphicLayoutEffect(() => {
329
+ handleUpdateHTML(valueRef.current);
330
+ }, [handleUpdateHTML]);
331
+ const handleInsertTextAtCursorPosition = (0, _react.useCallback)(text => {
332
+ if (editorRef.current) {
333
+ (0, _insert.insertTextAtCursorPosition)({
334
+ editorElement: editorRef.current,
335
+ text
336
+ });
337
+ const newEvent = new Event('input', {
338
+ bubbles: true
339
+ });
340
+ editorRef.current.dispatchEvent(newEvent);
341
+ }
342
+ }, []);
343
+ const handleReplaceText = (0, _react.useCallback)((searchText, pasteText) => {
344
+ if (editorRef.current) {
345
+ (0, _insert.replaceText)({
346
+ editorElement: editorRef.current,
347
+ searchText,
348
+ pasteText
349
+ });
350
+ const newEvent = new Event('input', {
351
+ bubbles: true
352
+ });
353
+ editorRef.current.dispatchEvent(newEvent);
354
+ }
355
+ }, []);
356
+ const handleStartProgress = (0, _react.useCallback)(duration => {
357
+ setProgressDuration(duration);
358
+ }, []);
359
+ const handleStopProgress = (0, _react.useCallback)(() => {
360
+ setProgressDuration(0);
361
+ }, []);
362
+ (0, _react.useImperativeHandle)(ref, () => ({
363
+ insertTextAtCursorPosition: handleInsertTextAtCursorPosition,
364
+ replaceText: handleReplaceText,
365
+ startProgress: handleStartProgress,
366
+ stopProgress: handleStopProgress
367
+ }), [handleInsertTextAtCursorPosition, handleReplaceText, handleStartProgress, handleStopProgress]);
368
+ (0, _react.useEffect)(() => {
369
+ /**
370
+ * This function ensures that the input field does not lose focus when the popup is opened
371
+ * or an emoji is selected in it. For this purpose the corresponding elements get the class
372
+ * 'prevent-lose-focus'.
373
+ *
374
+ * The class can also be set to any other elements that should also not cause the input
375
+ * field to lose focus.
376
+ */
377
+ const handlePreventLoseFocus = event => {
378
+ var _element$parentElemen, _element$parentElemen2;
379
+ const element = event.target;
380
+ if (element.classList.contains('prevent-lose-focus') || (_element$parentElemen = element.parentElement) !== null && _element$parentElemen !== void 0 && _element$parentElemen.classList.contains('prevent-lose-focus') || (_element$parentElemen2 = element.parentElement) !== null && _element$parentElemen2 !== void 0 && (_element$parentElemen2 = _element$parentElemen2.parentElement) !== null && _element$parentElemen2 !== void 0 && _element$parentElemen2.classList.contains('prevent-lose-focus')) {
381
+ event.preventDefault();
382
+ event.stopPropagation();
383
+ }
384
+ };
385
+ document.body.addEventListener('mousedown', handlePreventLoseFocus);
386
+ return () => {
387
+ document.body.removeEventListener('mousedown', handlePreventLoseFocus);
388
+ };
389
+ }, []);
390
+ const shouldShowPlaceholder = (0, _react.useMemo)(() => {
391
+ var _editorRef$current2;
392
+ if (!isPrefixAnimationFinished) {
393
+ return false;
394
+ }
395
+ const isJustPrefixElement = prefixElement && (0, _text.convertTextToHTML)(prefixElement) === ((_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.innerHTML);
396
+ const shouldRenderPlaceholder = prefixElement && !plainTextValue || (prefixElement ? prefixElementWidth && prefixElementWidth > 0 : true);
397
+ switch (true) {
398
+ case (!plainTextValue || isJustPrefixElement) && shouldHidePlaceholderOnFocus && !hasFocus:
399
+ case (!plainTextValue || isJustPrefixElement) && !shouldHidePlaceholderOnFocus:
400
+ return shouldRenderPlaceholder;
401
+ case (!plainTextValue || isJustPrefixElement) && shouldHidePlaceholderOnFocus && hasFocus:
402
+ return false;
403
+ default:
404
+ return false;
405
+ }
406
+ }, [isPrefixAnimationFinished, hasFocus, plainTextValue, prefixElement, shouldHidePlaceholderOnFocus, prefixElementWidth]);
407
+ (0, _react.useEffect)(() => {
408
+ if (prefixElement) {
409
+ setIsPrefixAnimationFinished(false);
410
+ }
411
+ }, [prefixElement]);
412
+ const handleFocus = event => {
413
+ if (typeof onFocus === 'function' && !isDisabled) {
414
+ onFocus(event);
415
+ }
416
+ setHasFocus(true);
417
+ };
418
+ const handleBlur = event => {
419
+ if (typeof onBlur === 'function' && !isDisabled) {
420
+ onBlur(event);
421
+ }
422
+ setHasFocus(false);
423
+ };
424
+ (0, _react.useEffect)(() => {
425
+ if (editorRef.current && prefixElement) {
426
+ const text = (0, _emoji.convertEmojisToUnicode)(prefixElement);
427
+ (0, _insert.insertTextAtCursorPosition)({
428
+ editorElement: editorRef.current,
429
+ text
430
+ });
431
+ handleUpdateHTML(prefixElement);
432
+ hasPrefixRendered.current = true;
433
+ }
434
+ }, [handleUpdateHTML, prefixElement]);
435
+ (0, _react.useEffect)(() => {
436
+ var _editorRef$current3;
437
+ if (prefixElementRef.current && prefixElement && (0, _text.convertTextToHTML)(prefixElement) === ((_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.innerHTML)) {
438
+ setPrefixElementWidth(prefixElementRef.current.offsetWidth + 2);
439
+ } else {
440
+ setPrefixElementWidth(undefined);
441
+ }
442
+ }, [plainTextValue, prefixElement]);
443
+ (0, _react.useEffect)(() => {
444
+ const handleResize = () => {
445
+ if (editorRef.current) {
446
+ setLabelWidth(editorRef.current.offsetWidth);
447
+ }
448
+ };
449
+ const resizeObserver = new ResizeObserver(handleResize);
450
+ if (editorRef.current) {
451
+ resizeObserver.observe(editorRef.current);
452
+ }
453
+ return () => {
454
+ resizeObserver.disconnect();
455
+ };
456
+ }, []);
457
+ (0, _react.useEffect)(() => {
458
+ const blurElement = () => {
459
+ if (editorRef.current && document.activeElement === editorRef.current && isDisabled) {
460
+ editorRef.current.blur();
461
+ }
462
+ };
463
+ document.addEventListener('focus', blurElement, true);
464
+ return () => {
465
+ document.removeEventListener('focus', blurElement, true);
466
+ };
467
+ }, [isDisabled]);
468
+ return /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInput, {
469
+ $isDisabled: isDisabled,
470
+ $shouldChangeColor: shouldChangeColor
471
+ }, /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
472
+ initial: true
473
+ }, progressDuration > 0 && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledMotionEmojiInputProgress, {
474
+ animate: {
475
+ width: '100%'
476
+ },
477
+ exit: {
478
+ opacity: 0
479
+ },
480
+ initial: {
481
+ opacity: 1,
482
+ width: '0%'
483
+ },
484
+ transition: {
485
+ width: {
486
+ ease: 'linear',
487
+ duration: progressDuration
488
+ },
489
+ opacity: {
490
+ type: 'tween',
491
+ duration: 0.3
492
+ }
493
+ }
494
+ })), /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputContent, null, prefixElement && /*#__PURE__*/_react.default.createElement(_PrefixElement.default, {
495
+ key: prefixElement,
496
+ element: prefixElement,
497
+ prefixElementRef: prefixElementRef,
498
+ setIsPrefixAnimationFinished: setIsPrefixAnimationFinished
499
+ }), /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledMotionEmojiInputEditor, {
500
+ $browser: browser === null || browser === void 0 ? void 0 : browser.name,
501
+ animate: {
502
+ maxHeight: height ?? maxHeight,
503
+ minHeight: height ?? '26px'
504
+ },
505
+ contentEditable: !isDisabled,
506
+ id: inputId,
507
+ onBeforeInput: handleBeforeInput,
508
+ onBlur: handleBlur,
509
+ onFocus: handleFocus,
510
+ onInput: handleInput,
511
+ onKeyDown: handleKeyDown,
512
+ onPaste: handlePaste,
513
+ onDrop: handleDrop,
514
+ ref: editorRef,
515
+ $shouldShowContent: isPrefixAnimationFinished,
516
+ transition: {
517
+ type: 'tween',
518
+ duration: 0.2
519
+ }
520
+ }), shouldShowPlaceholder && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputLabel, {
521
+ $maxWidth: labelWidth,
522
+ $offsetWidth: prefixElementWidth
523
+ }, placeholder), !isTouch && !shouldPreventEmojiPicker && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.default, {
524
+ accessToken: accessToken,
525
+ onSelect: handlePopupSelect,
526
+ onPopupVisibilityChange: handlePopupVisibility,
527
+ personId: personId
528
+ })), rightElement && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputRightWrapper, null, rightElement));
529
+ });
530
+ EmojiInput.displayName = 'EmojiInput';
531
+ var _default = exports.default = EmojiInput;
532
+ //# sourceMappingURL=EmojiInput.js.map