react-input-emoji 4.0.8 → 4.2.0

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.
package/README.md CHANGED
@@ -46,7 +46,7 @@ export default function Example() {
46
46
  ## Props
47
47
 
48
48
  | Prop | Type | Default | Description |
49
- | -------------- | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
49
+ |----------------|----------|------------------|--------------------------------------------------------------------------------------------------------------------------|
50
50
  | `value` | string | "" | The input value. |
51
51
  | `onChange` | function | - | This function is called when the value of the input changes. The first argument is the current value. |
52
52
  | `onResize` | function | - | This function is called when the width or the height of the input changes. The first argument is the current size value. |
@@ -57,6 +57,7 @@ export default function Example() {
57
57
  | `placeholder` | string | "Type a message" | Set the placeholder of the input. |
58
58
  | `height` | number | 40 | The total height of the area in which the element is rendered. |
59
59
  | `maxLength` | number | - | The maximum number of characters allowed in the element. |
60
+ | `theme` | string | - | Set theme for emoji popup. Available values "light", "dark", "auto" |
60
61
  | `borderRadius` | number | 21 | The border radius of the input container. |
61
62
  | `borderColor` | string | "#EAEAEA" | The border color of the input container. |
62
63
  | `fontSize` | number | 15 | The font size of the placeholder and input container. |
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, memo, useMemo, useState } from 'react';
1
+ import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, useMemo, memo, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
4
  function styleInject(css, ref) {
@@ -156,6 +156,7 @@ function handlePasteHtmlAtCaret(html) {
156
156
  if (window.getSelection) {
157
157
  // IE9 and non-IE
158
158
  sel = window.getSelection();
159
+ if (sel === null) return;
159
160
 
160
161
  if (sel.getRangeAt && sel.rangeCount) {
161
162
  range = sel.getRangeAt(0);
@@ -251,7 +252,7 @@ function replaceAllHtmlToString(html) {
251
252
  /**
252
253
  * @typedef {Object} Props
253
254
  * @property {React.Ref<any>} ref
254
- * @property {React.MutableRefObject<import('../text-input').Ref>} textInputRef
255
+ * @property {React.MutableRefObject<import('../text-input').Ref | null>} textInputRef
255
256
  * @property {(value: string) => void} setValue
256
257
  * @property {() => void} emitChange
257
258
  */
@@ -281,10 +282,14 @@ function useExpose({
281
282
  },
282
283
 
283
284
  focus: () => {
285
+ if (textInputRef.current === null) return;
284
286
  textInputRef.current.focus();
285
287
  },
286
288
  blur: () => {
287
- sanitize(textInputRef.current.html);
289
+ if (textInputRef.current !== null) {
290
+ sanitize(textInputRef.current.html);
291
+ }
292
+
288
293
  emitChange();
289
294
  }
290
295
  }));
@@ -294,16 +299,17 @@ function useExpose({
294
299
 
295
300
  /**
296
301
  * useEmit
297
- * @param {React.MutableRefObject<import('../text-input').Ref>} textInputRef
302
+ * @param {React.MutableRefObject<import('../text-input').Ref | null>} textInputRef
298
303
  * @param {(size: {width: number, height: number}) => void} onResize
299
304
  * @param {(text: string) => void} onChange
300
305
  */
301
306
 
302
307
  function useEmit(textInputRef, onResize, onChange) {
308
+ /** @type {React.MutableRefObject<{width: number; height: number} | null>} */
303
309
  const currentSizeRef = useRef(null);
304
310
  const onChangeFn = useRef(onChange);
305
311
  const checkAndEmitResize = useCallback(() => {
306
- if (textInputRef.current) {
312
+ if (textInputRef.current !== null) {
307
313
  const currentSize = currentSizeRef.current;
308
314
  const nextSize = textInputRef.current.size;
309
315
 
@@ -337,7 +343,7 @@ function useEmit(textInputRef, onResize, onChange) {
337
343
  * @property {(event: React.KeyboardEvent) => void} onKeyDown
338
344
  * @property {(event: React.KeyboardEvent) => void} onKeyUp
339
345
  * @property {() => void} onFocus
340
- * @property {() => void=} onBlur
346
+ * @property {() => void} onBlur
341
347
  * @property {(sanitizedText: string) => void=} onChange
342
348
  * @property {(event: React.KeyboardEvent) => void} onArrowUp
343
349
  * @property {(event: React.KeyboardEvent) => void} onArrowDown
@@ -374,40 +380,63 @@ const TextInput = ({
374
380
  }, ref) => {
375
381
  useImperativeHandle(ref, () => ({
376
382
  appendContent: html => {
377
- textInputRef.current.focus();
383
+ if (textInputRef.current) {
384
+ textInputRef.current.focus();
385
+ }
386
+
378
387
  handlePasteHtmlAtCaret(html);
379
- textInputRef.current.focus();
380
388
 
381
- if (textInputRef.current.innerHTML.trim() === "") {
389
+ if (textInputRef.current) {
390
+ textInputRef.current.focus();
391
+ }
392
+
393
+ if (textInputRef.current && placeholderRef.current && textInputRef.current.innerHTML.trim() === "") {
382
394
  placeholderRef.current.style.visibility = "visible";
383
- } else {
395
+ } else if (placeholderRef.current) {
384
396
  placeholderRef.current.style.visibility = "hidden";
385
397
  }
386
398
 
387
- onChange(textInputRef.current.innerHTML);
399
+ if (textInputRef.current && typeof onChange === 'function') {
400
+ onChange(textInputRef.current.innerHTML);
401
+ }
388
402
  },
389
403
 
390
404
  set html(value) {
391
- textInputRef.current.innerHTML = value;
405
+ if (textInputRef.current) {
406
+ textInputRef.current.innerHTML = value;
407
+ }
392
408
 
393
- if (value.trim() === "") {
394
- placeholderRef.current.style.visibility = "visible";
395
- } else {
396
- placeholderRef.current.style.visibility = "hidden";
409
+ if (placeholderRef.current) {
410
+ if (value.trim() === "") {
411
+ placeholderRef.current.style.visibility = "visible";
412
+ } else {
413
+ placeholderRef.current.style.visibility = "hidden";
414
+ }
397
415
  }
398
416
 
399
- onChange(textInputRef.current.innerHTML);
417
+ if (typeof onChange === 'function' && textInputRef.current) {
418
+ onChange(textInputRef.current.innerHTML);
419
+ }
400
420
  },
401
421
 
402
422
  get html() {
423
+ if (!textInputRef.current) return '';
403
424
  return textInputRef.current.innerHTML;
404
425
  },
405
426
 
406
427
  get text() {
428
+ if (!textInputRef.current) return '';
407
429
  return textInputRef.current.innerText;
408
430
  },
409
431
 
410
432
  get size() {
433
+ if (!textInputRef.current) {
434
+ return {
435
+ width: 0,
436
+ height: 0
437
+ };
438
+ }
439
+
411
440
  return {
412
441
  width: textInputRef.current.offsetWidth,
413
442
  height: textInputRef.current.offsetHeight
@@ -415,14 +444,15 @@ const TextInput = ({
415
444
  },
416
445
 
417
446
  focus() {
447
+ if (!textInputRef.current) return;
418
448
  textInputRef.current.focus();
419
449
  }
420
450
 
421
451
  }));
422
- /** @type {React.MutableRefObject<HTMLDivElement>} */
452
+ /** @type {React.MutableRefObject<HTMLDivElement | null>} */
423
453
 
424
454
  const placeholderRef = useRef(null);
425
- /** @type {React.MutableRefObject<HTMLDivElement>} */
455
+ /** @type {React.MutableRefObject<HTMLDivElement | null>} */
426
456
 
427
457
  const textInputRef = useRef(null);
428
458
  /**
@@ -438,7 +468,7 @@ const TextInput = ({
438
468
  } else if (event.key === "ArrowDown") {
439
469
  props.onArrowDown(event);
440
470
  } else {
441
- if (event.key.length === 1) {
471
+ if (event.key.length === 1 && placeholderRef.current) {
442
472
  placeholderRef.current.style.visibility = "hidden";
443
473
  }
444
474
  }
@@ -458,18 +488,20 @@ const TextInput = ({
458
488
 
459
489
 
460
490
  function handleKeyUp(event) {
461
- var _input$innerText;
462
-
463
491
  props.onKeyUp(event);
464
492
  const input = textInputRef.current;
465
493
 
466
- if (((_input$innerText = input.innerText) === null || _input$innerText === void 0 ? void 0 : _input$innerText.trim()) === "") {
467
- placeholderRef.current.style.visibility = "visible";
468
- } else {
469
- placeholderRef.current.style.visibility = "hidden";
494
+ if (placeholderRef.current) {
495
+ if (input?.innerText?.trim() === "") {
496
+ placeholderRef.current.style.visibility = "visible";
497
+ } else {
498
+ placeholderRef.current.style.visibility = "hidden";
499
+ }
470
500
  }
471
501
 
472
- onChange(textInputRef.current.innerHTML);
502
+ if (typeof onChange === 'function' && textInputRef.current) {
503
+ onChange(textInputRef.current.innerHTML);
504
+ }
473
505
  }
474
506
 
475
507
  return /*#__PURE__*/React.createElement("div", {
@@ -49301,23 +49333,20 @@ function _defineProperties(target, props) {
49301
49333
  function _createClass(Constructor, protoProps, staticProps) {
49302
49334
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
49303
49335
  if (staticProps) _defineProperties(Constructor, staticProps);
49336
+ Object.defineProperty(Constructor, "prototype", {
49337
+ writable: false
49338
+ });
49304
49339
  return Constructor;
49305
49340
  }
49306
49341
 
49307
49342
  function _typeof(obj) {
49308
49343
  "@babel/helpers - typeof";
49309
49344
 
49310
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
49311
- _typeof = function _typeof(obj) {
49312
- return typeof obj;
49313
- };
49314
- } else {
49315
- _typeof = function _typeof(obj) {
49316
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
49317
- };
49318
- }
49319
-
49320
- return _typeof(obj);
49345
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
49346
+ return typeof obj;
49347
+ } : function (obj) {
49348
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
49349
+ }, _typeof(obj);
49321
49350
  }
49322
49351
 
49323
49352
  var mapping = {
@@ -49407,8 +49436,8 @@ var stringFromCodePoint = _String.fromCodePoint || function stringFromCodePoint(
49407
49436
  codePoint > 0x10ffff || // not a valid Unicode code point
49408
49437
  Math.floor(codePoint) != codePoint // not an integer
49409
49438
  ) {
49410
- throw RangeError('Invalid code point: ' + codePoint);
49411
- }
49439
+ throw RangeError('Invalid code point: ' + codePoint);
49440
+ }
49412
49441
 
49413
49442
  if (codePoint <= 0xffff) {
49414
49443
  // BMP code point
@@ -50011,7 +50040,7 @@ function _defineProperty(obj, key, value) {
50011
50040
  }
50012
50041
 
50013
50042
  function _extends() {
50014
- _extends = Object.assign || function (target) {
50043
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
50015
50044
  for (var i = 1; i < arguments.length; i++) {
50016
50045
  var source = arguments[i];
50017
50046
 
@@ -50024,7 +50053,6 @@ function _extends() {
50024
50053
 
50025
50054
  return target;
50026
50055
  };
50027
-
50028
50056
  return _extends.apply(this, arguments);
50029
50057
  }
50030
50058
 
@@ -50039,24 +50067,25 @@ function _assertThisInitialized(self) {
50039
50067
  function _possibleConstructorReturn(self, call) {
50040
50068
  if (call && (_typeof(call) === "object" || typeof call === "function")) {
50041
50069
  return call;
50070
+ } else if (call !== void 0) {
50071
+ throw new TypeError("Derived constructors may only return object or undefined");
50042
50072
  }
50043
50073
 
50044
50074
  return _assertThisInitialized(self);
50045
50075
  }
50046
50076
 
50047
50077
  function _getPrototypeOf(o) {
50048
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
50078
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
50049
50079
  return o.__proto__ || Object.getPrototypeOf(o);
50050
50080
  };
50051
50081
  return _getPrototypeOf(o);
50052
50082
  }
50053
50083
 
50054
50084
  function _setPrototypeOf(o, p) {
50055
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
50085
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
50056
50086
  o.__proto__ = p;
50057
50087
  return o;
50058
50088
  };
50059
-
50060
50089
  return _setPrototypeOf(o, p);
50061
50090
  }
50062
50091
 
@@ -50072,6 +50101,9 @@ function _inherits(subClass, superClass) {
50072
50101
  configurable: true
50073
50102
  }
50074
50103
  });
50104
+ Object.defineProperty(subClass, "prototype", {
50105
+ writable: false
50106
+ });
50075
50107
  if (superClass) _setPrototypeOf(subClass, superClass);
50076
50108
  }
50077
50109
 
@@ -52346,6 +52378,7 @@ styleInject(css_248z);
52346
52378
  // vendors
52347
52379
  /**
52348
52380
  * @typedef {object} Props
52381
+ * @property {'light' | 'dark' | 'auto'} theme
52349
52382
  * @property {function(import("../types/types").EmojiMartItem): void} onSelectEmoji
52350
52383
  * @property {boolean} disableRecent
52351
52384
  * @property {object[]} customEmojis
@@ -52357,12 +52390,14 @@ styleInject(css_248z);
52357
52390
  * @return {React.FC}
52358
52391
  */
52359
52392
 
52360
- function EmojiPicker({
52361
- onSelectEmoji,
52362
- disableRecent,
52363
- customEmojis
52364
- }) {
52365
- const excluePicker = useMemo(() => {
52393
+ function EmojiPicker(props) {
52394
+ const {
52395
+ theme,
52396
+ onSelectEmoji,
52397
+ disableRecent,
52398
+ customEmojis
52399
+ } = props;
52400
+ const excludePicker = useMemo(() => {
52366
52401
  /** @type import("emoji-mart").CategoryName[] */
52367
52402
  const exclude = [];
52368
52403
 
@@ -52373,16 +52408,18 @@ function EmojiPicker({
52373
52408
  return exclude;
52374
52409
  }, [disableRecent]);
52375
52410
  return /*#__PURE__*/React.createElement(Picker, {
52411
+ theme: theme,
52412
+ set: "apple",
52376
52413
  showPreview: false,
52377
52414
  showSkinTones: false,
52378
- set: "apple",
52379
52415
  onSelect: onSelectEmoji,
52380
- exclude: excluePicker,
52416
+ exclude: excludePicker,
52381
52417
  custom: customEmojis
52382
52418
  });
52383
52419
  }
52384
52420
 
52385
52421
  EmojiPicker.propTypes = {
52422
+ theme: PropTypes.oneOf(['light', 'dark', 'auto']),
52386
52423
  onSelectEmoji: PropTypes.func,
52387
52424
  disableRecent: PropTypes.bool,
52388
52425
  customEmojis: PropTypes.array
@@ -52400,7 +52437,8 @@ var EmojiPicker$1 = /*#__PURE__*/memo(EmojiPicker);
52400
52437
 
52401
52438
  /**
52402
52439
  * @typedef {Object} Props
52403
- * @property {boolean} keepOpenend
52440
+ * @property {'light' | 'dark' | 'auto'} theme
52441
+ * @property {boolean} keepOpened
52404
52442
  * @property {boolean} disableRecent
52405
52443
  * @property {object[]=} customEmojis
52406
52444
  * @property {(fn: SanitizeFn) => void} addSanitizeFn
@@ -52411,14 +52449,16 @@ var EmojiPicker$1 = /*#__PURE__*/memo(EmojiPicker);
52411
52449
 
52412
52450
  /** @type {React.FC<Props>} */
52413
52451
 
52414
- const EmojiPickerWrapper = ({
52415
- keepOpenend,
52416
- disableRecent,
52417
- customEmojis,
52418
- addSanitizeFn,
52419
- addPolluteFn,
52420
- appendContent
52421
- }) => {
52452
+ const EmojiPickerWrapper = props => {
52453
+ const {
52454
+ theme,
52455
+ keepOpened,
52456
+ disableRecent,
52457
+ customEmojis,
52458
+ addSanitizeFn,
52459
+ addPolluteFn,
52460
+ appendContent
52461
+ } = props;
52422
52462
  const [showPicker, setShowPicker] = useState(false);
52423
52463
  useEffect(() => {
52424
52464
  addSanitizeFn(replaceAllTextEmojiToString);
@@ -52468,7 +52508,7 @@ const EmojiPickerWrapper = ({
52468
52508
  function handleSelectEmoji(emoji) {
52469
52509
  appendContent(getImageEmoji(emoji));
52470
52510
 
52471
- if (!keepOpenend) {
52511
+ if (!keepOpened) {
52472
52512
  setShowPicker(currentShowPicker => !currentShowPicker);
52473
52513
  }
52474
52514
  }
@@ -52481,10 +52521,12 @@ const EmojiPickerWrapper = ({
52481
52521
  }, /*#__PURE__*/React.createElement("div", {
52482
52522
  className: "react-emoji-picker"
52483
52523
  }, /*#__PURE__*/React.createElement(EmojiPicker$1, {
52524
+ theme: theme,
52484
52525
  onSelectEmoji: handleSelectEmoji,
52485
52526
  disableRecent: disableRecent,
52486
52527
  customEmojis: customEmojis
52487
52528
  })))), /*#__PURE__*/React.createElement("button", {
52529
+ type: "button",
52488
52530
  className: `react-input-emoji--button${showPicker ? " react-input-emoji--button__show" : ""}`,
52489
52531
  onClick: toggleShowPicker
52490
52532
  }, /*#__PURE__*/React.createElement("svg", {
@@ -52596,7 +52638,7 @@ function getElementWithFocus() {
52596
52638
 
52597
52639
  function getSelectionStart() {
52598
52640
  const node = document.getSelection().anchorNode;
52599
- return (node === null || node === void 0 ? void 0 : node.nodeType) == 3 ? node : null;
52641
+ return node?.nodeType == 3 ? node : null;
52600
52642
  }
52601
52643
 
52602
52644
  // @ts-check
@@ -52641,11 +52683,9 @@ function useMention(searchMention) {
52641
52683
  /** @type {(event: React.KeyboardEvent) => void} */
52642
52684
 
52643
52685
  const onKeyUp = useCallback(async event => {
52644
- var _getElementWithFocus;
52645
-
52646
52686
  if (typeof searchMention !== "function") return;
52647
52687
 
52648
- if (event.key === "Backspace" && (_getElementWithFocus = getElementWithFocus()) !== null && _getElementWithFocus !== void 0 && _getElementWithFocus.element.parentElement.hasAttribute("data-mention-id")) {
52688
+ if (event.key === "Backspace" && getElementWithFocus()?.element.parentElement.hasAttribute("data-mention-id")) {
52649
52689
  const elementWithFocus = getElementWithFocus();
52650
52690
  elementWithFocus.element.parentElement.remove();
52651
52691
  } else if (!["ArrowUp", "ArrowDown", "Esc", "Escape"].includes(event.key)) {
@@ -52788,6 +52828,7 @@ const MentionUserList = ({
52788
52828
  }, usersFiltered.map((user, index) => /*#__PURE__*/React.createElement("li", {
52789
52829
  key: user.id
52790
52830
  }, /*#__PURE__*/React.createElement("button", {
52831
+ type: "button",
52791
52832
  onClick: handleClick(user),
52792
52833
  className: `react-input-emoji--mention--item${selectedUser === index ? " react-input-emoji--mention--item__selected" : ""}`,
52793
52834
  onMouseOver: () => setSelectedUser(index)
@@ -52995,7 +53036,8 @@ function useEventListeners() {
52995
53036
  arrowUp: createObserver(),
52996
53037
  arrowDown: createObserver(),
52997
53038
  enter: createObserver(),
52998
- focus: createObserver()
53039
+ focus: createObserver(),
53040
+ blur: createObserver()
52999
53041
  }), []);
53000
53042
  /**
53001
53043
  * @template {keyof TextInputListeners} T, K
@@ -53054,14 +53096,16 @@ function usePollute() {
53054
53096
  * @typedef {object} Props
53055
53097
  * @property {string} value
53056
53098
  * @property {(value: string) => void} onChange
53099
+ * @property {"light" | "dark" | "auto"} theme
53057
53100
  * @property {boolean} cleanOnEnter
53058
53101
  * @property {(text: string) => void} onEnter
53059
53102
  * @property {string} placeholder
53060
53103
  * @property {(size: {width: number, height: number}) => void} onResize
53061
53104
  * @property {() => void} onClick
53062
53105
  * @property {() => void} onFocus
53106
+ * @property {() => void=} onBlur
53063
53107
  * @property {number} maxLength
53064
- * @property {boolean} keepOpenend
53108
+ * @property {boolean} keepOpened
53065
53109
  * @property {(event: KeyboardEvent) => void} onKeyDown
53066
53110
  * @property {string} inputClass
53067
53111
  * @property {boolean} disableRecent
@@ -53082,30 +53126,34 @@ function usePollute() {
53082
53126
  * @return {JSX.Element}
53083
53127
  */
53084
53128
 
53085
- function InputEmoji({
53086
- onChange,
53087
- onEnter,
53088
- onResize,
53089
- onClick,
53090
- onFocus,
53091
- onKeyDown,
53092
- cleanOnEnter,
53093
- placeholder,
53094
- maxLength,
53095
- keepOpenend,
53096
- inputClass,
53097
- disableRecent,
53098
- tabIndex,
53099
- value,
53100
- customEmojis,
53101
- searchMention,
53102
- // style
53103
- borderRadius,
53104
- borderColor,
53105
- fontSize,
53106
- fontFamily
53107
- }, ref) {
53108
- /** @type {React.MutableRefObject<import('./text-input').Ref>} */
53129
+ function InputEmoji(props, ref) {
53130
+ const {
53131
+ onChange,
53132
+ onEnter,
53133
+ onResize,
53134
+ onClick,
53135
+ onFocus,
53136
+ onBlur,
53137
+ onKeyDown,
53138
+ theme,
53139
+ cleanOnEnter,
53140
+ placeholder,
53141
+ maxLength,
53142
+ keepOpened,
53143
+ inputClass,
53144
+ disableRecent,
53145
+ tabIndex,
53146
+ value,
53147
+ customEmojis,
53148
+ searchMention,
53149
+ // style
53150
+ borderRadius,
53151
+ borderColor,
53152
+ fontSize,
53153
+ fontFamily
53154
+ } = props;
53155
+ /** @type {React.MutableRefObject<import('./text-input').Ref | null>} */
53156
+
53109
53157
  const textInputRef = useRef(null);
53110
53158
  const {
53111
53159
  addEventListener,
@@ -53121,6 +53169,7 @@ function InputEmoji({
53121
53169
  pollute
53122
53170
  } = usePollute();
53123
53171
  const updateHTML = useCallback((nextValue = "") => {
53172
+ if (textInputRef.current === null) return;
53124
53173
  textInputRef.current.html = replaceAllTextEmojis(nextValue);
53125
53174
  sanitizedTextRef.current = nextValue;
53126
53175
  }, [sanitizedTextRef]);
@@ -53149,11 +53198,11 @@ function InputEmoji({
53149
53198
  * @return {boolean}
53150
53199
  */
53151
53200
  function handleKeydown(event) {
53152
- if (typeof maxLength !== "undefined" && event.key !== "Backspace" && totalCharacters(textInputRef.current) >= maxLength) {
53201
+ if (typeof maxLength !== "undefined" && event.key !== "Backspace" && textInputRef.current !== null && totalCharacters(textInputRef.current) >= maxLength) {
53153
53202
  event.preventDefault();
53154
53203
  }
53155
53204
 
53156
- if (event.key === "Enter") {
53205
+ if (event.key === "Enter" && textInputRef.current) {
53157
53206
  event.preventDefault();
53158
53207
  const text = sanitize(textInputRef.current.html);
53159
53208
  emitChange(sanitizedTextRef.current);
@@ -53202,6 +53251,19 @@ function InputEmoji({
53202
53251
  unsubscribe();
53203
53252
  };
53204
53253
  }, [addEventListener, onClick, onFocus]);
53254
+ useEffect(() => {
53255
+ /** */
53256
+ function handleBlur() {
53257
+ if (typeof onBlur === 'function') {
53258
+ onBlur();
53259
+ }
53260
+ }
53261
+
53262
+ const unsubscribe = addEventListener('blur', handleBlur);
53263
+ return () => {
53264
+ unsubscribe();
53265
+ };
53266
+ }, [addEventListener, onBlur]);
53205
53267
  /**
53206
53268
  *
53207
53269
  * @param {string} html
@@ -53218,11 +53280,13 @@ function InputEmoji({
53218
53280
 
53219
53281
 
53220
53282
  function appendContent(html) {
53221
- if (typeof maxLength !== "undefined" && totalCharacters(textInputRef.current) >= maxLength) {
53283
+ if (typeof maxLength !== "undefined" && textInputRef.current !== null && totalCharacters(textInputRef.current) >= maxLength) {
53222
53284
  return;
53223
53285
  }
53224
53286
 
53225
- textInputRef.current.appendContent(html);
53287
+ if (textInputRef.current !== null) {
53288
+ textInputRef.current.appendContent(html);
53289
+ }
53226
53290
  }
53227
53291
  /**
53228
53292
  * Handle copy of current selected text
@@ -53262,6 +53326,7 @@ function InputEmoji({
53262
53326
  ref: textInputRef,
53263
53327
  onCopy: handleCopy,
53264
53328
  onPaste: handlePaste,
53329
+ onBlur: listeners.blur.publish,
53265
53330
  onFocus: listeners.focus.publish,
53266
53331
  onArrowUp: listeners.arrowUp.publish,
53267
53332
  onArrowDown: listeners.arrowDown.publish,
@@ -53279,7 +53344,8 @@ function InputEmoji({
53279
53344
  className: inputClass,
53280
53345
  onChange: handleTextInputChange
53281
53346
  }), /*#__PURE__*/React.createElement(EmojiPickerWrapper, {
53282
- keepOpenend: keepOpenend,
53347
+ theme: theme,
53348
+ keepOpened: keepOpened,
53283
53349
  disableRecent: disableRecent,
53284
53350
  customEmojis: customEmojis,
53285
53351
  addSanitizeFn: addSanitizeFn,
@@ -53290,6 +53356,9 @@ function InputEmoji({
53290
53356
 
53291
53357
  const InputEmojiWithRef = /*#__PURE__*/forwardRef(InputEmoji);
53292
53358
  InputEmojiWithRef.defaultProps = {
53359
+ theme:
53360
+ /** @type {const} */
53361
+ "auto",
53293
53362
  height: 30,
53294
53363
  placeholder: "Type a message",
53295
53364
  borderRadius: 21,
@@ -53300,5 +53369,5 @@ InputEmojiWithRef.defaultProps = {
53300
53369
  customEmojis: []
53301
53370
  };
53302
53371
 
53303
- export default InputEmojiWithRef;
53372
+ export { InputEmojiWithRef as default };
53304
53373
  //# sourceMappingURL=index.es.js.map