@chayns-components/emoji-input 5.0.0-beta.104 → 5.0.0-beta.1040

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