@chayns-components/emoji-input 5.0.0-beta.136 → 5.0.0-beta.1360

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 (256) 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 +561 -0
  7. package/lib/cjs/components/emoji-input/EmojiInput.js.map +1 -0
  8. package/lib/cjs/components/emoji-input/EmojiInput.styles.js +131 -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 +44 -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 +64 -0
  13. package/lib/cjs/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
  14. package/lib/cjs/components/emoji-picker/EmojiPicker.js +47 -0
  15. package/lib/cjs/components/emoji-picker/EmojiPicker.js.map +1 -0
  16. package/lib/{components → cjs/components}/emoji-picker/EmojiPicker.styles.js +3 -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 +99 -0
  19. package/lib/cjs/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
  20. package/lib/{components → cjs/components}/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +4 -6
  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 +260 -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 +66 -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 +63 -34
  27. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  28. package/lib/{components → cjs/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +6 -3
  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 +98 -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 +51 -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 +2 -4
  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 +126 -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/cjs/hooks/cursor.js +110 -0
  49. package/lib/cjs/hooks/cursor.js.map +1 -0
  50. package/lib/{hooks → cjs/hooks}/emojiHistory.js +13 -15
  51. package/lib/cjs/hooks/emojiHistory.js.map +1 -0
  52. package/lib/{index.js → cjs/index.js} +28 -3
  53. package/lib/cjs/index.js.map +1 -0
  54. package/lib/cjs/types/api.js.map +1 -0
  55. package/lib/cjs/types/category.js.map +1 -0
  56. package/lib/cjs/utils/asyncEmojiData.js +10 -0
  57. package/lib/cjs/utils/asyncEmojiData.js.map +1 -0
  58. package/lib/cjs/utils/convertEmojisToUnicodeAsync.js +29 -0
  59. package/lib/cjs/utils/convertEmojisToUnicodeAsync.js.map +1 -0
  60. package/lib/{utils → cjs/utils}/emoji.js +17 -13
  61. package/lib/cjs/utils/emoji.js.map +1 -0
  62. package/lib/{constants/emoji.js → cjs/utils/emojiShortList.js} +4 -127
  63. package/lib/cjs/utils/emojiShortList.js.map +1 -0
  64. package/lib/cjs/utils/environment.js.map +1 -0
  65. package/lib/cjs/utils/font.js.map +1 -0
  66. package/lib/{utils → cjs/utils}/insert.js +47 -9
  67. package/lib/cjs/utils/insert.js.map +1 -0
  68. package/lib/cjs/utils/number.js +17 -0
  69. package/lib/cjs/utils/number.js.map +1 -0
  70. package/lib/cjs/utils/scroll.js +65 -0
  71. package/lib/cjs/utils/scroll.js.map +1 -0
  72. package/lib/cjs/utils/selection.js +351 -0
  73. package/lib/cjs/utils/selection.js.map +1 -0
  74. package/lib/cjs/utils/text.js +63 -0
  75. package/lib/cjs/utils/text.js.map +1 -0
  76. package/lib/esm/api/item-storage/get.js +29 -0
  77. package/lib/esm/api/item-storage/get.js.map +1 -0
  78. package/lib/esm/api/item-storage/put.js +34 -0
  79. package/lib/esm/api/item-storage/put.js.map +1 -0
  80. package/lib/esm/components/emoji-input/EmojiInput.js +542 -0
  81. package/lib/esm/components/emoji-input/EmojiInput.js.map +1 -0
  82. package/lib/esm/components/emoji-input/EmojiInput.styles.js +124 -0
  83. package/lib/esm/components/emoji-input/EmojiInput.styles.js.map +1 -0
  84. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js +37 -0
  85. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js.map +1 -0
  86. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js +57 -0
  87. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
  88. package/lib/esm/components/emoji-picker/EmojiPicker.js +39 -0
  89. package/lib/esm/components/emoji-picker/EmojiPicker.js.map +1 -0
  90. package/lib/esm/components/emoji-picker/EmojiPicker.styles.js +16 -0
  91. package/lib/esm/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
  92. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +91 -0
  93. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
  94. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +18 -0
  95. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
  96. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +251 -0
  97. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
  98. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +59 -0
  99. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
  100. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +137 -0
  101. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  102. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +17 -0
  103. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
  104. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +120 -0
  105. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
  106. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +91 -0
  107. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
  108. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js +42 -0
  109. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
  110. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js +8 -0
  111. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
  112. package/lib/esm/constants/alignment.js +13 -0
  113. package/lib/esm/constants/alignment.js.map +1 -0
  114. package/lib/esm/constants/categories.js +13 -0
  115. package/lib/esm/constants/categories.js.map +1 -0
  116. package/lib/esm/constants/emoji-de-DE.json +3827 -0
  117. package/lib/esm/constants/emoji.js +120 -0
  118. package/lib/esm/constants/emoji.js.map +1 -0
  119. package/lib/esm/constants/externalServerUrl.js +2 -0
  120. package/lib/esm/constants/externalServerUrl.js.map +1 -0
  121. package/lib/esm/constants/regex.js +9 -0
  122. package/lib/esm/constants/regex.js.map +1 -0
  123. package/lib/esm/hooks/cursor.js +103 -0
  124. package/lib/esm/hooks/cursor.js.map +1 -0
  125. package/lib/esm/hooks/emojiHistory.js +81 -0
  126. package/lib/esm/hooks/emojiHistory.js.map +1 -0
  127. package/lib/{index.d.ts → esm/index.js} +3 -1
  128. package/lib/esm/index.js.map +1 -0
  129. package/lib/esm/types/api.js +2 -0
  130. package/lib/esm/types/api.js.map +1 -0
  131. package/lib/esm/types/category.js +2 -0
  132. package/lib/esm/types/category.js.map +1 -0
  133. package/lib/esm/utils/asyncEmojiData.js +2 -0
  134. package/lib/esm/utils/asyncEmojiData.js.map +1 -0
  135. package/lib/esm/utils/convertEmojisToUnicodeAsync.js +20 -0
  136. package/lib/esm/utils/convertEmojisToUnicodeAsync.js.map +1 -0
  137. package/lib/esm/utils/emoji.js +90 -0
  138. package/lib/esm/utils/emoji.js.map +1 -0
  139. package/lib/esm/utils/emojiShortList.js +3679 -0
  140. package/lib/esm/utils/emojiShortList.js.map +1 -0
  141. package/lib/esm/utils/environment.js +24 -0
  142. package/lib/esm/utils/environment.js.map +1 -0
  143. package/lib/esm/utils/font.js +10 -0
  144. package/lib/esm/utils/font.js.map +1 -0
  145. package/lib/esm/utils/insert.js +104 -0
  146. package/lib/esm/utils/insert.js.map +1 -0
  147. package/lib/esm/utils/number.js +10 -0
  148. package/lib/esm/utils/number.js.map +1 -0
  149. package/lib/esm/utils/scroll.js +58 -0
  150. package/lib/esm/utils/scroll.js.map +1 -0
  151. package/lib/esm/utils/selection.js +324 -0
  152. package/lib/esm/utils/selection.js.map +1 -0
  153. package/lib/esm/utils/text.js +54 -0
  154. package/lib/esm/utils/text.js.map +1 -0
  155. package/lib/types/components/emoji-input/EmojiInput.d.ts +101 -0
  156. package/lib/types/components/emoji-input/EmojiInput.styles.d.ts +26 -0
  157. package/lib/types/components/emoji-input/prefix-element/PrefixElement.d.ts +8 -0
  158. package/lib/types/components/emoji-input/prefix-element/PrefixElement.styles.d.ts +12 -0
  159. package/lib/types/components/emoji-picker/EmojiPicker.styles.d.ts +5 -0
  160. package/lib/types/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +4 -0
  161. package/lib/types/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +9 -0
  162. package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.d.ts +10 -0
  163. package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +6 -0
  164. package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +5 -0
  165. package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +20 -0
  166. package/lib/{components → types/components}/emoji-picker-popup/EmojiPickerPopup.d.ts +0 -13
  167. package/lib/types/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +1 -0
  168. package/lib/types/constants/emoji.d.ts +4 -0
  169. package/lib/types/constants/regex.d.ts +8 -0
  170. package/lib/types/hooks/cursor.d.ts +11 -0
  171. package/lib/types/index.d.ts +7 -0
  172. package/lib/types/utils/asyncEmojiData.d.ts +1 -0
  173. package/lib/types/utils/convertEmojisToUnicodeAsync.d.ts +3 -0
  174. package/lib/types/utils/emoji.d.ts +10 -0
  175. package/lib/{constants/emoji.d.ts → types/utils/emojiShortList.d.ts} +0 -4
  176. package/lib/{utils → types/utils}/insert.d.ts +10 -1
  177. package/lib/types/utils/number.d.ts +1 -0
  178. package/lib/types/utils/scroll.d.ts +1 -0
  179. package/lib/types/utils/selection.d.ts +30 -0
  180. package/lib/types/utils/text.d.ts +5 -0
  181. package/package.json +50 -31
  182. package/lib/api/item-storage/get.js.map +0 -1
  183. package/lib/api/item-storage/put.js.map +0 -1
  184. package/lib/components/emoji-input/EmojiInput.d.ts +0 -55
  185. package/lib/components/emoji-input/EmojiInput.js +0 -163
  186. package/lib/components/emoji-input/EmojiInput.js.map +0 -1
  187. package/lib/components/emoji-input/EmojiInput.styles.d.ts +0 -13
  188. package/lib/components/emoji-input/EmojiInput.styles.js +0 -154
  189. package/lib/components/emoji-input/EmojiInput.styles.js.map +0 -1
  190. package/lib/components/emoji-picker/EmojiPicker.js +0 -51
  191. package/lib/components/emoji-picker/EmojiPicker.js.map +0 -1
  192. package/lib/components/emoji-picker/EmojiPicker.styles.d.ts +0 -5
  193. package/lib/components/emoji-picker/EmojiPicker.styles.js.map +0 -1
  194. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +0 -51
  195. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +0 -1
  196. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +0 -2
  197. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +0 -1
  198. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +0 -131
  199. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +0 -1
  200. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +0 -7
  201. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +0 -99
  202. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +0 -1
  203. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +0 -1
  204. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +0 -1
  205. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +0 -1
  206. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +0 -74
  207. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +0 -1
  208. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +0 -11
  209. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +0 -104
  210. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +0 -1
  211. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +0 -150
  212. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +0 -1
  213. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +0 -7
  214. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js +0 -97
  215. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +0 -1
  216. package/lib/constants/alignment.js.map +0 -1
  217. package/lib/constants/categories.js.map +0 -1
  218. package/lib/constants/emoji.js.map +0 -1
  219. package/lib/constants/externalServerUrl.js +0 -9
  220. package/lib/constants/externalServerUrl.js.map +0 -1
  221. package/lib/constants/regex.d.ts +0 -2
  222. package/lib/constants/regex.js +0 -11
  223. package/lib/constants/regex.js.map +0 -1
  224. package/lib/hooks/emojiHistory.js.map +0 -1
  225. package/lib/index.js.map +0 -1
  226. package/lib/types/api.js.map +0 -1
  227. package/lib/types/category.js.map +0 -1
  228. package/lib/utils/emoji.d.ts +0 -3
  229. package/lib/utils/emoji.js.map +0 -1
  230. package/lib/utils/environment.js.map +0 -1
  231. package/lib/utils/font.js.map +0 -1
  232. package/lib/utils/insert.js.map +0 -1
  233. package/lib/utils/selection.d.ts +0 -8
  234. package/lib/utils/selection.js +0 -89
  235. package/lib/utils/selection.js.map +0 -1
  236. package/lib/utils/text.d.ts +0 -2
  237. package/lib/utils/text.js +0 -25
  238. package/lib/utils/text.js.map +0 -1
  239. /package/lib/{constants → cjs/constants}/emoji-de-DE.json +0 -0
  240. /package/lib/{types → cjs/types}/api.js +0 -0
  241. /package/lib/{types → cjs/types}/category.js +0 -0
  242. /package/lib/{utils → cjs/utils}/environment.js +0 -0
  243. /package/lib/{utils → cjs/utils}/font.js +0 -0
  244. /package/lib/{api → types/api}/item-storage/get.d.ts +0 -0
  245. /package/lib/{api → types/api}/item-storage/put.d.ts +0 -0
  246. /package/lib/{components → types/components}/emoji-picker/EmojiPicker.d.ts +0 -0
  247. /package/lib/{components → types/components}/emoji-picker/emoji-picker-categories/EmojiPickerCategories.d.ts +0 -0
  248. /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.d.ts +0 -0
  249. /package/lib/{constants → types/constants}/alignment.d.ts +0 -0
  250. /package/lib/{constants → types/constants}/categories.d.ts +0 -0
  251. /package/lib/{constants → types/constants}/externalServerUrl.d.ts +0 -0
  252. /package/lib/{hooks → types/hooks}/emojiHistory.d.ts +0 -0
  253. /package/lib/types/{api.d.ts → types/api.d.ts} +0 -0
  254. /package/lib/types/{category.d.ts → types/category.d.ts} +0 -0
  255. /package/lib/{utils → types/utils}/environment.d.ts +0 -0
  256. /package/lib/{utils → types/utils}/font.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,561 @@
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 _react = require("motion/react");
10
+ var _react2 = _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
+ var _asyncEmojiData = require("../../utils/asyncEmojiData");
19
+ var _scroll = require("../../utils/scroll");
20
+ var _cursor = require("../../hooks/cursor");
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
23
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react2.useLayoutEffect : _react2.useEffect;
24
+ const EmojiInput = /*#__PURE__*/(0, _react2.forwardRef)(({
25
+ accessToken,
26
+ height,
27
+ inputId,
28
+ isDisabled,
29
+ maxHeight = '190px',
30
+ onBlur,
31
+ onFocus,
32
+ onInput,
33
+ onKeyDown,
34
+ onPrefixElementRemove,
35
+ onPopupVisibilityChange,
36
+ personId,
37
+ placeholder,
38
+ popupAlignment,
39
+ prefixElement,
40
+ rightElement,
41
+ shouldHidePlaceholderOnFocus = false,
42
+ shouldPreventEmojiPicker,
43
+ value,
44
+ onCursorPositionChange
45
+ }, ref) => {
46
+ const isTouch = (0, _core.useIsTouch)();
47
+ const [plainTextValue, setPlainTextValue] = (0, _react2.useState)(value);
48
+ const [hasFocus, setHasFocus] = (0, _react2.useState)(false);
49
+ const [progressDuration, setProgressDuration] = (0, _react2.useState)(0);
50
+ const [labelWidth, setLabelWidth] = (0, _react2.useState)(0);
51
+ const [isPopupVisible, setIsPopupVisible] = (0, _react2.useState)(false);
52
+ const [isPrefixAnimationFinished, setIsPrefixAnimationFinished] = (0, _react2.useState)(!prefixElement);
53
+ const [prefixElementWidth, setPrefixElementWidth] = (0, _react2.useState)();
54
+ const [emojiShortNames, setEmojiShortNames] = (0, _react2.useState)({});
55
+ const [emojiRegShortNames, setEmojiRegShortNames] = (0, _react2.useState)(/./);
56
+ const areaProvider = (0, _react2.useContext)(_core.AreaContext);
57
+ const editorRef = (0, _react2.useRef)(null);
58
+ const prefixElementRef = (0, _react2.useRef)(null);
59
+ const hasPrefixRendered = (0, _react2.useRef)(false);
60
+ const hasPrefixChanged = (0, _react2.useRef)(false);
61
+ const shouldDeleteOneMoreBackwards = (0, _react2.useRef)(false);
62
+ const shouldDeleteOneMoreForwards = (0, _react2.useRef)(false);
63
+ const valueRef = (0, _react2.useRef)(value);
64
+ (0, _cursor.useCursorPosition)(editorRef, onCursorPositionChange, {
65
+ isDisabled
66
+ });
67
+ const {
68
+ browser
69
+ } = (0, _chaynsApi.getDevice)();
70
+ const shouldChangeColor = (0, _react2.useMemo)(() => areaProvider.shouldChangeColor ?? false, [areaProvider.shouldChangeColor]);
71
+ (0, _react2.useEffect)(() => {
72
+ void (0, _asyncEmojiData.loadEmojiShortList)().then(({
73
+ shortNameList,
74
+ regShortnames
75
+ }) => {
76
+ setEmojiShortNames(shortNameList);
77
+ setEmojiRegShortNames(regShortnames);
78
+ });
79
+ }, []);
80
+
81
+ /**
82
+ * This function updates the content of the 'contentEditable' element if the new text is
83
+ * different from the previous content. So this is only true if, for example, a text like ":-)"
84
+ * has been replaced to the corresponding emoji.
85
+ *
86
+ * When updating the HTML, the current cursor position is saved before replacing the content, so
87
+ * that it can be set again afterward.
88
+ */
89
+ const handleUpdateHTML = (0, _react2.useCallback)(html => {
90
+ if (!editorRef.current) {
91
+ return;
92
+ }
93
+ let newInnerHTML = (0, _emoji.convertEmojisToUnicode)(html, emojiRegShortNames, emojiShortNames);
94
+ newInnerHTML = (0, _text.convertTextToHTML)(newInnerHTML);
95
+ if (newInnerHTML !== editorRef.current.innerHTML) {
96
+ (0, _selection.saveSelection)(editorRef.current, {
97
+ shouldIgnoreEmptyTextNodes: true
98
+ });
99
+ editorRef.current.innerHTML = newInnerHTML;
100
+ (0, _selection.restoreSelection)(editorRef.current);
101
+ }
102
+ }, [emojiRegShortNames, emojiShortNames]);
103
+ const handleBeforeInput = (0, _react2.useCallback)(event => {
104
+ if (!editorRef.current) {
105
+ return;
106
+ }
107
+ if (isDisabled) {
108
+ event.preventDefault();
109
+ event.stopPropagation();
110
+ return;
111
+ }
112
+ const {
113
+ data,
114
+ type
115
+ } = event.nativeEvent;
116
+ if (type === 'textInput' && data && data.includes('\n')) {
117
+ event.preventDefault();
118
+ event.stopPropagation();
119
+ const text = (0, _emoji.convertEmojisToUnicode)(data, emojiRegShortNames, emojiShortNames);
120
+ (0, _insert.insertTextAtCursorPosition)({
121
+ editorElement: editorRef.current,
122
+ text
123
+ });
124
+ const newEvent = new Event('input', {
125
+ bubbles: true
126
+ });
127
+ editorRef.current.dispatchEvent(newEvent);
128
+ }
129
+ }, [emojiRegShortNames, emojiShortNames, isDisabled]);
130
+
131
+ /**
132
+ * This function handles the 'input' events of the 'contentEditable' element and also passes the
133
+ * respective event up accordingly if the 'onInput' property is a function.
134
+ */
135
+ const handleInput = (0, _react2.useCallback)(event => {
136
+ if (!editorRef.current) {
137
+ return;
138
+ }
139
+ if (isDisabled) {
140
+ event.stopPropagation();
141
+ event.preventDefault();
142
+ }
143
+ if (shouldDeleteOneMoreBackwards.current) {
144
+ shouldDeleteOneMoreBackwards.current = false;
145
+ shouldDeleteOneMoreForwards.current = false;
146
+ event.preventDefault();
147
+ event.stopPropagation();
148
+
149
+ // Remove content and set cursor to the right position
150
+ (0, _selection.insertInvisibleCursorMarker)();
151
+ return;
152
+ }
153
+ if (shouldDeleteOneMoreForwards.current) {
154
+ shouldDeleteOneMoreBackwards.current = false;
155
+ shouldDeleteOneMoreForwards.current = false;
156
+ event.preventDefault();
157
+ event.stopPropagation();
158
+
159
+ // noinspection JSDeprecatedSymbols
160
+ document.execCommand('forwardDelete', false);
161
+ return;
162
+ }
163
+ handleUpdateHTML(editorRef.current.innerHTML);
164
+ const text = (0, _text.convertHTMLToText)(editorRef.current.innerHTML);
165
+ setPlainTextValue(text);
166
+ if (typeof onInput === 'function') {
167
+ onInput(event, text);
168
+ }
169
+ (0, _selection.insertCursorAtMarker)(editorRef);
170
+ }, [handleUpdateHTML, isDisabled, onInput]);
171
+ const handleKeyDown = (0, _react2.useCallback)(event => {
172
+ if (isDisabled) {
173
+ event.preventDefault();
174
+ event.stopPropagation();
175
+ return;
176
+ }
177
+ if (event.key === 'Enter' && isPopupVisible) {
178
+ event.preventDefault();
179
+ return;
180
+ }
181
+ if (typeof onKeyDown === 'function') {
182
+ onKeyDown(event);
183
+ }
184
+ if (event.key === 'Enter' && !event.isPropagationStopped() && editorRef.current) {
185
+ event.preventDefault();
186
+
187
+ // noinspection JSDeprecatedSymbols
188
+ document.execCommand('insertLineBreak', false);
189
+ }
190
+ if (event.key === 'Enter') {
191
+ requestAnimationFrame(() => {
192
+ if (editorRef.current) (0, _scroll.scrollCursorIntoView)(editorRef.current);
193
+ });
194
+ }
195
+ if (event.key === 'Backspace' || event.key === 'Delete' || event.key === 'Unidentified') {
196
+ const charCodeThatWillBeDeleted = (0, _selection.getCharCodeThatWillBeDeleted)(event);
197
+ if (charCodeThatWillBeDeleted === 8203) {
198
+ if (event.key === 'Backspace' || event.key === 'Unidentified') {
199
+ shouldDeleteOneMoreBackwards.current = true;
200
+ } else {
201
+ shouldDeleteOneMoreForwards.current = true;
202
+ }
203
+ }
204
+ }
205
+ }, [isDisabled, isPopupVisible, onKeyDown]);
206
+ const handlePopupVisibility = (0, _react2.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, _react2.useCallback)(event => {
222
+ if (editorRef.current) {
223
+ event.preventDefault();
224
+ if (isDisabled) {
225
+ event.stopPropagation();
226
+ return;
227
+ }
228
+
229
+ // This ensures, that only the copied text is inserted and not its HTML formatting.
230
+ let text = event.clipboardData.getData('text/plain');
231
+ text = (0, _emoji.convertEmojisToUnicode)(text, emojiRegShortNames, emojiShortNames);
232
+
233
+ /* This ensures, that valid HTML in the inserted text is not interpreted as such. e.g. if the user
234
+ pasted the text '<b>test</b>' (not as formatted html), the <b> tags need to be escaped, to
235
+ prevent it from being interpreted as html. */
236
+ text = (0, _emoji.escapeHTML)(text);
237
+
238
+ // Insert an invisible control character at the end of the text to place the cursor in the correct position after insertion.
239
+ if (text.includes('\n')) {
240
+ text += '\u200C';
241
+ }
242
+
243
+ // This deprecated function is used, because it causes the inserted content to be added to the undo stack.
244
+ // If the text were to be inserted directly into the 'innerHTML' of the editor element, the undo stack would not be updated.
245
+ // In that case on CTRL+Z the inserted text would not be removed.
246
+ document.execCommand('insertHTML', false, text);
247
+ const newEvent = new Event('input', {
248
+ bubbles: true
249
+ });
250
+ editorRef.current.dispatchEvent(newEvent);
251
+ }
252
+ }, [emojiRegShortNames, emojiShortNames, isDisabled]);
253
+
254
+ /**
255
+ * This function prevents formatting from being adopted when texts are dropped. To do this, the
256
+ * plain text is read from the event after the default behavior has been prevented. The plain
257
+ * text is then inserted at the correct position in the input field using document.execCommand('insertHTML')
258
+ */
259
+ const handleDrop = (0, _react2.useCallback)(event => {
260
+ if (editorRef.current) {
261
+ var _event$dataTransfer;
262
+ event.preventDefault();
263
+ if (isDisabled) {
264
+ event.stopPropagation();
265
+ return;
266
+ }
267
+
268
+ // This ensures, that only the dropped text is inserted and not its HTML formatting.
269
+ let text = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.getData('text');
270
+ if (!text) {
271
+ return;
272
+ }
273
+ text = (0, _emoji.convertEmojisToUnicode)(text, emojiRegShortNames, emojiShortNames);
274
+
275
+ /* This ensures, that valid HTML in the inserted text is not interpreted as such. e.g. if the user
276
+ drops the text '<b>test</b>' (not as formatted html), the <b> tags need to be escaped, to
277
+ prevent it from being interpreted as html. */
278
+ text = (0, _emoji.escapeHTML)(text);
279
+
280
+ // This deprecated function is used, because it causes the inserted content to be added to the undo stack.
281
+ // If the text were to be inserted directly into the 'innerHTML' of the editor element, the undo stack would not be updated.
282
+ // In that case on CTRL+Z the inserted text would not be removed.
283
+ document.execCommand('insertHTML', false, text);
284
+ const newEvent = new Event('input', {
285
+ bubbles: true
286
+ });
287
+ editorRef.current.dispatchEvent(newEvent);
288
+ }
289
+ }, [emojiRegShortNames, emojiShortNames, isDisabled]);
290
+
291
+ /**
292
+ * This function uses the 'insertTextAtCursorPosition' function to insert the emoji at the
293
+ * correct position in the editor element.
294
+ *
295
+ * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,
296
+ * which in turn executes the 'onInput' function from the props. So this serves to ensure that
297
+ * the event is also passed through to the top when inserting via the popup.
298
+ */
299
+ const handlePopupSelect = (0, _react2.useCallback)(emoji => {
300
+ if (editorRef.current) {
301
+ (0, _insert.insertTextAtCursorPosition)({
302
+ editorElement: editorRef.current,
303
+ text: emoji,
304
+ shouldUseSavedSelection: true
305
+ });
306
+ const event = new Event('input', {
307
+ bubbles: true
308
+ });
309
+ editorRef.current.dispatchEvent(event);
310
+ }
311
+ }, []);
312
+ (0, _react2.useEffect)(() => {
313
+ var _editorRef$current;
314
+ if (typeof onPrefixElementRemove !== 'function') {
315
+ return;
316
+ }
317
+ if (!hasPrefixRendered.current) {
318
+ return;
319
+ }
320
+ const convertedText = (0, _text.convertHTMLToText)(((_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.innerHTML) ?? '').replace('&nbsp;', ' ');
321
+ const convertedPrefix = prefixElement && prefixElement.replace('&nbsp;', ' ');
322
+ if (convertedPrefix && convertedText.includes(convertedPrefix) && convertedText.length > convertedPrefix.length || convertedPrefix === convertedText) {
323
+ return;
324
+ }
325
+ if (hasPrefixChanged.current) {
326
+ hasPrefixChanged.current = false;
327
+ return;
328
+ }
329
+ onPrefixElementRemove();
330
+ hasPrefixRendered.current = false;
331
+ }, [onPrefixElementRemove, plainTextValue.length, prefixElement]);
332
+ (0, _react2.useEffect)(() => {
333
+ if (typeof prefixElement === 'string') {
334
+ hasPrefixChanged.current = true;
335
+ }
336
+ }, [prefixElement]);
337
+ (0, _react2.useEffect)(() => {
338
+ if (value !== plainTextValue) {
339
+ setPlainTextValue(value);
340
+ handleUpdateHTML(value);
341
+ }
342
+ }, [handleUpdateHTML, plainTextValue, value]);
343
+
344
+ // This effect is used to call the 'handleUpdateHTML' function once after the component has been
345
+ // rendered. This is necessary because the 'contentEditable' element otherwise does not display
346
+ // the HTML content correctly when the component is rendered for the first time.
347
+ useIsomorphicLayoutEffect(() => {
348
+ handleUpdateHTML(valueRef.current);
349
+ }, [handleUpdateHTML]);
350
+ const handleInsertTextAtCursorPosition = (0, _react2.useCallback)(text => {
351
+ if (editorRef.current) {
352
+ (0, _insert.insertTextAtCursorPosition)({
353
+ editorElement: editorRef.current,
354
+ text
355
+ });
356
+ const newEvent = new Event('input', {
357
+ bubbles: true
358
+ });
359
+ editorRef.current.dispatchEvent(newEvent);
360
+ }
361
+ }, []);
362
+ const handleReplaceText = (0, _react2.useCallback)((searchText, pasteText, options) => {
363
+ if (editorRef.current) {
364
+ (0, _insert.replaceText)({
365
+ editorElement: editorRef.current,
366
+ searchText,
367
+ pasteText,
368
+ options
369
+ });
370
+ (0, _selection.insertPseudoMarker)();
371
+ const newEvent = new Event('input', {
372
+ bubbles: true
373
+ });
374
+ editorRef.current.dispatchEvent(newEvent);
375
+ }
376
+ }, []);
377
+ const handleStartProgress = (0, _react2.useCallback)(duration => {
378
+ setProgressDuration(duration);
379
+ }, []);
380
+ const handleStopProgress = (0, _react2.useCallback)(() => {
381
+ setProgressDuration(0);
382
+ }, []);
383
+ (0, _react2.useImperativeHandle)(ref, () => ({
384
+ insertTextAtCursorPosition: handleInsertTextAtCursorPosition,
385
+ replaceText: handleReplaceText,
386
+ startProgress: handleStartProgress,
387
+ stopProgress: handleStopProgress,
388
+ focus: () => {
389
+ var _editorRef$current2;
390
+ return (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.focus();
391
+ },
392
+ blur: () => {
393
+ var _editorRef$current3;
394
+ return (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.blur();
395
+ }
396
+ }), [handleInsertTextAtCursorPosition, handleReplaceText, handleStartProgress, handleStopProgress]);
397
+ (0, _react2.useEffect)(() => {
398
+ /**
399
+ * This function ensures that the input field does not lose focus when the popup is opened
400
+ * or an emoji is selected in it. For this purpose the corresponding elements get the class
401
+ * 'prevent-lose-focus'.
402
+ *
403
+ * The class can also be set to any other elements that should also not cause the input
404
+ * field to lose focus.
405
+ */
406
+ const handlePreventLoseFocus = event => {
407
+ var _element$parentElemen, _element$parentElemen2;
408
+ const element = event.target;
409
+ 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')) {
410
+ event.preventDefault();
411
+ event.stopPropagation();
412
+ }
413
+ };
414
+ document.body.addEventListener('mousedown', handlePreventLoseFocus);
415
+ return () => {
416
+ document.body.removeEventListener('mousedown', handlePreventLoseFocus);
417
+ };
418
+ }, []);
419
+ const shouldShowPlaceholder = (0, _react2.useMemo)(() => {
420
+ var _editorRef$current4;
421
+ if (!isPrefixAnimationFinished) {
422
+ return false;
423
+ }
424
+ const isJustPrefixElement = prefixElement && (0, _text.convertTextToHTML)(prefixElement) === ((_editorRef$current4 = editorRef.current) === null || _editorRef$current4 === void 0 ? void 0 : _editorRef$current4.innerHTML);
425
+ const shouldRenderPlaceholder = prefixElement && !plainTextValue || (prefixElement ? prefixElementWidth && prefixElementWidth > 0 : true);
426
+ switch (true) {
427
+ case (!plainTextValue || isJustPrefixElement) && shouldHidePlaceholderOnFocus && !hasFocus:
428
+ case (!plainTextValue || isJustPrefixElement) && !shouldHidePlaceholderOnFocus:
429
+ return shouldRenderPlaceholder;
430
+ case (!plainTextValue || isJustPrefixElement) && shouldHidePlaceholderOnFocus && hasFocus:
431
+ return false;
432
+ default:
433
+ return false;
434
+ }
435
+ }, [isPrefixAnimationFinished, hasFocus, plainTextValue, prefixElement, shouldHidePlaceholderOnFocus, prefixElementWidth]);
436
+ (0, _react2.useEffect)(() => {
437
+ if (prefixElement) {
438
+ setIsPrefixAnimationFinished(false);
439
+ }
440
+ }, [prefixElement]);
441
+ const handleFocus = event => {
442
+ if (typeof onFocus === 'function' && !isDisabled) {
443
+ onFocus(event);
444
+ }
445
+ setHasFocus(true);
446
+ };
447
+ const handleBlur = event => {
448
+ if (typeof onBlur === 'function' && !isDisabled) {
449
+ onBlur(event);
450
+ }
451
+ setHasFocus(false);
452
+ };
453
+ (0, _react2.useEffect)(() => {
454
+ if (editorRef.current && prefixElement) {
455
+ const text = (0, _emoji.convertEmojisToUnicode)(prefixElement, emojiRegShortNames, emojiShortNames);
456
+ (0, _insert.insertTextAtCursorPosition)({
457
+ editorElement: editorRef.current,
458
+ text
459
+ });
460
+ handleUpdateHTML(prefixElement);
461
+ hasPrefixRendered.current = true;
462
+ }
463
+ }, [emojiRegShortNames, emojiShortNames, handleUpdateHTML, prefixElement]);
464
+ (0, _react2.useEffect)(() => {
465
+ var _editorRef$current5;
466
+ if (prefixElementRef.current && prefixElement && (0, _text.convertTextToHTML)(prefixElement) === ((_editorRef$current5 = editorRef.current) === null || _editorRef$current5 === void 0 ? void 0 : _editorRef$current5.innerHTML)) {
467
+ setPrefixElementWidth(prefixElementRef.current.offsetWidth + 2);
468
+ } else {
469
+ setPrefixElementWidth(undefined);
470
+ }
471
+ }, [plainTextValue, prefixElement]);
472
+ (0, _react2.useEffect)(() => {
473
+ const handleResize = () => {
474
+ if (editorRef.current) {
475
+ setLabelWidth(editorRef.current.offsetWidth);
476
+ }
477
+ };
478
+ const resizeObserver = new ResizeObserver(handleResize);
479
+ if (editorRef.current) {
480
+ resizeObserver.observe(editorRef.current);
481
+ }
482
+ return () => {
483
+ resizeObserver.disconnect();
484
+ };
485
+ }, []);
486
+ (0, _react2.useEffect)(() => {
487
+ const blurElement = () => {
488
+ if (editorRef.current && document.activeElement === editorRef.current && isDisabled) {
489
+ editorRef.current.blur();
490
+ }
491
+ };
492
+ document.addEventListener('focus', blurElement, true);
493
+ return () => {
494
+ document.removeEventListener('focus', blurElement, true);
495
+ };
496
+ }, [isDisabled]);
497
+ return /*#__PURE__*/_react2.default.createElement(_EmojiInput.StyledEmojiInput, {
498
+ $isDisabled: isDisabled,
499
+ $shouldChangeColor: shouldChangeColor
500
+ }, /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
501
+ initial: true
502
+ }, progressDuration > 0 && /*#__PURE__*/_react2.default.createElement(_EmojiInput.StyledMotionEmojiInputProgress, {
503
+ animate: {
504
+ width: '100%'
505
+ },
506
+ exit: {
507
+ opacity: 0
508
+ },
509
+ initial: {
510
+ opacity: 1,
511
+ width: '0%'
512
+ },
513
+ transition: {
514
+ width: {
515
+ ease: 'linear',
516
+ duration: progressDuration
517
+ },
518
+ opacity: {
519
+ type: 'tween',
520
+ duration: 0.3
521
+ }
522
+ }
523
+ })), /*#__PURE__*/_react2.default.createElement(_EmojiInput.StyledEmojiInputContent, null, prefixElement && /*#__PURE__*/_react2.default.createElement(_PrefixElement.default, {
524
+ key: prefixElement,
525
+ element: prefixElement,
526
+ prefixElementRef: prefixElementRef,
527
+ setIsPrefixAnimationFinished: setIsPrefixAnimationFinished
528
+ }), /*#__PURE__*/_react2.default.createElement(_EmojiInput.StyledMotionEmojiInputEditor, {
529
+ $browser: browser === null || browser === void 0 ? void 0 : browser.name,
530
+ animate: {
531
+ maxHeight: height ?? maxHeight,
532
+ minHeight: height ?? '26px'
533
+ },
534
+ contentEditable: true,
535
+ id: inputId,
536
+ onBeforeInput: handleBeforeInput,
537
+ onBlur: handleBlur,
538
+ onFocus: handleFocus,
539
+ onInput: handleInput,
540
+ onKeyDown: handleKeyDown,
541
+ onPaste: handlePaste,
542
+ onDrop: handleDrop,
543
+ ref: editorRef,
544
+ $shouldShowContent: isPrefixAnimationFinished,
545
+ transition: {
546
+ type: 'tween',
547
+ duration: 0.2
548
+ }
549
+ }), shouldShowPlaceholder && /*#__PURE__*/_react2.default.createElement(_EmojiInput.StyledEmojiInputLabel, {
550
+ $maxWidth: labelWidth,
551
+ $offsetWidth: prefixElementWidth
552
+ }, placeholder), !isTouch && !shouldPreventEmojiPicker && /*#__PURE__*/_react2.default.createElement(_EmojiPickerPopup.default, {
553
+ accessToken: accessToken,
554
+ onSelect: handlePopupSelect,
555
+ onPopupVisibilityChange: handlePopupVisibility,
556
+ personId: personId
557
+ })), rightElement && /*#__PURE__*/_react2.default.createElement(_EmojiInput.StyledEmojiInputRightWrapper, null, rightElement));
558
+ });
559
+ EmojiInput.displayName = 'EmojiInput';
560
+ var _default = exports.default = EmojiInput;
561
+ //# sourceMappingURL=EmojiInput.js.map