stream-chat-react 10.6.0 → 10.7.1

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/dist/index.cjs.js CHANGED
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var sanitizeUrl = require('@braintree/sanitize-url');
7
6
  var ReactPlayer = require('react-player');
8
7
  var prettybytes = require('pretty-bytes');
8
+ var sanitizeUrl = require('@braintree/sanitize-url');
9
9
  var DefaultEmojiIndex = require('emoji-mart/dist/utils/emoji-index/nimble-emoji-index.js');
10
10
  var Dayjs = require('dayjs');
11
11
  var calendar = require('dayjs/plugin/calendar');
@@ -1384,7 +1384,7 @@ var UnMemoizedGallery = function (props) {
1384
1384
  React__default["default"].createElement("p", null, t('{{ imageCount }} more', {
1385
1385
  imageCount: images.length - countImagesDisplayedInPreview,
1386
1386
  })))) : (React__default["default"].createElement("button", { className: 'str-chat__gallery-image', "data-testid": 'gallery-image', key: "gallery-image-".concat(i), onClick: function () { return toggleModal(i); } },
1387
- React__default["default"].createElement("img", __assign({ alt: 'User uploaded content', src: image.previewUrl || image.image_url || image.thumb_url, style: image.style }, ((innerRefs === null || innerRefs === void 0 ? void 0 : innerRefs.current) && { ref: function (r) { return (innerRefs.current[i] = r); } })))));
1387
+ React__default["default"].createElement("img", __assign({ alt: 'User uploaded content', src: sanitizeUrl.sanitizeUrl(image.previewUrl || image.image_url || image.thumb_url), style: image.style }, ((innerRefs === null || innerRefs === void 0 ? void 0 : innerRefs.current) && { ref: function (r) { return (innerRefs.current[i] = r); } })))));
1388
1388
  });
1389
1389
  var className = clsx('str-chat__gallery', {
1390
1390
  'str-chat__gallery--square': images.length > lastImageIndexInPreview,
@@ -1715,6 +1715,18 @@ var renderMedia = function (props) {
1715
1715
  });
1716
1716
  };
1717
1717
 
1718
+ var UnsupportedAttachment = function (_a) {
1719
+ var _b;
1720
+ var attachment = _a.attachment;
1721
+ return (React__default["default"].createElement("div", null,
1722
+ React__default["default"].createElement("div", null,
1723
+ "Unsupported attachment type ",
1724
+ React__default["default"].createElement("strong", null, (_b = attachment.type) !== null && _b !== void 0 ? _b : 'unknown')),
1725
+ React__default["default"].createElement("code", null, JSON.stringify(attachment, null, 4)),
1726
+ ";"));
1727
+ };
1728
+ var NullComponent = function () { return null; };
1729
+
1718
1730
  var AttachmentWithinContainer = function (_a) {
1719
1731
  var _b;
1720
1732
  var _c;
@@ -1852,12 +1864,18 @@ var MediaContainer = function (props) {
1852
1864
  content,
1853
1865
  React__default["default"].createElement(AttachmentActionsContainer, __assign({}, props))))) : (React__default["default"].createElement(AttachmentWithinContainer, { attachment: attachment, componentType: componentType }, content));
1854
1866
  };
1867
+ var UnsupportedAttachmentContainer = function (_a) {
1868
+ var attachment = _a.attachment, _b = _a.UnsupportedAttachment, UnsupportedAttachment = _b === void 0 ? NullComponent : _b;
1869
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
1870
+ React__default["default"].createElement(UnsupportedAttachment, { attachment: attachment })));
1871
+ };
1855
1872
 
1856
1873
  var CONTAINER_MAP = {
1857
1874
  audio: AudioContainer,
1858
1875
  card: CardContainer,
1859
1876
  file: FileContainer,
1860
1877
  media: MediaContainer,
1878
+ unsupported: UnsupportedAttachmentContainer,
1861
1879
  };
1862
1880
  var ATTACHMENT_GROUPS_ORDER = [
1863
1881
  'card',
@@ -1866,6 +1884,7 @@ var ATTACHMENT_GROUPS_ORDER = [
1866
1884
  'media',
1867
1885
  'audio',
1868
1886
  'file',
1887
+ 'unsupported',
1869
1888
  ];
1870
1889
  /**
1871
1890
  * A component used for rendering message attachments. By default, the component supports: AttachmentActions, Audio, Card, File, Gallery, Image, and Video
@@ -1877,26 +1896,27 @@ var Attachment = function (props) {
1877
1896
  };
1878
1897
  var renderGroupedAttachments = function (_a) {
1879
1898
  var attachments = _a.attachments, rest = __rest(_a, ["attachments"]);
1880
- var uploadedImages = [];
1881
- var containers = attachments.reduce(function (acc, attachment) {
1882
- if (isUploadedImage(attachment)) {
1883
- uploadedImages.push(__assign(__assign({}, attachment), { image_url: sanitizeUrl.sanitizeUrl(attachment.image_url), thumb_url: sanitizeUrl.sanitizeUrl(attachment.thumb_url) }));
1884
- }
1885
- else {
1886
- var attachmentType = getAttachmentType(attachment);
1887
- if (attachmentType) {
1888
- var Container = CONTAINER_MAP[attachmentType];
1889
- acc[attachmentType].push(React__default["default"].createElement(Container, __assign({ key: "".concat(attachmentType, "-").concat(acc[attachmentType].length) }, rest, { attachment: attachment })));
1890
- }
1891
- }
1892
- return acc;
1899
+ var uploadedImages = attachments.filter(function (attachment) {
1900
+ return isUploadedImage(attachment);
1901
+ });
1902
+ var containers = attachments
1903
+ .filter(function (attachment) { return !isUploadedImage(attachment); })
1904
+ .reduce(function (typeMap, attachment) {
1905
+ var attachmentType = getAttachmentType(attachment);
1906
+ var Container = CONTAINER_MAP[attachmentType];
1907
+ typeMap[attachmentType].push(React__default["default"].createElement(Container, __assign({ key: "".concat(attachmentType, "-").concat(typeMap[attachmentType].length) }, rest, { attachment: attachment })));
1908
+ return typeMap;
1893
1909
  }, {
1894
1910
  audio: [],
1895
1911
  card: [],
1896
1912
  file: [],
1897
- gallery: [],
1898
- image: [],
1899
1913
  media: [],
1914
+ unsupported: [],
1915
+ // not used in reduce
1916
+ // eslint-disable-next-line sort-keys
1917
+ image: [],
1918
+ // eslint-disable-next-line sort-keys
1919
+ gallery: [],
1900
1920
  });
1901
1921
  if (uploadedImages.length > 1) {
1902
1922
  containers['gallery'] = [
@@ -1926,21 +1946,19 @@ var getAttachmentType = function (attachment) {
1926
1946
  else if (isFileAttachment(attachment)) {
1927
1947
  return 'file';
1928
1948
  }
1929
- return null;
1949
+ return 'unsupported';
1930
1950
  };
1931
1951
 
1932
1952
  var Item = /*#__PURE__*/React__default["default"].forwardRef(function Item(props, innerRef) {
1933
1953
  var className = props.className,
1934
- Component = props.component,
1935
- item = props.item,
1936
- onClickHandler = props.onClickHandler,
1937
- onSelectHandler = props.onSelectHandler,
1938
- selected = props.selected,
1939
- style = props.style;
1940
-
1954
+ Component = props.component,
1955
+ item = props.item,
1956
+ onClickHandler = props.onClickHandler,
1957
+ onSelectHandler = props.onSelectHandler,
1958
+ selected = props.selected,
1959
+ style = props.style;
1941
1960
  var _useChatContext = useChatContext('SuggestionItem'),
1942
- themeVersion = _useChatContext.themeVersion;
1943
-
1961
+ themeVersion = _useChatContext.themeVersion;
1944
1962
  var selectItem = React.useCallback(function () {
1945
1963
  return onSelectHandler(item);
1946
1964
  }, [item, onClickHandler]);
@@ -4874,12 +4892,12 @@ var extend = function extend() {
4874
4892
  };
4875
4893
 
4876
4894
  function isPlainObject(value) {
4877
- if (Object.prototype.toString.call(value) !== '[object Object]') {
4895
+ if (typeof value !== 'object' || value === null) {
4878
4896
  return false;
4879
4897
  }
4880
4898
 
4881
4899
  const prototype = Object.getPrototypeOf(value);
4882
- return prototype === null || prototype === Object.prototype;
4900
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
4883
4901
  }
4884
4902
 
4885
4903
  /**
@@ -23939,73 +23957,59 @@ var DefaultSuggestionListHeader = function (props) {
23939
23957
  };
23940
23958
 
23941
23959
  function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23942
-
23943
23960
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23944
23961
  var List = function List(_ref) {
23945
23962
  var className = _ref.className,
23946
- component = _ref.component,
23947
- currentTrigger = _ref.currentTrigger,
23948
- dropdownScroll = _ref.dropdownScroll,
23949
- getSelectedItem = _ref.getSelectedItem,
23950
- getTextToReplace = _ref.getTextToReplace,
23951
- PropHeader = _ref.Header,
23952
- itemClassName = _ref.itemClassName,
23953
- itemStyle = _ref.itemStyle,
23954
- onSelect = _ref.onSelect,
23955
- selectionEnd = _ref.selectionEnd,
23956
- style = _ref.style,
23957
- PropSuggestionItem = _ref.SuggestionItem,
23958
- propValue = _ref.value,
23959
- values = _ref.values;
23960
-
23963
+ component = _ref.component,
23964
+ currentTrigger = _ref.currentTrigger,
23965
+ dropdownScroll = _ref.dropdownScroll,
23966
+ getSelectedItem = _ref.getSelectedItem,
23967
+ getTextToReplace = _ref.getTextToReplace,
23968
+ PropHeader = _ref.Header,
23969
+ itemClassName = _ref.itemClassName,
23970
+ itemStyle = _ref.itemStyle,
23971
+ onSelect = _ref.onSelect,
23972
+ selectionEnd = _ref.selectionEnd,
23973
+ style = _ref.style,
23974
+ PropSuggestionItem = _ref.SuggestionItem,
23975
+ propValue = _ref.value,
23976
+ values = _ref.values;
23961
23977
  var _useComponentContext = useComponentContext('SuggestionList'),
23962
- AutocompleteSuggestionHeader = _useComponentContext.AutocompleteSuggestionHeader,
23963
- AutocompleteSuggestionItem = _useComponentContext.AutocompleteSuggestionItem;
23964
-
23978
+ AutocompleteSuggestionHeader = _useComponentContext.AutocompleteSuggestionHeader,
23979
+ AutocompleteSuggestionItem = _useComponentContext.AutocompleteSuggestionItem;
23965
23980
  var _useChatContext = useChatContext('SuggestionList'),
23966
- themeVersion = _useChatContext.themeVersion;
23967
-
23981
+ themeVersion = _useChatContext.themeVersion;
23968
23982
  var SuggestionItem = PropSuggestionItem || AutocompleteSuggestionItem || Item;
23969
23983
  var SuggestionHeader = PropHeader || AutocompleteSuggestionHeader || DefaultSuggestionListHeader;
23970
-
23971
23984
  var _useState = React.useState(undefined),
23972
- _useState2 = _slicedToArray__default["default"](_useState, 2),
23973
- selectedItem = _useState2[0],
23974
- setSelectedItem = _useState2[1];
23975
-
23985
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
23986
+ selectedItem = _useState2[0],
23987
+ setSelectedItem = _useState2[1];
23976
23988
  var itemsRef = [];
23977
-
23978
23989
  var isSelected = function isSelected(item) {
23979
23990
  return selectedItem === values.findIndex(function (value) {
23980
23991
  return getId(value) === getId(item);
23981
23992
  });
23982
23993
  };
23983
-
23984
23994
  var getId = function getId(item) {
23985
23995
  var textToReplace = getTextToReplace(item);
23986
-
23987
23996
  if (textToReplace.key) {
23988
23997
  return textToReplace.key;
23989
23998
  }
23990
-
23991
23999
  if (typeof item === 'string' || !item.key) {
23992
24000
  return textToReplace.text;
23993
24001
  }
23994
-
23995
24002
  return item.key;
23996
24003
  };
23997
-
23998
24004
  var modifyText = function modifyText(value) {
23999
24005
  if (!value) return;
24000
24006
  onSelect(getTextToReplace(value));
24001
24007
  if (getSelectedItem) getSelectedItem(value);
24002
24008
  };
24003
-
24004
24009
  var handleClick = function handleClick(e) {
24005
24010
  e === null || e === void 0 ? void 0 : e.preventDefault();
24006
24011
  modifyText(values[selectedItem]);
24007
24012
  };
24008
-
24009
24013
  var selectItem = React.useCallback(function (item) {
24010
24014
  var index = values.findIndex(function (value) {
24011
24015
  return value.id ? value.id === item.id : value.name === item.name;
@@ -24021,7 +24025,6 @@ var List = function List(_ref) {
24021
24025
  return newID;
24022
24026
  });
24023
24027
  }
24024
-
24025
24028
  if (event.key === 'ArrowDown') {
24026
24029
  setSelectedItem(function (prevSelected) {
24027
24030
  if (prevSelected === undefined) return 0;
@@ -24030,14 +24033,13 @@ var List = function List(_ref) {
24030
24033
  return newID;
24031
24034
  });
24032
24035
  }
24033
-
24034
24036
  if ((event.key === 'Enter' || event.key === 'Tab') && selectedItem !== undefined) {
24035
24037
  handleClick(event);
24036
24038
  }
24037
-
24038
24039
  return null;
24039
24040
  }, [selectedItem, values] // eslint-disable-line
24040
24041
  );
24042
+
24041
24043
  React.useEffect(function () {
24042
24044
  document.addEventListener('keydown', handleKeyDown, false);
24043
24045
  return function () {
@@ -24098,12 +24100,11 @@ function defaultScrollToItem(container, item) {
24098
24100
  var containerHight = parseInt(getComputedStyle(container).getPropertyValue('height'), 10) - itemHeight;
24099
24101
  var actualScrollTop = container.scrollTop;
24100
24102
  var itemOffsetTop = item.offsetTop;
24101
-
24102
24103
  if (itemOffsetTop < actualScrollTop + containerHight && actualScrollTop < itemOffsetTop) {
24103
24104
  return;
24104
- } // eslint-disable-next-line
24105
-
24105
+ }
24106
24106
 
24107
+ // eslint-disable-next-line
24107
24108
  container.scrollTop = itemOffsetTop;
24108
24109
  }
24109
24110
  var errorMessage = function errorMessage(message) {
@@ -24113,40 +24114,33 @@ var triggerPropsCheck = function triggerPropsCheck(_ref) {
24113
24114
  var trigger = _ref.trigger;
24114
24115
  if (!trigger) return Error('Invalid prop trigger. Prop missing.');
24115
24116
  var triggers = Object.entries(trigger);
24116
-
24117
24117
  for (var i = 0; i < triggers.length; i += 1) {
24118
24118
  var _triggers$i = _slicedToArray__default["default"](triggers[i], 2),
24119
- triggerChar = _triggers$i[0],
24120
- settings = _triggers$i[1];
24121
-
24119
+ triggerChar = _triggers$i[0],
24120
+ settings = _triggers$i[1];
24122
24121
  if (typeof triggerChar !== 'string' || triggerChar.length !== 1) {
24123
24122
  return Error('Invalid prop trigger. Keys of the object has to be string / one character.');
24124
- } // $FlowFixMe
24125
-
24123
+ }
24126
24124
 
24125
+ // $FlowFixMe
24127
24126
  var triggerSetting = settings;
24128
24127
  var callback = triggerSetting.callback,
24129
- component = triggerSetting.component,
24130
- dataProvider = triggerSetting.dataProvider,
24131
- output = triggerSetting.output;
24132
-
24128
+ component = triggerSetting.component,
24129
+ dataProvider = triggerSetting.dataProvider,
24130
+ output = triggerSetting.output;
24133
24131
  if (!ReactIs.isValidElementType(component)) {
24134
24132
  return Error('Invalid prop trigger: component should be defined.');
24135
24133
  }
24136
-
24137
24134
  if (!dataProvider || typeof dataProvider !== 'function') {
24138
24135
  return Error('Invalid prop trigger: dataProvider should be defined.');
24139
24136
  }
24140
-
24141
24137
  if (output && typeof output !== 'function') {
24142
24138
  return Error('Invalid prop trigger: output should be a function.');
24143
24139
  }
24144
-
24145
24140
  if (callback && typeof callback !== 'function') {
24146
24141
  return Error('Invalid prop trigger: callback should be a function.');
24147
24142
  }
24148
24143
  }
24149
-
24150
24144
  return null;
24151
24145
  };
24152
24146
 
@@ -24216,24 +24210,16 @@ var UnMemoizedUserItem = function (_a) {
24216
24210
  var UserItem = React__default["default"].memo(UnMemoizedUserItem);
24217
24211
 
24218
24212
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24219
-
24220
24213
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24221
-
24222
24214
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
24223
-
24224
24215
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24225
24216
  var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24226
24217
  _inherits__default["default"](ReactTextareaAutocomplete, _React$Component);
24227
-
24228
24218
  var _super = _createSuper(ReactTextareaAutocomplete);
24229
-
24230
24219
  function ReactTextareaAutocomplete(_props) {
24231
24220
  var _this;
24232
-
24233
24221
  _classCallCheck__default["default"](this, ReactTextareaAutocomplete);
24234
-
24235
24222
  _this = _super.call(this, _props);
24236
-
24237
24223
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSelectionPosition", function () {
24238
24224
  if (!_this.textareaRef) return null;
24239
24225
  return {
@@ -24241,72 +24227,58 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24241
24227
  selectionStart: _this.textareaRef.selectionStart
24242
24228
  };
24243
24229
  });
24244
-
24245
24230
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSelectedText", function () {
24246
24231
  if (!_this.textareaRef) return null;
24247
24232
  var _this$textareaRef = _this.textareaRef,
24248
- selectionEnd = _this$textareaRef.selectionEnd,
24249
- selectionStart = _this$textareaRef.selectionStart;
24233
+ selectionEnd = _this$textareaRef.selectionEnd,
24234
+ selectionStart = _this$textareaRef.selectionStart;
24250
24235
  if (selectionStart === selectionEnd) return null;
24251
24236
  return _this.state.value.substr(selectionStart, selectionEnd - selectionStart);
24252
24237
  });
24253
-
24254
24238
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "setCaretPosition", function () {
24255
24239
  var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
24256
24240
  if (!_this.textareaRef) return;
24257
-
24258
24241
  _this.textareaRef.focus();
24259
-
24260
24242
  _this.textareaRef.setSelectionRange(position, position);
24261
24243
  });
24262
-
24263
24244
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getCaretPosition", function () {
24264
24245
  if (!_this.textareaRef) return 0;
24265
24246
  return _this.textareaRef.selectionEnd;
24266
24247
  });
24267
-
24268
24248
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_defaultShouldSubmit", function (event) {
24269
24249
  return event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing;
24270
24250
  });
24271
-
24272
24251
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_handleKeyDown", function (event) {
24273
24252
  var _this$props$shouldSub = _this.props.shouldSubmit,
24274
- shouldSubmit = _this$props$shouldSub === void 0 ? _this._defaultShouldSubmit : _this$props$shouldSub; // prevent default behaviour when the selection list is rendered
24253
+ shouldSubmit = _this$props$shouldSub === void 0 ? _this._defaultShouldSubmit : _this$props$shouldSub;
24275
24254
 
24255
+ // prevent default behaviour when the selection list is rendered
24276
24256
  if ((event.key === 'ArrowUp' || event.key === 'ArrowDown') && _this.dropdownRef) event.preventDefault();
24277
24257
  if (shouldSubmit !== null && shouldSubmit !== void 0 && shouldSubmit(event)) return _this._onEnter(event);
24278
24258
  if (event.key === ' ') return _this._onSpace(event);
24279
24259
  if (event.key === 'Escape') return _this._closeAutocomplete();
24280
24260
  });
24281
-
24282
24261
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_onEnter", function (event) {
24283
24262
  if (!_this.textareaRef) return;
24284
24263
  var trigger = _this.state.currentTrigger;
24285
-
24286
24264
  if (!trigger || !_this.state.data) {
24287
24265
  // trigger a submit
24288
24266
  _this._replaceWord();
24289
-
24290
24267
  if (_this.textareaRef) {
24291
24268
  _this.textareaRef.selectionEnd = 0;
24292
24269
  }
24293
-
24294
24270
  _this.props.handleSubmit(event);
24295
-
24296
24271
  _this._closeAutocomplete();
24297
24272
  }
24298
24273
  });
24299
-
24300
24274
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_onSpace", function () {
24301
- if (!_this.props.replaceWord || !_this.textareaRef) return; // don't change characters if the element doesn't have focus
24275
+ if (!_this.props.replaceWord || !_this.textareaRef) return;
24302
24276
 
24277
+ // don't change characters if the element doesn't have focus
24303
24278
  var hasFocus = _this.textareaRef.matches(':focus');
24304
-
24305
24279
  if (!hasFocus) return;
24306
-
24307
24280
  _this._replaceWord();
24308
24281
  });
24309
-
24310
24282
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_replaceWord", function () {
24311
24283
  var value = _this.state.value;
24312
24284
  var lastWordRegex = /([^\s]+)(\s*)$/;
@@ -24314,14 +24286,11 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24314
24286
  var lastWord = match && match[1];
24315
24287
  if (!lastWord) return;
24316
24288
  var spaces = match[2];
24317
-
24318
24289
  var newWord = _this.props.replaceWord(lastWord);
24319
-
24320
24290
  if (newWord == null) return;
24321
24291
  var textBeforeWord = value.slice(0, _this.getCaretPosition() - match[0].length);
24322
24292
  var textAfterCaret = value.slice(_this.getCaretPosition(), -1);
24323
24293
  var newText = textBeforeWord + newWord + spaces + textAfterCaret;
24324
-
24325
24294
  _this.setState({
24326
24295
  value: newText
24327
24296
  }, function () {
@@ -24329,53 +24298,47 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24329
24298
  var e = new CustomEvent('change', {
24330
24299
  bubbles: true
24331
24300
  });
24332
-
24333
24301
  _this.textareaRef.dispatchEvent(e);
24334
-
24335
24302
  if (_this.props.onChange) _this.props.onChange(e);
24336
24303
  });
24337
24304
  });
24338
-
24339
24305
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_onSelect", function (newToken) {
24340
24306
  var _this$props = _this.props,
24341
- closeCommandsList = _this$props.closeCommandsList,
24342
- closeMentionsList = _this$props.closeMentionsList,
24343
- onChange = _this$props.onChange,
24344
- showCommandsList = _this$props.showCommandsList,
24345
- showMentionsList = _this$props.showMentionsList;
24307
+ closeCommandsList = _this$props.closeCommandsList,
24308
+ closeMentionsList = _this$props.closeMentionsList,
24309
+ onChange = _this$props.onChange,
24310
+ showCommandsList = _this$props.showCommandsList,
24311
+ showMentionsList = _this$props.showMentionsList;
24346
24312
  var _this$state = _this.state,
24347
- stateTrigger = _this$state.currentTrigger,
24348
- selectionEnd = _this$state.selectionEnd,
24349
- textareaValue = _this$state.value;
24313
+ stateTrigger = _this$state.currentTrigger,
24314
+ selectionEnd = _this$state.selectionEnd,
24315
+ textareaValue = _this$state.value;
24350
24316
  var currentTrigger = showCommandsList ? '/' : showMentionsList ? '@' : stateTrigger;
24351
24317
  if (!currentTrigger) return;
24352
-
24353
24318
  var computeCaretPosition = function computeCaretPosition(position, token, startToken) {
24354
24319
  switch (position) {
24355
24320
  case 'start':
24356
24321
  return startToken;
24357
-
24358
24322
  case 'next':
24359
24323
  case 'end':
24360
24324
  return startToken + token.length;
24361
-
24362
24325
  default:
24363
24326
  if (!Number.isInteger(position)) {
24364
24327
  throw new Error('RTA: caretPosition should be "start", "next", "end" or number.');
24365
24328
  }
24366
-
24367
24329
  return position;
24368
24330
  }
24369
24331
  };
24370
-
24371
24332
  var textToModify = showCommandsList ? '/' : showMentionsList ? '@' : textareaValue.slice(0, selectionEnd);
24372
- var startOfTokenPosition = textToModify.lastIndexOf(currentTrigger); // we add space after emoji is selected if a caret position is next
24333
+ var startOfTokenPosition = textToModify.lastIndexOf(currentTrigger);
24373
24334
 
24335
+ // we add space after emoji is selected if a caret position is next
24374
24336
  var newTokenString = newToken.caretPosition === 'next' ? "".concat(newToken.text, " ") : newToken.text;
24375
24337
  var newCaretPosition = computeCaretPosition(newToken.caretPosition, newTokenString, startOfTokenPosition);
24376
24338
  var modifiedText = textToModify.substring(0, startOfTokenPosition) + newTokenString;
24377
- var valueToReplace = textareaValue.replace(textToModify, modifiedText); // set the new textarea value and after that set the caret back to its position
24339
+ var valueToReplace = textareaValue.replace(textToModify, modifiedText);
24378
24340
 
24341
+ // set the new textarea value and after that set the caret back to its position
24379
24342
  _this.setState({
24380
24343
  dataLoading: false,
24381
24344
  value: valueToReplace
@@ -24384,25 +24347,17 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24384
24347
  var e = new CustomEvent('change', {
24385
24348
  bubbles: true
24386
24349
  });
24387
-
24388
24350
  _this.textareaRef.dispatchEvent(e);
24389
-
24390
24351
  if (onChange) onChange(e);
24391
-
24392
24352
  _this.setCaretPosition(newCaretPosition);
24393
24353
  });
24394
-
24395
24354
  _this._closeAutocomplete();
24396
-
24397
24355
  if (showCommandsList) closeCommandsList();
24398
24356
  if (showMentionsList) closeMentionsList();
24399
24357
  });
24400
-
24401
24358
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_getItemOnSelect", function (paramTrigger) {
24402
24359
  var stateTrigger = _this.state.currentTrigger;
24403
-
24404
24360
  var triggerSettings = _this._getCurrentTriggerSettings(paramTrigger);
24405
-
24406
24361
  var currentTrigger = paramTrigger || stateTrigger;
24407
24362
  if (!currentTrigger || !triggerSettings) return null;
24408
24363
  var callback = triggerSettings.callback;
@@ -24411,22 +24366,17 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24411
24366
  if (typeof callback !== 'function') {
24412
24367
  throw new Error('Output functor is not defined! You have to define "output" function. https://github.com/webscopeio/react-textarea-autocomplete#trigger-type');
24413
24368
  }
24414
-
24415
24369
  if (callback) {
24416
24370
  return callback(item, currentTrigger);
24417
24371
  }
24418
-
24419
24372
  return null;
24420
24373
  };
24421
24374
  });
24422
-
24423
24375
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_getTextToReplace", function (paramTrigger) {
24424
24376
  var _this$state2 = _this.state,
24425
- actualToken = _this$state2.actualToken,
24426
- stateTrigger = _this$state2.currentTrigger;
24427
-
24377
+ actualToken = _this$state2.actualToken,
24378
+ stateTrigger = _this$state2.currentTrigger;
24428
24379
  var triggerSettings = _this._getCurrentTriggerSettings(paramTrigger);
24429
-
24430
24380
  var currentTrigger = paramTrigger || stateTrigger;
24431
24381
  if (!currentTrigger || !triggerSettings) return null;
24432
24382
  var output = triggerSettings.output;
@@ -24434,91 +24384,74 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24434
24384
  if (_typeof__default["default"](item) === 'object' && (!output || typeof output !== 'function')) {
24435
24385
  throw new Error('Output functor is not defined! If you are using items as object you have to define "output" function. https://github.com/webscopeio/react-textarea-autocomplete#trigger-type');
24436
24386
  }
24437
-
24438
24387
  if (output) {
24439
24388
  var textToReplace = output(item, currentTrigger);
24440
-
24441
24389
  if (!textToReplace || typeof textToReplace === 'number') {
24442
24390
  throw new Error("Output functor should return string or object in shape {text: string, caretPosition: string | number}.\nGot \"".concat(String(textToReplace), "\". Check the implementation for trigger \"").concat(currentTrigger, "\" and its token \"").concat(actualToken, "\"\n\nSee https://github.com/webscopeio/react-textarea-autocomplete#trigger-type for more informations.\n"));
24443
24391
  }
24444
-
24445
24392
  if (typeof textToReplace === 'string') {
24446
24393
  return {
24447
24394
  caretPosition: DEFAULT_CARET_POSITION,
24448
24395
  text: textToReplace
24449
24396
  };
24450
24397
  }
24451
-
24452
24398
  if (!textToReplace.text && currentTrigger !== ':') {
24453
24399
  throw new Error("Output \"text\" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger \"".concat(currentTrigger, "\" and its token \"").concat(actualToken, "\"\n"));
24454
24400
  }
24455
-
24456
24401
  if (!textToReplace.caretPosition) {
24457
24402
  throw new Error("Output \"caretPosition\" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger \"".concat(currentTrigger, "\" and its token \"").concat(actualToken, "\"\n"));
24458
24403
  }
24459
-
24460
24404
  return textToReplace;
24461
24405
  }
24462
-
24463
24406
  if (typeof item !== 'string') {
24464
24407
  throw new Error('Output item should be string\n');
24465
24408
  }
24466
-
24467
24409
  return {
24468
24410
  caretPosition: DEFAULT_CARET_POSITION,
24469
24411
  text: "".concat(currentTrigger).concat(item).concat(currentTrigger)
24470
24412
  };
24471
24413
  };
24472
24414
  });
24473
-
24474
24415
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_getCurrentTriggerSettings", function (paramTrigger) {
24475
24416
  var stateTrigger = _this.state.currentTrigger;
24476
24417
  var currentTrigger = paramTrigger || stateTrigger;
24477
24418
  if (!currentTrigger) return null;
24478
24419
  return _this.props.trigger[currentTrigger];
24479
24420
  });
24480
-
24481
24421
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_getValuesFromProvider", function () {
24482
24422
  var _this$state3 = _this.state,
24483
- actualToken = _this$state3.actualToken,
24484
- currentTrigger = _this$state3.currentTrigger;
24485
-
24423
+ actualToken = _this$state3.actualToken,
24424
+ currentTrigger = _this$state3.currentTrigger;
24486
24425
  var triggerSettings = _this._getCurrentTriggerSettings();
24487
-
24488
24426
  if (!currentTrigger || !triggerSettings) return;
24489
24427
  var component = triggerSettings.component,
24490
- dataProvider = triggerSettings.dataProvider;
24491
-
24428
+ dataProvider = triggerSettings.dataProvider;
24492
24429
  if (typeof dataProvider !== 'function') {
24493
24430
  throw new Error('Trigger provider has to be a function!');
24494
24431
  }
24495
-
24496
24432
  _this.setState({
24497
24433
  dataLoading: true
24498
- }); // Modified: send the full text to support / style commands
24499
-
24434
+ });
24500
24435
 
24436
+ // Modified: send the full text to support / style commands
24501
24437
  dataProvider(actualToken, _this.state.value, function (data, token) {
24502
24438
  // Make sure that the result is still relevant for current query
24503
24439
  if (token !== _this.state.actualToken) return;
24504
-
24505
24440
  if (!Array.isArray(data)) {
24506
24441
  throw new Error('Trigger provider has to provide an array!');
24507
24442
  }
24508
-
24509
24443
  if (!ReactIs.isValidElementType(component)) {
24510
24444
  throw new Error('Component should be defined!');
24511
- } // throw away if we resolved old trigger
24512
-
24445
+ }
24513
24446
 
24514
- if (currentTrigger !== _this.state.currentTrigger) return; // if we haven't resolved any data let's close the autocomplete
24447
+ // throw away if we resolved old trigger
24448
+ if (currentTrigger !== _this.state.currentTrigger) return;
24515
24449
 
24450
+ // if we haven't resolved any data let's close the autocomplete
24516
24451
  if (!data.length) {
24517
24452
  _this._closeAutocomplete();
24518
-
24519
24453
  return;
24520
24454
  }
24521
-
24522
24455
  _this.setState({
24523
24456
  component: component,
24524
24457
  data: data,
@@ -24526,16 +24459,14 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24526
24459
  });
24527
24460
  });
24528
24461
  });
24529
-
24530
24462
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_getSuggestions", function (paramTrigger) {
24531
24463
  var _this$state4 = _this.state,
24532
- stateTrigger = _this$state4.currentTrigger,
24533
- data = _this$state4.data;
24464
+ stateTrigger = _this$state4.currentTrigger,
24465
+ data = _this$state4.data;
24534
24466
  var currentTrigger = paramTrigger || stateTrigger;
24535
24467
  if (!currentTrigger || !data || data && !data.length) return null;
24536
24468
  return data;
24537
24469
  });
24538
-
24539
24470
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_closeAutocomplete", function () {
24540
24471
  _this.setState({
24541
24472
  currentTrigger: null,
@@ -24545,54 +24476,45 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24545
24476
  top: null
24546
24477
  });
24547
24478
  });
24548
-
24549
24479
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_cleanUpProps", function () {
24550
24480
  var props = _objectSpread$2({}, _this.props);
24481
+ var notSafe = ['additionalTextareaProps', 'className', 'closeCommandsList', 'closeMentionsList', 'closeOnClickOutside', 'containerClassName', 'containerStyle', 'disableMentions', 'dropdownClassName', 'dropdownStyle', 'grow', 'handleSubmit', 'innerRef', 'itemClassName', 'itemStyle', 'listClassName', 'listStyle', 'loaderClassName', 'loaderStyle', 'loadingComponent', 'minChar', 'movePopupAsYouType', 'onCaretPositionChange', 'onChange', 'ref', 'replaceWord', 'scrollToItem', 'shouldSubmit', 'showCommandsList', 'showMentionsList', 'SuggestionItem', 'SuggestionList', 'trigger', 'value'];
24551
24482
 
24552
- var notSafe = ['additionalTextareaProps', 'className', 'closeCommandsList', 'closeMentionsList', 'closeOnClickOutside', 'containerClassName', 'containerStyle', 'disableMentions', 'dropdownClassName', 'dropdownStyle', 'grow', 'handleSubmit', 'innerRef', 'itemClassName', 'itemStyle', 'listClassName', 'listStyle', 'loaderClassName', 'loaderStyle', 'loadingComponent', 'minChar', 'movePopupAsYouType', 'onCaretPositionChange', 'onChange', 'ref', 'replaceWord', 'scrollToItem', 'shouldSubmit', 'showCommandsList', 'showMentionsList', 'SuggestionItem', 'SuggestionList', 'trigger', 'value']; // eslint-disable-next-line
24553
-
24483
+ // eslint-disable-next-line
24554
24484
  for (var prop in props) {
24555
24485
  if (notSafe.includes(prop)) delete props[prop];
24556
24486
  }
24557
-
24558
24487
  return props;
24559
24488
  });
24560
-
24561
24489
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_isCommand", function (text) {
24562
24490
  if (text[0] !== '/') return false;
24563
24491
  var tokens = text.split(' ');
24564
24492
  return tokens.length <= 1;
24565
24493
  });
24566
-
24567
24494
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_changeHandler", function (e) {
24568
24495
  var _this$props2 = _this.props,
24569
- minChar = _this$props2.minChar,
24570
- movePopupAsYouType = _this$props2.movePopupAsYouType,
24571
- onCaretPositionChange = _this$props2.onCaretPositionChange,
24572
- onChange = _this$props2.onChange,
24573
- trigger = _this$props2.trigger;
24496
+ minChar = _this$props2.minChar,
24497
+ movePopupAsYouType = _this$props2.movePopupAsYouType,
24498
+ onCaretPositionChange = _this$props2.onCaretPositionChange,
24499
+ onChange = _this$props2.onChange,
24500
+ trigger = _this$props2.trigger;
24574
24501
  var _this$state5 = _this.state,
24575
- left = _this$state5.left,
24576
- top = _this$state5.top;
24502
+ left = _this$state5.left,
24503
+ top = _this$state5.top;
24577
24504
  var textarea = e.target;
24578
24505
  var selectionEnd = textarea.selectionEnd,
24579
- selectionStart = textarea.selectionStart,
24580
- value = textarea.value;
24581
-
24506
+ selectionStart = textarea.selectionStart,
24507
+ value = textarea.value;
24582
24508
  if (onChange) {
24583
24509
  e.persist();
24584
24510
  onChange(e);
24585
24511
  }
24586
-
24587
24512
  if (onCaretPositionChange) onCaretPositionChange(_this.getCaretPosition());
24588
-
24589
24513
  _this.setState({
24590
24514
  value: value
24591
24515
  });
24592
-
24593
24516
  var currentTrigger;
24594
24517
  var lastToken;
24595
-
24596
24518
  if (_this._isCommand(value)) {
24597
24519
  currentTrigger = '/';
24598
24520
  lastToken = value;
@@ -24606,35 +24528,31 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24606
24528
  return a === lastToken[0];
24607
24529
  }) || null;
24608
24530
  }
24531
+
24609
24532
  /*
24610
24533
  if we lost the trigger token or there is no following character we want to close
24611
24534
  the autocomplete
24612
24535
  */
24613
-
24614
-
24615
24536
  if (!lastToken || lastToken.length <= minChar) {
24616
24537
  _this._closeAutocomplete();
24617
-
24618
24538
  return;
24619
24539
  }
24540
+ var actualToken = lastToken.slice(1);
24620
24541
 
24621
- var actualToken = lastToken.slice(1); // if trigger is not configured step out from the function, otherwise proceed
24622
-
24542
+ // if trigger is not configured step out from the function, otherwise proceed
24623
24543
  if (!currentTrigger) return;
24624
-
24625
- if (movePopupAsYouType || top === null && left === null || // if we have single char - trigger it means we want to re-position the autocomplete
24544
+ if (movePopupAsYouType || top === null && left === null ||
24545
+ // if we have single char - trigger it means we want to re-position the autocomplete
24626
24546
  lastToken.length === 1) {
24627
24547
  var _getCaretCoordinates = getCaretCoordinates__default["default"](textarea, selectionEnd),
24628
- newLeft = _getCaretCoordinates.left,
24629
- newTop = _getCaretCoordinates.top;
24630
-
24548
+ newLeft = _getCaretCoordinates.left,
24549
+ newTop = _getCaretCoordinates.top;
24631
24550
  _this.setState({
24632
24551
  // make position relative to textarea
24633
24552
  left: newLeft,
24634
24553
  top: newTop - _this.textareaRef.scrollTop || 0
24635
24554
  });
24636
24555
  }
24637
-
24638
24556
  _this.setState({
24639
24557
  actualToken: actualToken,
24640
24558
  currentTrigger: currentTrigger,
@@ -24648,77 +24566,62 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24648
24566
  }
24649
24567
  });
24650
24568
  });
24651
-
24652
24569
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_selectHandler", function (e) {
24653
24570
  var _this$props3 = _this.props,
24654
- onCaretPositionChange = _this$props3.onCaretPositionChange,
24655
- onSelect = _this$props3.onSelect;
24571
+ onCaretPositionChange = _this$props3.onCaretPositionChange,
24572
+ onSelect = _this$props3.onSelect;
24656
24573
  if (onCaretPositionChange) onCaretPositionChange(_this.getCaretPosition());
24657
-
24658
24574
  if (onSelect) {
24659
24575
  e.persist();
24660
24576
  onSelect(e);
24661
24577
  }
24662
24578
  });
24663
-
24664
24579
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_onClickAndBlurHandler", function (e) {
24665
24580
  var _this$props4 = _this.props,
24666
- closeOnClickOutside = _this$props4.closeOnClickOutside,
24667
- onBlur = _this$props4.onBlur; // If this is a click: e.target is the textarea, and e.relatedTarget is the thing
24581
+ closeOnClickOutside = _this$props4.closeOnClickOutside,
24582
+ onBlur = _this$props4.onBlur;
24583
+
24584
+ // If this is a click: e.target is the textarea, and e.relatedTarget is the thing
24668
24585
  // that was actually clicked. If we clicked inside the auto-select dropdown, then
24669
24586
  // that's not a blur, from the auto-select point of view, so then do nothing.
24670
-
24671
24587
  var el = e.relatedTarget;
24672
-
24673
24588
  if (_this.dropdownRef && el instanceof Node && _this.dropdownRef.contains(el)) {
24674
24589
  return;
24675
24590
  }
24676
-
24677
24591
  if (closeOnClickOutside) _this._closeAutocomplete();
24678
-
24679
24592
  if (onBlur) {
24680
24593
  e.persist();
24681
24594
  onBlur(e);
24682
24595
  }
24683
24596
  });
24684
-
24685
24597
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_onScrollHandler", function () {
24686
24598
  return _this._closeAutocomplete();
24687
24599
  });
24688
-
24689
24600
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "_dropdownScroll", function (item) {
24690
24601
  var scrollToItem = _this.props.scrollToItem;
24691
24602
  if (!scrollToItem) return;
24692
-
24693
24603
  if (scrollToItem === true) {
24694
24604
  defaultScrollToItem(_this.dropdownRef, item);
24695
24605
  return;
24696
24606
  }
24697
-
24698
24607
  if (typeof scrollToItem !== 'function' || scrollToItem.length !== 2) {
24699
24608
  throw new Error('`scrollToItem` has to be boolean (true for default implementation) or function with two parameters: container, item.');
24700
24609
  }
24701
-
24702
24610
  scrollToItem(_this.dropdownRef, item);
24703
24611
  });
24704
-
24705
24612
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getTriggerProps", function () {
24706
24613
  var _this$props5 = _this.props,
24707
- showCommandsList = _this$props5.showCommandsList,
24708
- showMentionsList = _this$props5.showMentionsList,
24709
- trigger = _this$props5.trigger;
24614
+ showCommandsList = _this$props5.showCommandsList,
24615
+ showMentionsList = _this$props5.showMentionsList,
24616
+ trigger = _this$props5.trigger;
24710
24617
  var _this$state6 = _this.state,
24711
- component = _this$state6.component,
24712
- currentTrigger = _this$state6.currentTrigger,
24713
- selectionEnd = _this$state6.selectionEnd,
24714
- value = _this$state6.value;
24715
-
24618
+ component = _this$state6.component,
24619
+ currentTrigger = _this$state6.currentTrigger,
24620
+ selectionEnd = _this$state6.selectionEnd,
24621
+ value = _this$state6.value;
24716
24622
  var selectedItem = _this._getItemOnSelect();
24717
-
24718
24623
  var suggestionData = _this._getSuggestions();
24719
-
24720
24624
  var textToReplace = _this._getTextToReplace();
24721
-
24722
24625
  var triggerProps = {
24723
24626
  component: component,
24724
24627
  currentTrigger: currentTrigger,
@@ -24728,7 +24631,6 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24728
24631
  value: value,
24729
24632
  values: suggestionData
24730
24633
  };
24731
-
24732
24634
  if (showCommandsList && trigger['/'] || showMentionsList && trigger['@']) {
24733
24635
  var currentCommands;
24734
24636
  var getCommands = trigger[showCommandsList ? '/' : '@'].dataProvider;
@@ -24743,28 +24645,25 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24743
24645
  triggerProps.value = showCommandsList ? '/' : '@';
24744
24646
  triggerProps.values = currentCommands;
24745
24647
  }
24746
-
24747
24648
  return triggerProps;
24748
24649
  });
24749
-
24750
24650
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "setDropdownRef", function (element) {
24751
24651
  _this.dropdownRef = element;
24752
24652
  });
24753
-
24754
24653
  var _this$props6 = _this.props,
24755
- loadingComponent = _this$props6.loadingComponent,
24756
- _trigger = _this$props6.trigger,
24757
- _value = _this$props6.value; // TODO: it would be better to have the parent control state...
24654
+ loadingComponent = _this$props6.loadingComponent,
24655
+ _trigger = _this$props6.trigger,
24656
+ _value = _this$props6.value;
24657
+
24658
+ // TODO: it would be better to have the parent control state...
24758
24659
  // if (value) this.state.value = value;
24759
24660
 
24760
24661
  if (!loadingComponent) {
24761
24662
  throw new Error('RTA: loadingComponent is not defined');
24762
24663
  }
24763
-
24764
24664
  if (!_trigger) {
24765
24665
  throw new Error('RTA: trigger is not defined');
24766
24666
  }
24767
-
24768
24667
  _this.state = {
24769
24668
  actualToken: '',
24770
24669
  component: null,
@@ -24779,22 +24678,20 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24779
24678
  };
24780
24679
  return _this;
24781
24680
  }
24782
-
24783
24681
  _createClass__default["default"](ReactTextareaAutocomplete, [{
24784
24682
  key: "renderSuggestionListContainer",
24785
24683
  value: function renderSuggestionListContainer() {
24786
24684
  var _this$props7 = this.props,
24787
- disableMentions = _this$props7.disableMentions,
24788
- dropdownClassName = _this$props7.dropdownClassName,
24789
- dropdownStyle = _this$props7.dropdownStyle,
24790
- itemClassName = _this$props7.itemClassName,
24791
- itemStyle = _this$props7.itemStyle,
24792
- listClassName = _this$props7.listClassName,
24793
- SuggestionItem = _this$props7.SuggestionItem,
24794
- _this$props7$Suggesti = _this$props7.SuggestionList,
24795
- SuggestionList = _this$props7$Suggesti === void 0 ? List : _this$props7$Suggesti;
24685
+ disableMentions = _this$props7.disableMentions,
24686
+ dropdownClassName = _this$props7.dropdownClassName,
24687
+ dropdownStyle = _this$props7.dropdownStyle,
24688
+ itemClassName = _this$props7.itemClassName,
24689
+ itemStyle = _this$props7.itemStyle,
24690
+ listClassName = _this$props7.listClassName,
24691
+ SuggestionItem = _this$props7.SuggestionItem,
24692
+ _this$props7$Suggesti = _this$props7.SuggestionList,
24693
+ SuggestionList = _this$props7$Suggesti === void 0 ? List : _this$props7$Suggesti;
24796
24694
  var triggerProps = this.getTriggerProps();
24797
-
24798
24695
  if (triggerProps.values && triggerProps.currentTrigger && !(disableMentions && triggerProps.currentTrigger === '@')) {
24799
24696
  return /*#__PURE__*/React__default["default"].createElement("div", {
24800
24697
  className: clsx('rta__autocomplete', 'str-chat__suggestion-list-container', dropdownClassName),
@@ -24809,24 +24706,24 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24809
24706
  SuggestionItem: SuggestionItem
24810
24707
  }, triggerProps)));
24811
24708
  }
24812
-
24813
24709
  return null;
24814
24710
  }
24815
24711
  }, {
24816
24712
  key: "render",
24817
24713
  value: function render() {
24818
24714
  var _this2 = this;
24819
-
24820
24715
  var _this$props8 = this.props,
24821
- className = _this$props8.className,
24822
- containerClassName = _this$props8.containerClassName,
24823
- containerStyle = _this$props8.containerStyle,
24824
- style = _this$props8.style;
24716
+ className = _this$props8.className,
24717
+ containerClassName = _this$props8.containerClassName,
24718
+ containerStyle = _this$props8.containerStyle,
24719
+ style = _this$props8.style;
24825
24720
  var maxRows = this.props.maxRows;
24826
24721
  var _this$state7 = this.state,
24827
- dataLoading = _this$state7.dataLoading,
24828
- value = _this$state7.value;
24829
- if (!this.props.grow) maxRows = 1; // By setting defaultValue to undefined, avoid error:
24722
+ dataLoading = _this$state7.dataLoading,
24723
+ value = _this$state7.value;
24724
+ if (!this.props.grow) maxRows = 1;
24725
+
24726
+ // By setting defaultValue to undefined, avoid error:
24830
24727
  // ForwardRef(TextareaAutosize) contains a textarea with both value and defaultValue props.
24831
24728
  // Textarea elements must be either controlled or uncontrolled
24832
24729
 
@@ -24849,7 +24746,6 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24849
24746
  onSelect: this._selectHandler,
24850
24747
  ref: function ref(_ref) {
24851
24748
  var _this2$props;
24852
-
24853
24749
  (_this2$props = _this2.props) === null || _this2$props === void 0 ? void 0 : _this2$props.innerRef(_ref);
24854
24750
  _this2.textareaRef = _ref;
24855
24751
  },
@@ -24878,12 +24774,9 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
24878
24774
  /**
24879
24775
  * Close autocomplete, also clean up trigger (to avoid slow promises)
24880
24776
  */
24881
-
24882
24777
  }]);
24883
-
24884
24778
  return ReactTextareaAutocomplete;
24885
24779
  }(React__default["default"].Component);
24886
-
24887
24780
  _defineProperty__default["default"](ReactTextareaAutocomplete, "defaultProps", {
24888
24781
  closeOnClickOutside: true,
24889
24782
  maxRows: 10,
@@ -24892,7 +24785,6 @@ _defineProperty__default["default"](ReactTextareaAutocomplete, "defaultProps", {
24892
24785
  scrollToItem: true,
24893
24786
  value: ''
24894
24787
  });
24895
-
24896
24788
  ReactTextareaAutocomplete.propTypes = {
24897
24789
  className: PropTypes__default["default"].string,
24898
24790
  closeOnClickOutside: PropTypes__default["default"].bool,
@@ -33778,7 +33670,7 @@ var UnMemoizedChannelList = function (props) {
33778
33670
  */
33779
33671
  var ChannelList = React__default["default"].memo(UnMemoizedChannelList);
33780
33672
 
33781
- var version = '10.6.0';
33673
+ var version = '10.7.1';
33782
33674
 
33783
33675
  var useChat = function (_a) {
33784
33676
  var _b, _c;
@@ -34870,7 +34762,6 @@ var useMessageListElements = function (props) {
34870
34762
  var lastReceivedId = React.useMemo(function () { return getLastReceived(enrichedMessages); }, [enrichedMessages]);
34871
34763
  var elements = React.useMemo(function () {
34872
34764
  return enrichedMessages.map(function (message) {
34873
- var _a;
34874
34765
  if (message.customType === CUSTOM_MESSAGE_TYPE.date &&
34875
34766
  message.date &&
34876
34767
  isDate(message.date)) {
@@ -34882,9 +34773,7 @@ var useMessageListElements = function (props) {
34882
34773
  React__default["default"].createElement(HeaderComponent, null)));
34883
34774
  }
34884
34775
  if (message.type === 'system') {
34885
- return (React__default["default"].createElement("li", { key: ((_a = message.event) === null || _a === void 0 ? void 0 : _a.created_at) ||
34886
- message.created_at ||
34887
- '' },
34776
+ return (React__default["default"].createElement("li", { key: message.id || message.created_at },
34888
34777
  React__default["default"].createElement(MessageSystem, { message: message })));
34889
34778
  }
34890
34779
  var groupStyles = messageGroupStyles[message.id] || '';
@@ -35905,6 +35794,7 @@ exports.MessageText = MessageText;
35905
35794
  exports.MessageTimestamp = MessageTimestamp;
35906
35795
  exports.Modal = Modal;
35907
35796
  exports.ModalGallery = ModalGallery;
35797
+ exports.NullComponent = NullComponent;
35908
35798
  exports.PinIcon = PinIcon;
35909
35799
  exports.PinIndicator = PinIndicator;
35910
35800
  exports.PlayButton = PlayButton;
@@ -35940,6 +35830,8 @@ exports.TypingContext = TypingContext;
35940
35830
  exports.TypingIndicator = TypingIndicator;
35941
35831
  exports.TypingProvider = TypingProvider;
35942
35832
  exports.UnMemoizedLoadMorePaginator = UnMemoizedLoadMorePaginator;
35833
+ exports.UnsupportedAttachment = UnsupportedAttachment;
35834
+ exports.UnsupportedAttachmentContainer = UnsupportedAttachmentContainer;
35943
35835
  exports.UploadIcon = UploadIcon;
35944
35836
  exports.UploadsPreview = UploadsPreview;
35945
35837
  exports.UserItem = UserItem;