@chayns-components/emoji-input 5.0.0-beta.98 → 5.0.0-beta.982

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 (229) 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 +510 -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 +5 -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 +69 -0
  25. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
  26. package/lib/{components → cjs/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +49 -21
  27. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  28. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +24 -0
  29. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
  30. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +130 -0
  31. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
  32. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +99 -0
  33. package/lib/cjs/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
  34. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.js +52 -0
  35. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
  36. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.styles.js +15 -0
  37. package/lib/cjs/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
  38. package/lib/{constants → cjs/constants}/alignment.js +6 -8
  39. package/lib/cjs/constants/alignment.js.map +1 -0
  40. package/lib/{constants → cjs/constants}/categories.js +1 -2
  41. package/lib/cjs/constants/categories.js.map +1 -0
  42. package/lib/{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/{utils → cjs/utils}/environment.js +6 -4
  59. package/lib/cjs/utils/environment.js.map +1 -0
  60. package/lib/cjs/utils/font.js +17 -0
  61. package/lib/cjs/utils/font.js.map +1 -0
  62. package/lib/cjs/utils/insert.js +110 -0
  63. package/lib/cjs/utils/insert.js.map +1 -0
  64. package/lib/cjs/utils/number.js +17 -0
  65. package/lib/cjs/utils/number.js.map +1 -0
  66. package/lib/cjs/utils/selection.js +255 -0
  67. package/lib/cjs/utils/selection.js.map +1 -0
  68. package/lib/cjs/utils/text.js +57 -0
  69. package/lib/cjs/utils/text.js.map +1 -0
  70. package/lib/esm/api/item-storage/get.js +30 -0
  71. package/lib/esm/api/item-storage/get.js.map +1 -0
  72. package/lib/esm/api/item-storage/put.js +35 -0
  73. package/lib/esm/api/item-storage/put.js.map +1 -0
  74. package/lib/esm/components/emoji-input/EmojiInput.js +497 -0
  75. package/lib/esm/components/emoji-input/EmojiInput.js.map +1 -0
  76. package/lib/esm/components/emoji-input/EmojiInput.styles.js +151 -0
  77. package/lib/esm/components/emoji-input/EmojiInput.styles.js.map +1 -0
  78. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js +38 -0
  79. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.js.map +1 -0
  80. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js +69 -0
  81. package/lib/esm/components/emoji-input/prefix-element/PrefixElement.styles.js.map +1 -0
  82. package/lib/esm/components/emoji-picker/EmojiPicker.js +40 -0
  83. package/lib/esm/components/emoji-picker/EmojiPicker.js.map +1 -0
  84. package/lib/esm/components/emoji-picker/EmojiPicker.styles.js +16 -0
  85. package/lib/esm/components/emoji-picker/EmojiPicker.styles.js.map +1 -0
  86. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +96 -0
  87. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +1 -0
  88. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js +18 -0
  89. package/lib/esm/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +1 -0
  90. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +240 -0
  91. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +1 -0
  92. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +76 -0
  93. package/lib/esm/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +1 -0
  94. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js +136 -0
  95. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +1 -0
  96. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +20 -0
  97. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +1 -0
  98. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +121 -0
  99. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +1 -0
  100. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +98 -0
  101. package/lib/esm/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +1 -0
  102. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js +43 -0
  103. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.js.map +1 -0
  104. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js +8 -0
  105. package/lib/esm/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +1 -0
  106. package/lib/esm/constants/alignment.js +13 -0
  107. package/lib/esm/constants/alignment.js.map +1 -0
  108. package/lib/esm/constants/categories.js +13 -0
  109. package/lib/esm/constants/categories.js.map +1 -0
  110. package/lib/esm/constants/emoji-de-DE.json +3827 -0
  111. package/lib/esm/constants/emoji.js +3798 -0
  112. package/lib/esm/constants/emoji.js.map +1 -0
  113. package/lib/esm/constants/externalServerUrl.js +2 -0
  114. package/lib/esm/constants/externalServerUrl.js.map +1 -0
  115. package/lib/esm/constants/regex.js +9 -0
  116. package/lib/esm/constants/regex.js.map +1 -0
  117. package/lib/esm/hooks/emojiHistory.js +83 -0
  118. package/lib/esm/hooks/emojiHistory.js.map +1 -0
  119. package/lib/{index.d.ts → esm/index.js} +1 -0
  120. package/lib/esm/index.js.map +1 -0
  121. package/lib/esm/types/api.js +2 -0
  122. package/lib/esm/types/api.js.map +1 -0
  123. package/lib/esm/types/category.js +2 -0
  124. package/lib/esm/types/category.js.map +1 -0
  125. package/lib/esm/utils/emoji.js +92 -0
  126. package/lib/esm/utils/emoji.js.map +1 -0
  127. package/lib/esm/utils/environment.js +24 -0
  128. package/lib/esm/utils/environment.js.map +1 -0
  129. package/lib/esm/utils/font.js +10 -0
  130. package/lib/esm/utils/font.js.map +1 -0
  131. package/lib/esm/utils/insert.js +104 -0
  132. package/lib/esm/utils/insert.js.map +1 -0
  133. package/lib/esm/utils/number.js +10 -0
  134. package/lib/esm/utils/number.js.map +1 -0
  135. package/lib/esm/utils/selection.js +237 -0
  136. package/lib/esm/utils/selection.js.map +1 -0
  137. package/lib/esm/utils/text.js +48 -0
  138. package/lib/esm/utils/text.js.map +1 -0
  139. package/lib/types/components/emoji-input/EmojiInput.d.ts +94 -0
  140. package/lib/types/components/emoji-input/EmojiInput.styles.d.ts +549 -0
  141. package/lib/types/components/emoji-input/prefix-element/PrefixElement.d.ts +8 -0
  142. package/lib/types/components/emoji-input/prefix-element/PrefixElement.styles.d.ts +12 -0
  143. package/lib/types/components/emoji-picker/EmojiPicker.styles.d.ts +5 -0
  144. package/lib/types/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +267 -0
  145. package/lib/types/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +10 -0
  146. package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/Emoji.d.ts +5 -0
  147. package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +6 -0
  148. package/lib/types/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +283 -0
  149. package/lib/{components → types/components}/emoji-picker-popup/EmojiPickerPopup.d.ts +0 -13
  150. package/lib/types/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +1 -0
  151. package/lib/types/constants/regex.d.ts +8 -0
  152. package/lib/types/index.d.ts +6 -0
  153. package/lib/{utils → types/utils}/emoji.d.ts +2 -0
  154. package/lib/{utils → types/utils}/environment.d.ts +1 -0
  155. package/lib/types/utils/font.d.ts +1 -0
  156. package/lib/{utils → types/utils}/insert.d.ts +8 -1
  157. package/lib/types/utils/number.d.ts +1 -0
  158. package/lib/types/utils/selection.d.ts +23 -0
  159. package/lib/types/utils/text.d.ts +3 -0
  160. package/package.json +48 -30
  161. package/lib/api/item-storage/get.js.map +0 -1
  162. package/lib/api/item-storage/put.js.map +0 -1
  163. package/lib/components/emoji-input/EmojiInput.d.ts +0 -49
  164. package/lib/components/emoji-input/EmojiInput.js +0 -161
  165. package/lib/components/emoji-input/EmojiInput.js.map +0 -1
  166. package/lib/components/emoji-input/EmojiInput.styles.d.ts +0 -16
  167. package/lib/components/emoji-input/EmojiInput.styles.js +0 -158
  168. package/lib/components/emoji-input/EmojiInput.styles.js.map +0 -1
  169. package/lib/components/emoji-picker/EmojiPicker.js.map +0 -1
  170. package/lib/components/emoji-picker/EmojiPicker.styles.d.ts +0 -5
  171. package/lib/components/emoji-picker/EmojiPicker.styles.js.map +0 -1
  172. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js +0 -51
  173. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.js.map +0 -1
  174. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.d.ts +0 -2
  175. package/lib/components/emoji-picker/emoji-picker-categories/EmojiPickerCategories.styles.js.map +0 -1
  176. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js +0 -131
  177. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.js.map +0 -1
  178. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.d.ts +0 -7
  179. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js +0 -99
  180. package/lib/components/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.styles.js.map +0 -1
  181. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.js.map +0 -1
  182. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.d.ts +0 -1
  183. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js +0 -20
  184. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/Emoji.styles.js.map +0 -1
  185. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js +0 -74
  186. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.js.map +0 -1
  187. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.d.ts +0 -11
  188. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js +0 -104
  189. package/lib/components/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.styles.js.map +0 -1
  190. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js +0 -150
  191. package/lib/components/emoji-picker-popup/EmojiPickerPopup.js.map +0 -1
  192. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.d.ts +0 -7
  193. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js +0 -97
  194. package/lib/components/emoji-picker-popup/EmojiPickerPopup.styles.js.map +0 -1
  195. package/lib/constants/alignment.js.map +0 -1
  196. package/lib/constants/categories.js.map +0 -1
  197. package/lib/constants/emoji.js.map +0 -1
  198. package/lib/constants/externalServerUrl.js +0 -9
  199. package/lib/constants/externalServerUrl.js.map +0 -1
  200. package/lib/hooks/emojiHistory.js.map +0 -1
  201. package/lib/index.js.map +0 -1
  202. package/lib/types/api.js +0 -6
  203. package/lib/types/api.js.map +0 -1
  204. package/lib/types/category.js +0 -6
  205. package/lib/types/category.js.map +0 -1
  206. package/lib/utils/emoji.js.map +0 -1
  207. package/lib/utils/environment.js.map +0 -1
  208. package/lib/utils/font.d.ts +0 -1
  209. package/lib/utils/font.js +0 -15
  210. package/lib/utils/font.js.map +0 -1
  211. package/lib/utils/insert.js +0 -50
  212. package/lib/utils/insert.js.map +0 -1
  213. package/lib/utils/selection.d.ts +0 -2
  214. package/lib/utils/selection.js +0 -43
  215. package/lib/utils/selection.js.map +0 -1
  216. /package/lib/{constants → cjs/constants}/emoji-de-DE.json +0 -0
  217. /package/lib/{api → types/api}/item-storage/get.d.ts +0 -0
  218. /package/lib/{api → types/api}/item-storage/put.d.ts +0 -0
  219. /package/lib/{components → types/components}/emoji-picker/EmojiPicker.d.ts +0 -0
  220. /package/lib/{components → types/components}/emoji-picker/emoji-picker-categories/EmojiPickerCategories.d.ts +0 -0
  221. /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/EmojiPickerEmojis.d.ts +0 -0
  222. /package/lib/{components → types/components}/emoji-picker/emoji-picker-emojis/emoji/skin-tone-popup/SkinTonePopup.d.ts +0 -0
  223. /package/lib/{constants → types/constants}/alignment.d.ts +0 -0
  224. /package/lib/{constants → types/constants}/categories.d.ts +0 -0
  225. /package/lib/{constants → types/constants}/emoji.d.ts +0 -0
  226. /package/lib/{constants → types/constants}/externalServerUrl.d.ts +0 -0
  227. /package/lib/{hooks → types/hooks}/emojiHistory.d.ts +0 -0
  228. /package/lib/types/{api.d.ts → types/api.d.ts} +0 -0
  229. /package/lib/types/{category.d.ts → types/category.d.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ export declare const BB_LC_MENTION_REGEX: RegExp;
2
+ export declare const BB_NER_IGNORE_REGEX: RegExp;
3
+ export declare const BB_NER_REPLACE_REGEX: RegExp;
4
+ export declare const HTML_LC_MENTION_REGEX: RegExp;
5
+ export declare const HTML_NER_IGNORE_REGEX: RegExp;
6
+ export declare const HTML_NER_REPLACE_REGEX: RegExp;
7
+ export declare const HTML_BOLD_REGEX: RegExp;
8
+ export declare const HTML_A_TAG_REGEX: RegExp;
@@ -0,0 +1,6 @@
1
+ export { default as EmojiInput } from './components/emoji-input/EmojiInput';
2
+ export type { EmojiInputRef } from './components/emoji-input/EmojiInput';
3
+ export { default as EmojiPickerPopup } from './components/emoji-picker-popup/EmojiPickerPopup';
4
+ export { default as EmojiPicker } from './components/emoji-picker/EmojiPicker';
5
+ export { PopupAlignment } from './constants/alignment';
6
+ export { convertEmojisToUnicode } from './utils/emoji';
@@ -1,2 +1,4 @@
1
+ export declare const unescapeHTML: (text: string) => string;
2
+ export declare const escapeHTML: (text: string) => string;
1
3
  export declare const convertEmojisToUnicode: (text: string) => string;
2
4
  export declare const addSkinToneToEmoji: (emoji: string, skinTone: string) => string;
@@ -4,5 +4,6 @@ declare enum DeviceType {
4
4
  Tablet = 2
5
5
  }
6
6
  export declare const getDeviceType: () => DeviceType;
7
+ export declare const getIsMacOS: () => boolean;
7
8
  export declare const getIsMobile: () => boolean;
8
9
  export {};
@@ -0,0 +1 @@
1
+ export declare const getFontFamily: () => string;
@@ -1,6 +1,7 @@
1
1
  interface InsertTextAtCursorPositionOptions {
2
2
  editorElement: HTMLDivElement;
3
3
  text: string;
4
+ shouldUseSavedSelection?: boolean;
4
5
  }
5
6
  /**
6
7
  * This function inserts the passed text at the correct position in the editor element. If the
@@ -15,5 +16,11 @@ interface InsertTextAtCursorPositionOptions {
15
16
  * @param {HTMLDivElement} options.editorElement - Element to insert text into
16
17
  * @param {string} options.text - Text to insert into element
17
18
  */
18
- export declare const insertTextAtCursorPosition: ({ editorElement, text, }: InsertTextAtCursorPositionOptions) => void;
19
+ export declare const insertTextAtCursorPosition: ({ editorElement, text, shouldUseSavedSelection, }: InsertTextAtCursorPositionOptions) => void;
20
+ export interface ReplaceTextOptions {
21
+ editorElement: HTMLDivElement;
22
+ searchText: string;
23
+ pasteText: string;
24
+ }
25
+ export declare const replaceText: ({ editorElement, searchText, pasteText }: ReplaceTextOptions) => void;
19
26
  export {};
@@ -0,0 +1 @@
1
+ export declare const clamp: (value: number, min: number, max: number) => number;
@@ -0,0 +1,23 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ interface SaveSelectionOptions {
3
+ shouldIgnoreEmptyTextNodes?: boolean;
4
+ }
5
+ export declare const saveSelection: (element: HTMLDivElement, { shouldIgnoreEmptyTextNodes }?: SaveSelectionOptions) => void;
6
+ export declare const restoreSelection: (element: HTMLDivElement) => void;
7
+ export declare const insertInvisibleCursorMarker: () => void;
8
+ export declare const moveSelectionOffset: (distance: number) => void;
9
+ export declare const setChildIndex: (index: number) => void;
10
+ /**
11
+ * This function returns the code of the character that will be removed by the KeyDown event in the
12
+ * next step, if the "Backspace" or "Delete" key was pressed and there is no selection of multiple
13
+ * characters.
14
+ *
15
+ * @param event - Keyboard event from "onKeyDown"
16
+ */
17
+ export declare const getCharCodeThatWillBeDeleted: (event: KeyboardEvent<HTMLDivElement>) => number | null | undefined;
18
+ interface FindAndSelectTextOptions {
19
+ editorElement: HTMLDivElement;
20
+ searchText: string;
21
+ }
22
+ export declare const findAndSelectText: ({ editorElement, searchText, }: FindAndSelectTextOptions) => Range | null;
23
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const convertTextToHTML: (text: string) => string;
2
+ export declare const convertHTMLToText: (text: string) => string;
3
+ export declare const getElementTextLength: (element: Element) => number;
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@chayns-components/emoji-input",
3
- "version": "5.0.0-beta.98",
3
+ "version": "5.0.0-beta.982",
4
4
  "description": "Input field that supports HTML elements and emojis",
5
+ "sideEffects": false,
6
+ "browserslist": [
7
+ ">0.5%",
8
+ "not dead",
9
+ "not op_mini all",
10
+ "not IE 11"
11
+ ],
5
12
  "keywords": [
6
13
  "chayns",
7
14
  "react",
@@ -13,8 +20,16 @@
13
20
  "author": "Tobit.Software",
14
21
  "homepage": "https://github.com/TobitSoftware/chayns-components/tree/main/packages/emoji-input#readme",
15
22
  "license": "MIT",
16
- "main": "lib/index.js",
17
- "types": "lib/index.d.ts",
23
+ "types": "lib/types/index.d.ts",
24
+ "main": "lib/cjs/index.js",
25
+ "module": "lib/esm/index.js",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./lib/types/index.d.ts",
29
+ "require": "./lib/cjs/index.js",
30
+ "import": "./lib/esm/index.js"
31
+ }
32
+ },
18
33
  "directories": {
19
34
  "lib": "lib",
20
35
  "test": "__tests__"
@@ -27,46 +42,49 @@
27
42
  "url": "git+https://github.com/TobitSoftware/chayns-components.git"
28
43
  },
29
44
  "scripts": {
30
- "build": "npm run build:js && npm run build:types",
31
- "build:js": "babel src --out-dir lib --extensions=.ts,.tsx --source-maps --ignore=src/stories --copy-files",
45
+ "build": "npm run build:cjs && npm run build:esm && npm run build:types",
32
46
  "build:types": "tsc",
33
- "prepublishOnly": "npm run build"
47
+ "build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir lib/cjs --extensions=.ts,.tsx --source-maps --ignore=src/stories --copy-files",
48
+ "build:esm": "cross-env NODE_ENV=esm babel src --out-dir lib/esm --extensions=.ts,.tsx --source-maps --ignore=src/stories --copy-files",
49
+ "prepublishOnly": "npm run build",
50
+ "watch:js": "npm run build:esm -- --watch",
51
+ "link": "npm link && npm run watch:js"
34
52
  },
35
53
  "bugs": {
36
54
  "url": "https://github.com/TobitSoftware/chayns-components/issues"
37
55
  },
38
56
  "devDependencies": {
39
- "@babel/cli": "^7.21.0",
40
- "@babel/core": "^7.21.3",
41
- "@babel/preset-env": "^7.20.2",
42
- "@babel/preset-react": "^7.18.6",
43
- "@babel/preset-typescript": "^7.21.0",
44
- "@types/react": "^17.0.53",
45
- "@types/react-dom": "^17.0.19",
46
- "@types/styled-components": "^5.1.26",
47
- "@types/uuid": "^9.0.1",
48
- "babel-loader": "^8.3.0",
49
- "lerna": "^6.5.1",
50
- "react": "^17.0.2",
51
- "react-dom": "^17.0.2",
52
- "typescript": "^4.9.5"
57
+ "@babel/cli": "^7.26.4",
58
+ "@babel/core": "^7.26.0",
59
+ "@babel/preset-env": "^7.26.0",
60
+ "@babel/preset-react": "^7.26.3",
61
+ "@babel/preset-typescript": "^7.26.0",
62
+ "@types/react": "^18.3.18",
63
+ "@types/react-dom": "^18.3.5",
64
+ "@types/styled-components": "^5.1.34",
65
+ "@types/uuid": "^10.0.0",
66
+ "babel-loader": "^9.2.1",
67
+ "cross-env": "^7.0.3",
68
+ "lerna": "^8.1.9",
69
+ "react": "^18.3.1",
70
+ "react-dom": "^18.3.1",
71
+ "styled-components": "^6.1.14",
72
+ "typescript": "^5.7.3"
53
73
  },
54
74
  "dependencies": {
55
- "@chayns-components/core": "^5.0.0-beta.98",
56
- "@chayns/colors": "^2.0.0",
57
- "clsx": "^1.2.1",
58
- "emojilib": "^3.0.9",
59
- "framer-motion": "^6.5.1",
60
- "styled-components": "^5.3.9",
61
- "unicode-emoji-json": "^0.5.0",
62
- "uuid": "^9.0.0"
75
+ "@chayns-components/core": "^5.0.0-beta.982",
76
+ "emojilib": "^3.0.12",
77
+ "unicode-emoji-json": "^0.8.0"
63
78
  },
64
79
  "peerDependencies": {
80
+ "chayns-api": ">=1.0.73",
81
+ "framer-motion": ">=10.18.0",
65
82
  "react": ">=16.14.0",
66
- "react-dom": ">=16.14.0"
83
+ "react-dom": ">=16.14.0",
84
+ "styled-components": ">=5.3.11"
67
85
  },
68
86
  "publishConfig": {
69
87
  "access": "public"
70
88
  },
71
- "gitHead": "ee7237bbc5e9a51e98268f74989f98da251255c1"
89
+ "gitHead": "ce3890f89eb21a574ef499db6d4cdf93d647775a"
72
90
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"get.js","names":["_externalServerUrl","require","getEmojiHistory","_ref","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,MAAAC,IAAA,IAG0C;EAAA,IAHnC;IAClCC,WAAW;IACXC;EACoB,CAAC,GAAAF,IAAA;EACrB,MAAMG,WAAwB,GAAG;IAC7BC,OAAO,EAAE;MACLC,aAAa,EAAG,UAASJ,WAAY;IACzC,CAAC;IACDK,MAAM,EAAE;EACZ,CAAC;EAED,MAAMC,GAAG,GAAI,GAAEC,wCAAsB,YAAWN,QAAS,cAAa;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,EAAkC;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,CAAAjB,eAAA,GAAAA,eAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"put.js","names":["_externalServerUrl","require","putEmojiHistory","_ref","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,MAAAC,IAAA,IAI0C;EAAA,IAJnC;IAClCC,WAAW;IACXC,QAAQ;IACRC;EACoB,CAAC,GAAAH,IAAA;EACrB,MAAMI,WAAwB,GAAG;IAC7BC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MAAEJ;IAAM,CAAC,CAAC;IAC/BK,OAAO,EAAE;MACLC,aAAa,EAAG,UAASR,WAAY,EAAC;MACtC,cAAc,EAAE;IACpB,CAAC;IACDS,MAAM,EAAE;EACZ,CAAC;EAED,MAAMC,GAAG,GAAI,GAAEC,wCAAsB,YAAWV,QAAS,cAAa;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,EAAkC;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,CAAApB,eAAA,GAAAA,eAAA"}
@@ -1,49 +0,0 @@
1
- import { ChangeEventHandler, FC, KeyboardEventHandler, ReactNode } from 'react';
2
- import type { PopupAlignment } from '../../constants/alignment';
3
- export type EmojiInputProps = {
4
- /**
5
- * Access token of the logged-in user. Is needed to load and save the history of the emojis.
6
- */
7
- accessToken?: string;
8
- /**
9
- * Disables the input so that it cannot be changed anymore
10
- */
11
- isDisabled?: boolean;
12
- /**
13
- * Function that is executed when the text of the input changes
14
- */
15
- onInput?: ChangeEventHandler<HTMLDivElement>;
16
- /**
17
- * Function that is executed when a key is pressed down.
18
- */
19
- onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
20
- /**
21
- * Function that is executed when the visibility of the popup changes.
22
- * @param {boolean} isVisible - Whether the popup is visible or not
23
- */
24
- onPopupVisibilityChange?: (isVisible: boolean) => void;
25
- /**
26
- * Person id of the logged-in user. Is needed to load and save the history of the emojis.
27
- */
28
- personId?: string;
29
- /**
30
- * Placeholder for the input field
31
- */
32
- placeholder?: string;
33
- /**
34
- * Sets the alignment of the popup to a fixed value. If this value is not set, the component
35
- * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this
36
- * value.
37
- */
38
- popupAlignment?: PopupAlignment;
39
- /**
40
- * Element that is rendered inside the EmojiInput on the right side.
41
- */
42
- rightElement?: ReactNode;
43
- /**
44
- * Value of the input field
45
- */
46
- value: string;
47
- };
48
- declare const EmojiInput: FC<EmojiInputProps>;
49
- export default EmojiInput;
@@ -1,161 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _emoji = require("../../utils/emoji");
9
- var _environment = require("../../utils/environment");
10
- var _font = require("../../utils/font");
11
- var _insert = require("../../utils/insert");
12
- var _selection = require("../../utils/selection");
13
- var _EmojiPickerPopup = _interopRequireDefault(require("../emoji-picker-popup/EmojiPickerPopup"));
14
- var _EmojiInput = require("./EmojiInput.styles");
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
- const EmojiInput = _ref => {
19
- let {
20
- accessToken,
21
- isDisabled,
22
- onInput,
23
- onKeyDown,
24
- onPopupVisibilityChange,
25
- personId,
26
- placeholder,
27
- popupAlignment,
28
- rightElement,
29
- value
30
- } = _ref;
31
- const [isMobile] = (0, _react.useState)((0, _environment.getIsMobile)());
32
- const [rootFontFamily] = (0, _react.useState)((0, _font.getRootFontFamily)());
33
- const editorRef = (0, _react.useRef)(null);
34
-
35
- /**
36
- * This function updates the content of the 'contentEditable' element if the new text is
37
- * different from the previous content. So this is only true if, for example, a text like ":-)"
38
- * has been replaced to the corresponding emoji.
39
- *
40
- * When updating the HTML, the current cursor position is saved before replacing the content, so
41
- * that it can be set again afterward.
42
- */
43
- const handleUpdateText = (0, _react.useCallback)(text => {
44
- if (!editorRef.current) {
45
- return;
46
- }
47
- const newInnerText = (0, _emoji.convertEmojisToUnicode)(text);
48
- if (newInnerText !== editorRef.current.innerText) {
49
- (0, _selection.saveSelection)(editorRef.current);
50
- editorRef.current.innerText = newInnerText;
51
- (0, _selection.restoreSelection)(editorRef.current);
52
- }
53
- }, []);
54
-
55
- /**
56
- * This function handles the 'input' events of the 'contentEditable' element and also passes the
57
- * respective event up accordingly if the 'onInput' property is a function.
58
- */
59
- const handleInput = (0, _react.useCallback)(event => {
60
- if (!editorRef.current) {
61
- return;
62
- }
63
- handleUpdateText(editorRef.current.innerText);
64
- if (typeof onInput === 'function') {
65
- onInput(event);
66
- }
67
- }, [handleUpdateText, onInput]);
68
-
69
- /**
70
- * This function prevents formatting from being adopted when texts are inserted. To do this, the
71
- * plain text is read from the event after the default behavior has been prevented. The plain
72
- * text is then inserted at the correct position in the input field using the
73
- * 'insertTextAtCursorPosition' function.
74
- */
75
- const handlePaste = (0, _react.useCallback)(event => {
76
- if (editorRef.current) {
77
- event.preventDefault();
78
- let text = event.clipboardData.getData('text/plain');
79
- text = (0, _emoji.convertEmojisToUnicode)(text);
80
- (0, _insert.insertTextAtCursorPosition)({
81
- editorElement: editorRef.current,
82
- text
83
- });
84
- const newEvent = new Event('input', {
85
- bubbles: true
86
- });
87
- editorRef.current.dispatchEvent(newEvent);
88
- }
89
- }, []);
90
-
91
- /**
92
- * This function uses the 'insertTextAtCursorPosition' function to insert the emoji at the
93
- * correct position in the editor element.
94
- *
95
- * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,
96
- * which in turn executes the 'onInput' function from the props. So this serves to ensure that
97
- * the event is also passed through to the top when inserting via the popup.
98
- */
99
- const handlePopupSelect = (0, _react.useCallback)(emoji => {
100
- if (editorRef.current) {
101
- (0, _insert.insertTextAtCursorPosition)({
102
- editorElement: editorRef.current,
103
- text: emoji
104
- });
105
- const event = new Event('input', {
106
- bubbles: true
107
- });
108
- editorRef.current.dispatchEvent(event);
109
- }
110
- }, []);
111
-
112
- /**
113
- * This function ensures that the input field does not lose focus when the popup is opened or an
114
- * emoji is selected in it. For this purpose the corresponding elements get the class
115
- * 'prevent-lose-focus'.
116
- *
117
- * The class can also be set to any other elements that should also not cause the input field to
118
- * lose focus.
119
- */
120
- const handlePreventLoseFocus = (0, _react.useCallback)(event => {
121
- var _element$parentElemen;
122
- const element = event.target;
123
- if (element.classList.contains('prevent-lose-focus') || (_element$parentElemen = element.parentElement) !== null && _element$parentElemen !== void 0 && _element$parentElemen.classList.contains('prevent-lose-focus')) {
124
- event.preventDefault();
125
- event.stopPropagation();
126
- }
127
- }, []);
128
- (0, _react.useEffect)(() => {
129
- handleUpdateText(value);
130
- }, [handleUpdateText, value]);
131
- (0, _react.useEffect)(() => {
132
- document.body.addEventListener('mousedown', handlePreventLoseFocus);
133
- return () => {
134
- document.body.removeEventListener('mousedown', handlePreventLoseFocus);
135
- };
136
- }, [handlePreventLoseFocus]);
137
- return /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInput, {
138
- isDisabled: isDisabled
139
- }, /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputContent, {
140
- isRightElementGiven: !!rightElement
141
- }, /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputEditor, {
142
- contentEditable: !isDisabled,
143
- isMobile: isMobile,
144
- onInput: handleInput,
145
- onKeyDown: onKeyDown,
146
- onPaste: handlePaste,
147
- placeholder: placeholder,
148
- ref: editorRef,
149
- rootFontFamily: rootFontFamily
150
- }), !isMobile && /*#__PURE__*/_react.default.createElement(_EmojiPickerPopup.default, {
151
- accessToken: accessToken,
152
- alignment: popupAlignment,
153
- onSelect: handlePopupSelect,
154
- onPopupVisibilityChange: onPopupVisibilityChange,
155
- personId: personId
156
- })), rightElement && /*#__PURE__*/_react.default.createElement(_EmojiInput.StyledEmojiInputRightWrapper, null, rightElement));
157
- };
158
- EmojiInput.displayName = 'EmojiInput';
159
- var _default = EmojiInput;
160
- exports.default = _default;
161
- //# sourceMappingURL=EmojiInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EmojiInput.js","names":["_react","_interopRequireWildcard","require","_emoji","_environment","_font","_insert","_selection","_EmojiPickerPopup","_interopRequireDefault","_EmojiInput","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","EmojiInput","_ref","accessToken","isDisabled","onInput","onKeyDown","onPopupVisibilityChange","personId","placeholder","popupAlignment","rightElement","value","isMobile","useState","getIsMobile","rootFontFamily","getRootFontFamily","editorRef","useRef","handleUpdateText","useCallback","text","current","newInnerText","convertEmojisToUnicode","innerText","saveSelection","restoreSelection","handleInput","event","handlePaste","preventDefault","clipboardData","getData","insertTextAtCursorPosition","editorElement","newEvent","Event","bubbles","dispatchEvent","handlePopupSelect","emoji","handlePreventLoseFocus","_element$parentElemen","element","target","classList","contains","parentElement","stopPropagation","useEffect","document","body","addEventListener","removeEventListener","createElement","StyledEmojiInput","StyledEmojiInputContent","isRightElementGiven","StyledEmojiInputEditor","contentEditable","onPaste","ref","alignment","onSelect","StyledEmojiInputRightWrapper","displayName","_default","exports"],"sources":["../../../src/components/emoji-input/EmojiInput.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n ClipboardEvent,\n FC,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { PopupAlignment } from '../../constants/alignment';\nimport { convertEmojisToUnicode } from '../../utils/emoji';\nimport { getIsMobile } from '../../utils/environment';\nimport { getRootFontFamily } from '../../utils/font';\nimport { insertTextAtCursorPosition } from '../../utils/insert';\nimport { restoreSelection, saveSelection } from '../../utils/selection';\nimport EmojiPickerPopup from '../emoji-picker-popup/EmojiPickerPopup';\nimport {\n StyledEmojiInput,\n StyledEmojiInputContent,\n StyledEmojiInputEditor,\n StyledEmojiInputRightWrapper,\n} from './EmojiInput.styles';\n\nexport type EmojiInputProps = {\n /**\n * Access token of the logged-in user. Is needed to load and save the history of the emojis.\n */\n accessToken?: string;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the text of the input changes\n */\n onInput?: ChangeEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when a key is pressed down.\n */\n onKeyDown?: KeyboardEventHandler<HTMLDivElement>;\n /**\n * Function that is executed when the visibility of the popup changes.\n * @param {boolean} isVisible - Whether the popup is visible or not\n */\n onPopupVisibilityChange?: (isVisible: boolean) => void;\n /**\n * Person id of the logged-in user. Is needed to load and save the history of the emojis.\n */\n personId?: string;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Sets the alignment of the popup to a fixed value. If this value is not set, the component\n * calculates the best position on its own. Use the imported 'PopupAlignment' enum to set this\n * value.\n */\n popupAlignment?: PopupAlignment;\n /**\n * Element that is rendered inside the EmojiInput on the right side.\n */\n rightElement?: ReactNode;\n /**\n * Value of the input field\n */\n value: string;\n};\n\nconst EmojiInput: FC<EmojiInputProps> = ({\n accessToken,\n isDisabled,\n onInput,\n onKeyDown,\n onPopupVisibilityChange,\n personId,\n placeholder,\n popupAlignment,\n rightElement,\n value,\n}) => {\n const [isMobile] = useState(getIsMobile());\n const [rootFontFamily] = useState(getRootFontFamily());\n\n const editorRef = useRef<HTMLDivElement>(null);\n\n /**\n * This function updates the content of the 'contentEditable' element if the new text is\n * different from the previous content. So this is only true if, for example, a text like \":-)\"\n * has been replaced to the corresponding emoji.\n *\n * When updating the HTML, the current cursor position is saved before replacing the content, so\n * that it can be set again afterward.\n */\n const handleUpdateText = useCallback((text: string) => {\n if (!editorRef.current) {\n return;\n }\n\n const newInnerText = convertEmojisToUnicode(text);\n\n if (newInnerText !== editorRef.current.innerText) {\n saveSelection(editorRef.current);\n\n editorRef.current.innerText = newInnerText;\n\n restoreSelection(editorRef.current);\n }\n }, []);\n\n /**\n * This function handles the 'input' events of the 'contentEditable' element and also passes the\n * respective event up accordingly if the 'onInput' property is a function.\n */\n const handleInput = useCallback(\n (event: ChangeEvent<HTMLDivElement>) => {\n if (!editorRef.current) {\n return;\n }\n\n handleUpdateText(editorRef.current.innerText);\n\n if (typeof onInput === 'function') {\n onInput(event);\n }\n },\n [handleUpdateText, onInput]\n );\n\n /**\n * This function prevents formatting from being adopted when texts are inserted. To do this, the\n * plain text is read from the event after the default behavior has been prevented. The plain\n * text is then inserted at the correct position in the input field using the\n * 'insertTextAtCursorPosition' function.\n */\n const handlePaste = useCallback((event: ClipboardEvent<HTMLDivElement>) => {\n if (editorRef.current) {\n event.preventDefault();\n\n let text = event.clipboardData.getData('text/plain');\n\n text = convertEmojisToUnicode(text);\n\n insertTextAtCursorPosition({ editorElement: editorRef.current, text });\n\n const newEvent = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(newEvent);\n }\n }, []);\n\n /**\n * This function uses the 'insertTextAtCursorPosition' function to insert the emoji at the\n * correct position in the editor element.\n *\n * At the end an 'input' event is dispatched, so that the function 'handleInput' is triggered,\n * which in turn executes the 'onInput' function from the props. So this serves to ensure that\n * the event is also passed through to the top when inserting via the popup.\n */\n const handlePopupSelect = useCallback((emoji: string) => {\n if (editorRef.current) {\n insertTextAtCursorPosition({ editorElement: editorRef.current, text: emoji });\n\n const event = new Event('input', { bubbles: true });\n\n editorRef.current.dispatchEvent(event);\n }\n }, []);\n\n /**\n * This function ensures that the input field does not lose focus when the popup is opened or an\n * emoji is selected in it. For this purpose the corresponding elements get the class\n * 'prevent-lose-focus'.\n *\n * The class can also be set to any other elements that should also not cause the input field to\n * lose focus.\n */\n const handlePreventLoseFocus = useCallback((event: MouseEvent) => {\n const element = event.target as Element;\n\n if (\n element.classList.contains('prevent-lose-focus') ||\n element.parentElement?.classList.contains('prevent-lose-focus')\n ) {\n event.preventDefault();\n event.stopPropagation();\n }\n }, []);\n\n useEffect(() => {\n handleUpdateText(value);\n }, [handleUpdateText, value]);\n\n useEffect(() => {\n document.body.addEventListener('mousedown', handlePreventLoseFocus);\n\n return () => {\n document.body.removeEventListener('mousedown', handlePreventLoseFocus);\n };\n }, [handlePreventLoseFocus]);\n\n return (\n <StyledEmojiInput isDisabled={isDisabled}>\n <StyledEmojiInputContent isRightElementGiven={!!rightElement}>\n <StyledEmojiInputEditor\n contentEditable={!isDisabled}\n isMobile={isMobile}\n onInput={handleInput}\n onKeyDown={onKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={editorRef}\n rootFontFamily={rootFontFamily}\n />\n {!isMobile && (\n <EmojiPickerPopup\n accessToken={accessToken}\n alignment={popupAlignment}\n onSelect={handlePopupSelect}\n onPopupVisibilityChange={onPopupVisibilityChange}\n personId={personId}\n />\n )}\n </StyledEmojiInputContent>\n {rightElement && (\n <StyledEmojiInputRightWrapper>{rightElement}</StyledEmojiInputRightWrapper>\n )}\n </StyledEmojiInput>\n );\n};\n\nEmojiInput.displayName = 'EmojiInput';\n\nexport default EmojiInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAaA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAK6B,SAAAO,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAd,wBAAAU,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBA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type { EmojiInputProps } from './EmojiInput';
2
- export declare const StyledEmojiInput: import("styled-components").StyledComponent<"div", any, Pick<EmojiInputProps, "isDisabled"> & {
3
- theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
4
- }, never>;
5
- type StyledEmojiInputContentProps = {
6
- isRightElementGiven: boolean;
7
- };
8
- export declare const StyledEmojiInputContent: import("styled-components").StyledComponent<"div", any, StyledEmojiInputContentProps, never>;
9
- export declare const StyledEmojiInputEditor: import("styled-components").StyledComponent<"div", any, Pick<EmojiInputProps, "placeholder"> & {
10
- theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
11
- } & {
12
- isMobile: boolean;
13
- rootFontFamily: string;
14
- }, never>;
15
- export declare const StyledEmojiInputRightWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
16
- export {};
@@ -1,158 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StyledEmojiInputRightWrapper = exports.StyledEmojiInputEditor = exports.StyledEmojiInputContent = exports.StyledEmojiInput = void 0;
7
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
- const StyledEmojiInput = _styledComponents.default.div`
11
- align-items: center;
12
- background-color: ${_ref => {
13
- let {
14
- theme
15
- } = _ref;
16
- return theme['100'];
17
- }};
18
- border-radius: 3px;
19
- display: flex;
20
- min-height: 42px;
21
- opacity: ${_ref2 => {
22
- let {
23
- isDisabled
24
- } = _ref2;
25
- return isDisabled ? 0.5 : 1;
26
- }};
27
- pointer-events: ${_ref3 => {
28
- let {
29
- isDisabled
30
- } = _ref3;
31
- return isDisabled ? 'none' : 'initial';
32
- }};
33
- position: relative;
34
- transition: opacity 0.3s ease;
35
- `;
36
- exports.StyledEmojiInput = StyledEmojiInput;
37
- const StyledEmojiInputContent = _styledComponents.default.div`
38
- align-items: end;
39
- border: 1px solid rgba(160, 160, 160, 0.3);
40
- border-radius: 3px;
41
- display: flex;
42
- flex: 1 1 auto;
43
- gap: 10px;
44
- padding: 8px 10px;
45
-
46
- ${_ref4 => {
47
- let {
48
- isRightElementGiven
49
- } = _ref4;
50
- return isRightElementGiven && (0, _styledComponents.css)`
51
- border-top-right-radius: 0;
52
- border-bottom-right-radius: 0;
53
- border-right-width: 0;
54
- `;
55
- }}
56
- `;
57
- exports.StyledEmojiInputContent = StyledEmojiInputContent;
58
- const StyledEmojiInputEditor = _styledComponents.default.div`
59
- color: ${_ref5 => {
60
- let {
61
- theme
62
- } = _ref5;
63
- return theme.text;
64
- }};
65
- flex: 1 1 auto;
66
- max-height: 210px;
67
- overflow-y: scroll;
68
- word-break: break-word;
69
-
70
- // This fixes a bug where the field is not editable in certain browsers.
71
- // This is for example the case on iOS 15 or older.
72
- -webkit-user-modify: read-write;
73
- -webkit-user-select: text;
74
-
75
- ${_ref6 => {
76
- let {
77
- isMobile,
78
- rootFontFamily
79
- } = _ref6;
80
- if (isMobile) {
81
- return (0, _styledComponents.css)`
82
- font-family: ${rootFontFamily};
83
- `;
84
- }
85
- return (0, _styledComponents.css)`
86
- font-family: ${rootFontFamily}, 'Noto Color Emoji';
87
- `;
88
- }}
89
-
90
- &:empty:not(:focus):before {
91
- content: '${_ref7 => {
92
- let {
93
- placeholder
94
- } = _ref7;
95
- return placeholder;
96
- }}';
97
- color: ${_ref8 => {
98
- let {
99
- theme
100
- } = _ref8;
101
- return theme['006'];
102
- }};
103
- pointer-events: none;
104
- }
105
-
106
- // Styles for custom scrollbar
107
- ::-webkit-scrollbar {
108
- width: 5px;
109
- }
110
-
111
- ::-webkit-scrollbar-track {
112
- background-color: transparent;
113
- }
114
-
115
- ::-webkit-scrollbar-button {
116
- background-color: transparent;
117
- height: 5px;
118
- }
119
-
120
- ::-webkit-scrollbar-thumb {
121
- background-color: rgba(
122
- ${_ref9 => {
123
- let {
124
- theme
125
- } = _ref9;
126
- return theme['text-rgb'];
127
- }},
128
- 0.15
129
- );
130
- border-radius: 20px;
131
- }
132
-
133
- // Scrollbar styles for Firefox. The above styles are not supported in Firefox, these styles are
134
- // only supported in Firefox:
135
- * {
136
- scrollbar-color: rgba(
137
- ${_ref10 => {
138
- let {
139
- theme
140
- } = _ref10;
141
- return theme['text-rgb'];
142
- }},
143
- 0.15
144
- )
145
- transparent;
146
- scrollbar-width: thin;
147
- }
148
- `;
149
- exports.StyledEmojiInputEditor = StyledEmojiInputEditor;
150
- const StyledEmojiInputRightWrapper = _styledComponents.default.div`
151
- align-self: stretch;
152
- border-bottom-right-radius: 3px;
153
- border-top-right-radius: 3px;
154
- flex: 0 0 auto;
155
- overflow: hidden;
156
- `;
157
- exports.StyledEmojiInputRightWrapper = StyledEmojiInputRightWrapper;
158
- //# sourceMappingURL=EmojiInput.styles.js.map