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/browser.full-bundle.js +273 -334
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +5 -5
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Attachment/Attachment.d.ts +4 -1
- package/dist/components/Attachment/Attachment.d.ts.map +1 -1
- package/dist/components/Attachment/Attachment.js +20 -18
- package/dist/components/Attachment/AttachmentContainer.d.ts +1 -0
- package/dist/components/Attachment/AttachmentContainer.d.ts.map +1 -1
- package/dist/components/Attachment/AttachmentContainer.js +6 -0
- package/dist/components/Attachment/UnsupportedAttachment.d.ts +8 -0
- package/dist/components/Attachment/UnsupportedAttachment.d.ts.map +1 -0
- package/dist/components/Attachment/UnsupportedAttachment.js +12 -0
- package/dist/components/Attachment/index.d.ts +1 -0
- package/dist/components/Attachment/index.d.ts.map +1 -1
- package/dist/components/Attachment/index.js +1 -0
- package/dist/components/Gallery/Gallery.d.ts.map +1 -1
- package/dist/components/Gallery/Gallery.js +2 -1
- package/dist/components/MessageList/hooks/useMessageListElements.d.ts.map +1 -1
- package/dist/components/MessageList/hooks/useMessageListElements.js +1 -4
- package/dist/index.cjs.js +167 -275
- package/dist/index.cjs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -5
|
@@ -162,46 +162,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
162
162
|
return a;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
var dist$1 = {};
|
|
166
|
-
|
|
167
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};Object.defineProperty(dist$1, "__esModule", { value: true });
|
|
168
|
-
var sanitizeUrl_1 = dist$1.sanitizeUrl = void 0;
|
|
169
|
-
var invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
|
|
170
|
-
var htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
|
|
171
|
-
var ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
|
|
172
|
-
var urlSchemeRegex = /^([^:]+):/gm;
|
|
173
|
-
var relativeFirstCharacters = [".", "/"];
|
|
174
|
-
function isRelativeUrlWithoutProtocol(url) {
|
|
175
|
-
return relativeFirstCharacters.indexOf(url[0]) > -1;
|
|
176
|
-
}
|
|
177
|
-
// adapted from https://stackoverflow.com/a/29824550/2601552
|
|
178
|
-
function decodeHtmlCharacters(str) {
|
|
179
|
-
return str.replace(htmlEntitiesRegex, function (match, dec) {
|
|
180
|
-
return String.fromCharCode(dec);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
function sanitizeUrl(url) {
|
|
184
|
-
var sanitizedUrl = decodeHtmlCharacters(url || "")
|
|
185
|
-
.replace(ctrlCharactersRegex, "")
|
|
186
|
-
.trim();
|
|
187
|
-
if (!sanitizedUrl) {
|
|
188
|
-
return "about:blank";
|
|
189
|
-
}
|
|
190
|
-
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
191
|
-
return sanitizedUrl;
|
|
192
|
-
}
|
|
193
|
-
var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
194
|
-
if (!urlSchemeParseResults) {
|
|
195
|
-
return sanitizedUrl;
|
|
196
|
-
}
|
|
197
|
-
var urlScheme = urlSchemeParseResults[0];
|
|
198
|
-
if (invalidProtocolRegex.test(urlScheme)) {
|
|
199
|
-
return "about:blank";
|
|
200
|
-
}
|
|
201
|
-
return sanitizedUrl;
|
|
202
|
-
}
|
|
203
|
-
sanitizeUrl_1 = dist$1.sanitizeUrl = sanitizeUrl;
|
|
204
|
-
|
|
205
165
|
var lib$1 = {};
|
|
206
166
|
|
|
207
167
|
var players = {};
|
|
@@ -5810,11 +5770,53 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
5810
5770
|
return (React__default["default"].createElement("span", { className: 'str-chat__message-attachment-file--item-size' }, prettyBytes(fileSize)));
|
|
5811
5771
|
};
|
|
5812
5772
|
|
|
5773
|
+
var dist$2 = {};
|
|
5774
|
+
|
|
5775
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};Object.defineProperty(dist$2, "__esModule", { value: true });
|
|
5776
|
+
var sanitizeUrl_1$1 = dist$2.sanitizeUrl = void 0;
|
|
5777
|
+
var invalidProtocolRegex$1 = /^([^\w]*)(javascript|data|vbscript)/im;
|
|
5778
|
+
var htmlEntitiesRegex$1 = /&#(\w+)(^\w|;)?/g;
|
|
5779
|
+
var htmlCtrlEntityRegex = /&(newline|tab);/gi;
|
|
5780
|
+
var ctrlCharactersRegex$1 = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
|
|
5781
|
+
var urlSchemeRegex$1 = /^.+(:|:)/gim;
|
|
5782
|
+
var relativeFirstCharacters$1 = [".", "/"];
|
|
5783
|
+
function isRelativeUrlWithoutProtocol$1(url) {
|
|
5784
|
+
return relativeFirstCharacters$1.indexOf(url[0]) > -1;
|
|
5785
|
+
}
|
|
5786
|
+
// adapted from https://stackoverflow.com/a/29824550/2601552
|
|
5787
|
+
function decodeHtmlCharacters$1(str) {
|
|
5788
|
+
return str.replace(htmlEntitiesRegex$1, function (match, dec) {
|
|
5789
|
+
return String.fromCharCode(dec);
|
|
5790
|
+
});
|
|
5791
|
+
}
|
|
5792
|
+
function sanitizeUrl$1(url) {
|
|
5793
|
+
var sanitizedUrl = decodeHtmlCharacters$1(url || "")
|
|
5794
|
+
.replace(htmlCtrlEntityRegex, "")
|
|
5795
|
+
.replace(ctrlCharactersRegex$1, "")
|
|
5796
|
+
.trim();
|
|
5797
|
+
if (!sanitizedUrl) {
|
|
5798
|
+
return "about:blank";
|
|
5799
|
+
}
|
|
5800
|
+
if (isRelativeUrlWithoutProtocol$1(sanitizedUrl)) {
|
|
5801
|
+
return sanitizedUrl;
|
|
5802
|
+
}
|
|
5803
|
+
var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex$1);
|
|
5804
|
+
if (!urlSchemeParseResults) {
|
|
5805
|
+
return sanitizedUrl;
|
|
5806
|
+
}
|
|
5807
|
+
var urlScheme = urlSchemeParseResults[0];
|
|
5808
|
+
if (invalidProtocolRegex$1.test(urlScheme)) {
|
|
5809
|
+
return "about:blank";
|
|
5810
|
+
}
|
|
5811
|
+
return sanitizedUrl;
|
|
5812
|
+
}
|
|
5813
|
+
sanitizeUrl_1$1 = dist$2.sanitizeUrl = sanitizeUrl$1;
|
|
5814
|
+
|
|
5813
5815
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var UnMemoizedSafeAnchor = function (props) {
|
|
5814
5816
|
var children = props.children, className = props.className, download = props.download, href = props.href, rel = props.rel, target = props.target;
|
|
5815
5817
|
if (!href)
|
|
5816
5818
|
return null;
|
|
5817
|
-
var sanitized = sanitizeUrl_1(href);
|
|
5819
|
+
var sanitized = sanitizeUrl_1$1(href);
|
|
5818
5820
|
return (React__default["default"].createElement("a", { "aria-label": 'Attachment', className: className, download: download, href: sanitized, rel: rel, target: target }, children));
|
|
5819
5821
|
};
|
|
5820
5822
|
var SafeAnchor = React__default["default"].memo(UnMemoizedSafeAnchor);
|
|
@@ -7101,16 +7103,31 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
7101
7103
|
}
|
|
7102
7104
|
}
|
|
7103
7105
|
|
|
7106
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _toPrimitive(input, hint) {
|
|
7107
|
+
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
7108
|
+
var prim = input[Symbol.toPrimitive];
|
|
7109
|
+
if (prim !== undefined) {
|
|
7110
|
+
var res = prim.call(input, hint || "default");
|
|
7111
|
+
if (_typeof$1(res) !== "object") return res;
|
|
7112
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7113
|
+
}
|
|
7114
|
+
return (hint === "string" ? String : Number)(input);
|
|
7115
|
+
}
|
|
7116
|
+
|
|
7117
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _toPropertyKey(arg) {
|
|
7118
|
+
var key = _toPrimitive(arg, "string");
|
|
7119
|
+
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
7120
|
+
}
|
|
7121
|
+
|
|
7104
7122
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _defineProperties(target, props) {
|
|
7105
7123
|
for (var i = 0; i < props.length; i++) {
|
|
7106
7124
|
var descriptor = props[i];
|
|
7107
7125
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
7108
7126
|
descriptor.configurable = true;
|
|
7109
7127
|
if ("value" in descriptor) descriptor.writable = true;
|
|
7110
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
7128
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
7111
7129
|
}
|
|
7112
7130
|
}
|
|
7113
|
-
|
|
7114
7131
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
7115
7132
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
7116
7133
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -7124,16 +7141,14 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
7124
7141
|
if (self === void 0) {
|
|
7125
7142
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7126
7143
|
}
|
|
7127
|
-
|
|
7128
7144
|
return self;
|
|
7129
7145
|
}
|
|
7130
7146
|
|
|
7131
7147
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _setPrototypeOf(o, p) {
|
|
7132
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
7148
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
7133
7149
|
o.__proto__ = p;
|
|
7134
7150
|
return o;
|
|
7135
7151
|
};
|
|
7136
|
-
|
|
7137
7152
|
return _setPrototypeOf(o, p);
|
|
7138
7153
|
}
|
|
7139
7154
|
|
|
@@ -7141,7 +7156,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
7141
7156
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
7142
7157
|
throw new TypeError("Super expression must either be null or a function");
|
|
7143
7158
|
}
|
|
7144
|
-
|
|
7145
7159
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
7146
7160
|
constructor: {
|
|
7147
7161
|
value: subClass,
|
|
@@ -7161,18 +7175,18 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
7161
7175
|
} else if (call !== void 0) {
|
|
7162
7176
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
7163
7177
|
}
|
|
7164
|
-
|
|
7165
7178
|
return _assertThisInitialized(self);
|
|
7166
7179
|
}
|
|
7167
7180
|
|
|
7168
7181
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _getPrototypeOf(o) {
|
|
7169
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
7182
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
7170
7183
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
7171
7184
|
};
|
|
7172
7185
|
return _getPrototypeOf(o);
|
|
7173
7186
|
}
|
|
7174
7187
|
|
|
7175
7188
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _defineProperty$4(obj, key, value) {
|
|
7189
|
+
key = _toPropertyKey(key);
|
|
7176
7190
|
if (key in obj) {
|
|
7177
7191
|
Object.defineProperty(obj, key, {
|
|
7178
7192
|
value: value,
|
|
@@ -7183,7 +7197,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
7183
7197
|
} else {
|
|
7184
7198
|
obj[key] = value;
|
|
7185
7199
|
}
|
|
7186
|
-
|
|
7187
7200
|
return obj;
|
|
7188
7201
|
}
|
|
7189
7202
|
|
|
@@ -7197,11 +7210,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
7197
7210
|
|
|
7198
7211
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function _arrayLikeToArray$5(arr, len) {
|
|
7199
7212
|
if (len == null || len > arr.length) len = arr.length;
|
|
7200
|
-
|
|
7201
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
7202
|
-
arr2[i] = arr[i];
|
|
7203
|
-
}
|
|
7204
|
-
|
|
7213
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
7205
7214
|
return arr2;
|
|
7206
7215
|
}
|
|
7207
7216
|
|
|
@@ -10834,7 +10843,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
10834
10843
|
React__default["default"].createElement("p", null, t('{{ imageCount }} more', {
|
|
10835
10844
|
imageCount: images.length - countImagesDisplayedInPreview,
|
|
10836
10845
|
})))) : (React__default["default"].createElement("button", { className: 'str-chat__gallery-image', "data-testid": 'gallery-image', key: "gallery-image-".concat(i), onClick: function () { return toggleModal(i); } },
|
|
10837
|
-
React__default["default"].createElement("img", __assign$8({ 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); } })))));
|
|
10846
|
+
React__default["default"].createElement("img", __assign$8({ alt: 'User uploaded content', src: sanitizeUrl_1$1(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); } })))));
|
|
10838
10847
|
});
|
|
10839
10848
|
var className = clsx('str-chat__gallery', {
|
|
10840
10849
|
'str-chat__gallery--square': images.length > lastImageIndexInPreview,
|
|
@@ -10857,7 +10866,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
10857
10866
|
var _a = props.dimensions, dimensions = _a === void 0 ? {} : _a, fallback = props.fallback, image_url = props.image_url, thumb_url = props.thumb_url, innerRef = props.innerRef, previewUrl = props.previewUrl, style = props.style;
|
|
10858
10867
|
var _b = React$2.useState(false), modalIsOpen = _b[0], setModalIsOpen = _b[1];
|
|
10859
10868
|
var _c = useComponentContext('ImageComponent').ModalGallery, ModalGallery$1 = _c === void 0 ? ModalGallery : _c;
|
|
10860
|
-
var imageSrc = sanitizeUrl_1(previewUrl || image_url || thumb_url);
|
|
10869
|
+
var imageSrc = sanitizeUrl_1$1(previewUrl || image_url || thumb_url);
|
|
10861
10870
|
var toggleModal = function () { return setModalIsOpen(function (modalIsOpen) { return !modalIsOpen; }); };
|
|
10862
10871
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
10863
10872
|
React__default["default"].createElement("img", __assign$8({ alt: fallback, className: 'str-chat__message-attachment--img', "data-testid": 'image-test', onClick: toggleModal, src: imageSrc, style: style, tabIndex: 0 }, dimensions, (innerRef && { ref: innerRef }))),
|
|
@@ -15290,6 +15299,18 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
15290
15299
|
return tokens.length === 1 && tokens[0].isLink && (!type || tokens[0].t === type);
|
|
15291
15300
|
}
|
|
15292
15301
|
|
|
15302
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var UnsupportedAttachment = function (_a) {
|
|
15303
|
+
var _b;
|
|
15304
|
+
var attachment = _a.attachment;
|
|
15305
|
+
return (React__default["default"].createElement("div", null,
|
|
15306
|
+
React__default["default"].createElement("div", null,
|
|
15307
|
+
"Unsupported attachment type ",
|
|
15308
|
+
React__default["default"].createElement("strong", null, (_b = attachment.type) !== null && _b !== void 0 ? _b : 'unknown')),
|
|
15309
|
+
React__default["default"].createElement("code", null, JSON.stringify(attachment, null, 4)),
|
|
15310
|
+
";"));
|
|
15311
|
+
};
|
|
15312
|
+
var NullComponent = function () { return null; };
|
|
15313
|
+
|
|
15293
15314
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var AttachmentWithinContainer = function (_a) {
|
|
15294
15315
|
var _b;
|
|
15295
15316
|
var _c;
|
|
@@ -15427,12 +15448,18 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
15427
15448
|
content,
|
|
15428
15449
|
React__default["default"].createElement(AttachmentActionsContainer, __assign$8({}, props))))) : (React__default["default"].createElement(AttachmentWithinContainer, { attachment: attachment, componentType: componentType }, content));
|
|
15429
15450
|
};
|
|
15451
|
+
var UnsupportedAttachmentContainer = function (_a) {
|
|
15452
|
+
var attachment = _a.attachment, _b = _a.UnsupportedAttachment, UnsupportedAttachment = _b === void 0 ? NullComponent : _b;
|
|
15453
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
15454
|
+
React__default["default"].createElement(UnsupportedAttachment, { attachment: attachment })));
|
|
15455
|
+
};
|
|
15430
15456
|
|
|
15431
15457
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var CONTAINER_MAP = {
|
|
15432
15458
|
audio: AudioContainer,
|
|
15433
15459
|
card: CardContainer,
|
|
15434
15460
|
file: FileContainer,
|
|
15435
15461
|
media: MediaContainer,
|
|
15462
|
+
unsupported: UnsupportedAttachmentContainer,
|
|
15436
15463
|
};
|
|
15437
15464
|
var ATTACHMENT_GROUPS_ORDER = [
|
|
15438
15465
|
'card',
|
|
@@ -15441,6 +15468,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
15441
15468
|
'media',
|
|
15442
15469
|
'audio',
|
|
15443
15470
|
'file',
|
|
15471
|
+
'unsupported',
|
|
15444
15472
|
];
|
|
15445
15473
|
/**
|
|
15446
15474
|
* A component used for rendering message attachments. By default, the component supports: AttachmentActions, Audio, Card, File, Gallery, Image, and Video
|
|
@@ -15452,26 +15480,27 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
15452
15480
|
};
|
|
15453
15481
|
var renderGroupedAttachments = function (_a) {
|
|
15454
15482
|
var attachments = _a.attachments, rest = __rest$4(_a, ["attachments"]);
|
|
15455
|
-
var uploadedImages =
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
}
|
|
15460
|
-
|
|
15461
|
-
|
|
15462
|
-
|
|
15463
|
-
|
|
15464
|
-
|
|
15465
|
-
}
|
|
15466
|
-
}
|
|
15467
|
-
return acc;
|
|
15483
|
+
var uploadedImages = attachments.filter(function (attachment) {
|
|
15484
|
+
return isUploadedImage(attachment);
|
|
15485
|
+
});
|
|
15486
|
+
var containers = attachments
|
|
15487
|
+
.filter(function (attachment) { return !isUploadedImage(attachment); })
|
|
15488
|
+
.reduce(function (typeMap, attachment) {
|
|
15489
|
+
var attachmentType = getAttachmentType(attachment);
|
|
15490
|
+
var Container = CONTAINER_MAP[attachmentType];
|
|
15491
|
+
typeMap[attachmentType].push(React__default["default"].createElement(Container, __assign$8({ key: "".concat(attachmentType, "-").concat(typeMap[attachmentType].length) }, rest, { attachment: attachment })));
|
|
15492
|
+
return typeMap;
|
|
15468
15493
|
}, {
|
|
15469
15494
|
audio: [],
|
|
15470
15495
|
card: [],
|
|
15471
15496
|
file: [],
|
|
15472
|
-
gallery: [],
|
|
15473
|
-
image: [],
|
|
15474
15497
|
media: [],
|
|
15498
|
+
unsupported: [],
|
|
15499
|
+
// not used in reduce
|
|
15500
|
+
// eslint-disable-next-line sort-keys
|
|
15501
|
+
image: [],
|
|
15502
|
+
// eslint-disable-next-line sort-keys
|
|
15503
|
+
gallery: [],
|
|
15475
15504
|
});
|
|
15476
15505
|
if (uploadedImages.length > 1) {
|
|
15477
15506
|
containers['gallery'] = [
|
|
@@ -15501,23 +15530,21 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
15501
15530
|
else if (isFileAttachment(attachment)) {
|
|
15502
15531
|
return 'file';
|
|
15503
15532
|
}
|
|
15504
|
-
return
|
|
15533
|
+
return 'unsupported';
|
|
15505
15534
|
};
|
|
15506
15535
|
|
|
15507
15536
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
15508
15537
|
|
|
15509
15538
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var Item$1 = /*#__PURE__*/React__default["default"].forwardRef(function Item(props, innerRef) {
|
|
15510
15539
|
var className = props.className,
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15540
|
+
Component = props.component,
|
|
15541
|
+
item = props.item,
|
|
15542
|
+
onClickHandler = props.onClickHandler,
|
|
15543
|
+
onSelectHandler = props.onSelectHandler,
|
|
15544
|
+
selected = props.selected,
|
|
15545
|
+
style = props.style;
|
|
15518
15546
|
var _useChatContext = useChatContext('SuggestionItem'),
|
|
15519
|
-
|
|
15520
|
-
|
|
15547
|
+
themeVersion = _useChatContext.themeVersion;
|
|
15521
15548
|
var selectItem = React$2.useCallback(function () {
|
|
15522
15549
|
return onSelectHandler(item);
|
|
15523
15550
|
}, [item, onClickHandler]);
|
|
@@ -17723,12 +17750,12 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
17723
17750
|
};
|
|
17724
17751
|
|
|
17725
17752
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function isPlainObject(value) {
|
|
17726
|
-
if (
|
|
17753
|
+
if (typeof value !== 'object' || value === null) {
|
|
17727
17754
|
return false;
|
|
17728
17755
|
}
|
|
17729
17756
|
|
|
17730
17757
|
const prototype = Object.getPrototypeOf(value);
|
|
17731
|
-
return prototype === null || prototype === Object.prototype;
|
|
17758
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
17732
17759
|
}
|
|
17733
17760
|
|
|
17734
17761
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
|
|
@@ -37135,75 +37162,60 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
37135
37162
|
return null;
|
|
37136
37163
|
};
|
|
37137
37164
|
|
|
37138
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
37139
|
-
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; }
|
|
37140
|
-
|
|
37165
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};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; }
|
|
37141
37166
|
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) { definePropertyExports(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; }
|
|
37142
37167
|
var List$1 = function List(_ref) {
|
|
37143
37168
|
var className = _ref.className,
|
|
37144
|
-
|
|
37145
|
-
|
|
37146
|
-
|
|
37147
|
-
|
|
37148
|
-
|
|
37149
|
-
|
|
37150
|
-
|
|
37151
|
-
|
|
37152
|
-
|
|
37153
|
-
|
|
37154
|
-
|
|
37155
|
-
|
|
37156
|
-
|
|
37157
|
-
|
|
37158
|
-
|
|
37169
|
+
component = _ref.component,
|
|
37170
|
+
currentTrigger = _ref.currentTrigger,
|
|
37171
|
+
dropdownScroll = _ref.dropdownScroll,
|
|
37172
|
+
getSelectedItem = _ref.getSelectedItem,
|
|
37173
|
+
getTextToReplace = _ref.getTextToReplace,
|
|
37174
|
+
PropHeader = _ref.Header,
|
|
37175
|
+
itemClassName = _ref.itemClassName,
|
|
37176
|
+
itemStyle = _ref.itemStyle,
|
|
37177
|
+
onSelect = _ref.onSelect,
|
|
37178
|
+
selectionEnd = _ref.selectionEnd,
|
|
37179
|
+
style = _ref.style,
|
|
37180
|
+
PropSuggestionItem = _ref.SuggestionItem,
|
|
37181
|
+
propValue = _ref.value,
|
|
37182
|
+
values = _ref.values;
|
|
37159
37183
|
var _useComponentContext = useComponentContext('SuggestionList'),
|
|
37160
|
-
|
|
37161
|
-
|
|
37162
|
-
|
|
37184
|
+
AutocompleteSuggestionHeader = _useComponentContext.AutocompleteSuggestionHeader,
|
|
37185
|
+
AutocompleteSuggestionItem = _useComponentContext.AutocompleteSuggestionItem;
|
|
37163
37186
|
var _useChatContext = useChatContext('SuggestionList'),
|
|
37164
|
-
|
|
37165
|
-
|
|
37187
|
+
themeVersion = _useChatContext.themeVersion;
|
|
37166
37188
|
var SuggestionItem = PropSuggestionItem || AutocompleteSuggestionItem || Item$1;
|
|
37167
37189
|
var SuggestionHeader = PropHeader || AutocompleteSuggestionHeader || DefaultSuggestionListHeader;
|
|
37168
|
-
|
|
37169
37190
|
var _useState = React$2.useState(undefined),
|
|
37170
|
-
|
|
37171
|
-
|
|
37172
|
-
|
|
37173
|
-
|
|
37191
|
+
_useState2 = _slicedToArray$2(_useState, 2),
|
|
37192
|
+
selectedItem = _useState2[0],
|
|
37193
|
+
setSelectedItem = _useState2[1];
|
|
37174
37194
|
var itemsRef = [];
|
|
37175
|
-
|
|
37176
37195
|
var isSelected = function isSelected(item) {
|
|
37177
37196
|
return selectedItem === values.findIndex(function (value) {
|
|
37178
37197
|
return getId(value) === getId(item);
|
|
37179
37198
|
});
|
|
37180
37199
|
};
|
|
37181
|
-
|
|
37182
37200
|
var getId = function getId(item) {
|
|
37183
37201
|
var textToReplace = getTextToReplace(item);
|
|
37184
|
-
|
|
37185
37202
|
if (textToReplace.key) {
|
|
37186
37203
|
return textToReplace.key;
|
|
37187
37204
|
}
|
|
37188
|
-
|
|
37189
37205
|
if (typeof item === 'string' || !item.key) {
|
|
37190
37206
|
return textToReplace.text;
|
|
37191
37207
|
}
|
|
37192
|
-
|
|
37193
37208
|
return item.key;
|
|
37194
37209
|
};
|
|
37195
|
-
|
|
37196
37210
|
var modifyText = function modifyText(value) {
|
|
37197
37211
|
if (!value) return;
|
|
37198
37212
|
onSelect(getTextToReplace(value));
|
|
37199
37213
|
if (getSelectedItem) getSelectedItem(value);
|
|
37200
37214
|
};
|
|
37201
|
-
|
|
37202
37215
|
var handleClick = function handleClick(e) {
|
|
37203
37216
|
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
37204
37217
|
modifyText(values[selectedItem]);
|
|
37205
37218
|
};
|
|
37206
|
-
|
|
37207
37219
|
var selectItem = React$2.useCallback(function (item) {
|
|
37208
37220
|
var index = values.findIndex(function (value) {
|
|
37209
37221
|
return value.id ? value.id === item.id : value.name === item.name;
|
|
@@ -37219,7 +37231,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
37219
37231
|
return newID;
|
|
37220
37232
|
});
|
|
37221
37233
|
}
|
|
37222
|
-
|
|
37223
37234
|
if (event.key === 'ArrowDown') {
|
|
37224
37235
|
setSelectedItem(function (prevSelected) {
|
|
37225
37236
|
if (prevSelected === undefined) return 0;
|
|
@@ -37228,14 +37239,13 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
37228
37239
|
return newID;
|
|
37229
37240
|
});
|
|
37230
37241
|
}
|
|
37231
|
-
|
|
37232
37242
|
if ((event.key === 'Enter' || event.key === 'Tab') && selectedItem !== undefined) {
|
|
37233
37243
|
handleClick(event);
|
|
37234
37244
|
}
|
|
37235
|
-
|
|
37236
37245
|
return null;
|
|
37237
37246
|
}, [selectedItem, values] // eslint-disable-line
|
|
37238
37247
|
);
|
|
37248
|
+
|
|
37239
37249
|
React$2.useEffect(function () {
|
|
37240
37250
|
document.addEventListener('keydown', handleKeyDown, false);
|
|
37241
37251
|
return function () {
|
|
@@ -37914,12 +37924,11 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
37914
37924
|
var containerHight = parseInt(getComputedStyle(container).getPropertyValue('height'), 10) - itemHeight;
|
|
37915
37925
|
var actualScrollTop = container.scrollTop;
|
|
37916
37926
|
var itemOffsetTop = item.offsetTop;
|
|
37917
|
-
|
|
37918
37927
|
if (itemOffsetTop < actualScrollTop + containerHight && actualScrollTop < itemOffsetTop) {
|
|
37919
37928
|
return;
|
|
37920
|
-
}
|
|
37921
|
-
|
|
37929
|
+
}
|
|
37922
37930
|
|
|
37931
|
+
// eslint-disable-next-line
|
|
37923
37932
|
container.scrollTop = itemOffsetTop;
|
|
37924
37933
|
}
|
|
37925
37934
|
var errorMessage = function errorMessage(message) {
|
|
@@ -37929,40 +37938,33 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
37929
37938
|
var trigger = _ref.trigger;
|
|
37930
37939
|
if (!trigger) return Error('Invalid prop trigger. Prop missing.');
|
|
37931
37940
|
var triggers = Object.entries(trigger);
|
|
37932
|
-
|
|
37933
37941
|
for (var i = 0; i < triggers.length; i += 1) {
|
|
37934
37942
|
var _triggers$i = _slicedToArray$2(triggers[i], 2),
|
|
37935
|
-
|
|
37936
|
-
|
|
37937
|
-
|
|
37943
|
+
triggerChar = _triggers$i[0],
|
|
37944
|
+
settings = _triggers$i[1];
|
|
37938
37945
|
if (typeof triggerChar !== 'string' || triggerChar.length !== 1) {
|
|
37939
37946
|
return Error('Invalid prop trigger. Keys of the object has to be string / one character.');
|
|
37940
|
-
}
|
|
37941
|
-
|
|
37947
|
+
}
|
|
37942
37948
|
|
|
37949
|
+
// $FlowFixMe
|
|
37943
37950
|
var triggerSetting = settings;
|
|
37944
37951
|
var callback = triggerSetting.callback,
|
|
37945
|
-
|
|
37946
|
-
|
|
37947
|
-
|
|
37948
|
-
|
|
37952
|
+
component = triggerSetting.component,
|
|
37953
|
+
dataProvider = triggerSetting.dataProvider,
|
|
37954
|
+
output = triggerSetting.output;
|
|
37949
37955
|
if (!reactIs$1.exports.isValidElementType(component)) {
|
|
37950
37956
|
return Error('Invalid prop trigger: component should be defined.');
|
|
37951
37957
|
}
|
|
37952
|
-
|
|
37953
37958
|
if (!dataProvider || typeof dataProvider !== 'function') {
|
|
37954
37959
|
return Error('Invalid prop trigger: dataProvider should be defined.');
|
|
37955
37960
|
}
|
|
37956
|
-
|
|
37957
37961
|
if (output && typeof output !== 'function') {
|
|
37958
37962
|
return Error('Invalid prop trigger: output should be a function.');
|
|
37959
37963
|
}
|
|
37960
|
-
|
|
37961
37964
|
if (callback && typeof callback !== 'function') {
|
|
37962
37965
|
return Error('Invalid prop trigger: callback should be a function.');
|
|
37963
37966
|
}
|
|
37964
37967
|
}
|
|
37965
|
-
|
|
37966
37968
|
return null;
|
|
37967
37969
|
};
|
|
37968
37970
|
|
|
@@ -38033,26 +38035,17 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38033
38035
|
};
|
|
38034
38036
|
var UserItem = React__default["default"].memo(UnMemoizedUserItem);
|
|
38035
38037
|
|
|
38036
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
38037
|
-
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; }
|
|
38038
|
-
|
|
38038
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};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; }
|
|
38039
38039
|
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) { definePropertyExports(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; }
|
|
38040
|
-
|
|
38041
38040
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = getPrototypeOfExports(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = getPrototypeOfExports(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturnExports(this, result); }; }
|
|
38042
|
-
|
|
38043
38041
|
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; } }
|
|
38044
38042
|
var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
|
|
38045
38043
|
inheritsExports(ReactTextareaAutocomplete, _React$Component);
|
|
38046
|
-
|
|
38047
38044
|
var _super = _createSuper(ReactTextareaAutocomplete);
|
|
38048
|
-
|
|
38049
38045
|
function ReactTextareaAutocomplete(_props) {
|
|
38050
38046
|
var _this;
|
|
38051
|
-
|
|
38052
38047
|
classCallCheckExports(this, ReactTextareaAutocomplete);
|
|
38053
|
-
|
|
38054
38048
|
_this = _super.call(this, _props);
|
|
38055
|
-
|
|
38056
38049
|
definePropertyExports(assertThisInitializedExports(_this), "getSelectionPosition", function () {
|
|
38057
38050
|
if (!_this.textareaRef) return null;
|
|
38058
38051
|
return {
|
|
@@ -38060,72 +38053,58 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38060
38053
|
selectionStart: _this.textareaRef.selectionStart
|
|
38061
38054
|
};
|
|
38062
38055
|
});
|
|
38063
|
-
|
|
38064
38056
|
definePropertyExports(assertThisInitializedExports(_this), "getSelectedText", function () {
|
|
38065
38057
|
if (!_this.textareaRef) return null;
|
|
38066
38058
|
var _this$textareaRef = _this.textareaRef,
|
|
38067
|
-
|
|
38068
|
-
|
|
38059
|
+
selectionEnd = _this$textareaRef.selectionEnd,
|
|
38060
|
+
selectionStart = _this$textareaRef.selectionStart;
|
|
38069
38061
|
if (selectionStart === selectionEnd) return null;
|
|
38070
38062
|
return _this.state.value.substr(selectionStart, selectionEnd - selectionStart);
|
|
38071
38063
|
});
|
|
38072
|
-
|
|
38073
38064
|
definePropertyExports(assertThisInitializedExports(_this), "setCaretPosition", function () {
|
|
38074
38065
|
var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
38075
38066
|
if (!_this.textareaRef) return;
|
|
38076
|
-
|
|
38077
38067
|
_this.textareaRef.focus();
|
|
38078
|
-
|
|
38079
38068
|
_this.textareaRef.setSelectionRange(position, position);
|
|
38080
38069
|
});
|
|
38081
|
-
|
|
38082
38070
|
definePropertyExports(assertThisInitializedExports(_this), "getCaretPosition", function () {
|
|
38083
38071
|
if (!_this.textareaRef) return 0;
|
|
38084
38072
|
return _this.textareaRef.selectionEnd;
|
|
38085
38073
|
});
|
|
38086
|
-
|
|
38087
38074
|
definePropertyExports(assertThisInitializedExports(_this), "_defaultShouldSubmit", function (event) {
|
|
38088
38075
|
return event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing;
|
|
38089
38076
|
});
|
|
38090
|
-
|
|
38091
38077
|
definePropertyExports(assertThisInitializedExports(_this), "_handleKeyDown", function (event) {
|
|
38092
38078
|
var _this$props$shouldSub = _this.props.shouldSubmit,
|
|
38093
|
-
|
|
38079
|
+
shouldSubmit = _this$props$shouldSub === void 0 ? _this._defaultShouldSubmit : _this$props$shouldSub;
|
|
38094
38080
|
|
|
38081
|
+
// prevent default behaviour when the selection list is rendered
|
|
38095
38082
|
if ((event.key === 'ArrowUp' || event.key === 'ArrowDown') && _this.dropdownRef) event.preventDefault();
|
|
38096
38083
|
if (shouldSubmit !== null && shouldSubmit !== void 0 && shouldSubmit(event)) return _this._onEnter(event);
|
|
38097
38084
|
if (event.key === ' ') return _this._onSpace(event);
|
|
38098
38085
|
if (event.key === 'Escape') return _this._closeAutocomplete();
|
|
38099
38086
|
});
|
|
38100
|
-
|
|
38101
38087
|
definePropertyExports(assertThisInitializedExports(_this), "_onEnter", function (event) {
|
|
38102
38088
|
if (!_this.textareaRef) return;
|
|
38103
38089
|
var trigger = _this.state.currentTrigger;
|
|
38104
|
-
|
|
38105
38090
|
if (!trigger || !_this.state.data) {
|
|
38106
38091
|
// trigger a submit
|
|
38107
38092
|
_this._replaceWord();
|
|
38108
|
-
|
|
38109
38093
|
if (_this.textareaRef) {
|
|
38110
38094
|
_this.textareaRef.selectionEnd = 0;
|
|
38111
38095
|
}
|
|
38112
|
-
|
|
38113
38096
|
_this.props.handleSubmit(event);
|
|
38114
|
-
|
|
38115
38097
|
_this._closeAutocomplete();
|
|
38116
38098
|
}
|
|
38117
38099
|
});
|
|
38118
|
-
|
|
38119
38100
|
definePropertyExports(assertThisInitializedExports(_this), "_onSpace", function () {
|
|
38120
|
-
if (!_this.props.replaceWord || !_this.textareaRef) return;
|
|
38101
|
+
if (!_this.props.replaceWord || !_this.textareaRef) return;
|
|
38121
38102
|
|
|
38103
|
+
// don't change characters if the element doesn't have focus
|
|
38122
38104
|
var hasFocus = _this.textareaRef.matches(':focus');
|
|
38123
|
-
|
|
38124
38105
|
if (!hasFocus) return;
|
|
38125
|
-
|
|
38126
38106
|
_this._replaceWord();
|
|
38127
38107
|
});
|
|
38128
|
-
|
|
38129
38108
|
definePropertyExports(assertThisInitializedExports(_this), "_replaceWord", function () {
|
|
38130
38109
|
var value = _this.state.value;
|
|
38131
38110
|
var lastWordRegex = /([^\s]+)(\s*)$/;
|
|
@@ -38133,14 +38112,11 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38133
38112
|
var lastWord = match && match[1];
|
|
38134
38113
|
if (!lastWord) return;
|
|
38135
38114
|
var spaces = match[2];
|
|
38136
|
-
|
|
38137
38115
|
var newWord = _this.props.replaceWord(lastWord);
|
|
38138
|
-
|
|
38139
38116
|
if (newWord == null) return;
|
|
38140
38117
|
var textBeforeWord = value.slice(0, _this.getCaretPosition() - match[0].length);
|
|
38141
38118
|
var textAfterCaret = value.slice(_this.getCaretPosition(), -1);
|
|
38142
38119
|
var newText = textBeforeWord + newWord + spaces + textAfterCaret;
|
|
38143
|
-
|
|
38144
38120
|
_this.setState({
|
|
38145
38121
|
value: newText
|
|
38146
38122
|
}, function () {
|
|
@@ -38148,53 +38124,47 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38148
38124
|
var e = new CustomEvent('change', {
|
|
38149
38125
|
bubbles: true
|
|
38150
38126
|
});
|
|
38151
|
-
|
|
38152
38127
|
_this.textareaRef.dispatchEvent(e);
|
|
38153
|
-
|
|
38154
38128
|
if (_this.props.onChange) _this.props.onChange(e);
|
|
38155
38129
|
});
|
|
38156
38130
|
});
|
|
38157
|
-
|
|
38158
38131
|
definePropertyExports(assertThisInitializedExports(_this), "_onSelect", function (newToken) {
|
|
38159
38132
|
var _this$props = _this.props,
|
|
38160
|
-
|
|
38161
|
-
|
|
38162
|
-
|
|
38163
|
-
|
|
38164
|
-
|
|
38133
|
+
closeCommandsList = _this$props.closeCommandsList,
|
|
38134
|
+
closeMentionsList = _this$props.closeMentionsList,
|
|
38135
|
+
onChange = _this$props.onChange,
|
|
38136
|
+
showCommandsList = _this$props.showCommandsList,
|
|
38137
|
+
showMentionsList = _this$props.showMentionsList;
|
|
38165
38138
|
var _this$state = _this.state,
|
|
38166
|
-
|
|
38167
|
-
|
|
38168
|
-
|
|
38139
|
+
stateTrigger = _this$state.currentTrigger,
|
|
38140
|
+
selectionEnd = _this$state.selectionEnd,
|
|
38141
|
+
textareaValue = _this$state.value;
|
|
38169
38142
|
var currentTrigger = showCommandsList ? '/' : showMentionsList ? '@' : stateTrigger;
|
|
38170
38143
|
if (!currentTrigger) return;
|
|
38171
|
-
|
|
38172
38144
|
var computeCaretPosition = function computeCaretPosition(position, token, startToken) {
|
|
38173
38145
|
switch (position) {
|
|
38174
38146
|
case 'start':
|
|
38175
38147
|
return startToken;
|
|
38176
|
-
|
|
38177
38148
|
case 'next':
|
|
38178
38149
|
case 'end':
|
|
38179
38150
|
return startToken + token.length;
|
|
38180
|
-
|
|
38181
38151
|
default:
|
|
38182
38152
|
if (!Number.isInteger(position)) {
|
|
38183
38153
|
throw new Error('RTA: caretPosition should be "start", "next", "end" or number.');
|
|
38184
38154
|
}
|
|
38185
|
-
|
|
38186
38155
|
return position;
|
|
38187
38156
|
}
|
|
38188
38157
|
};
|
|
38189
|
-
|
|
38190
38158
|
var textToModify = showCommandsList ? '/' : showMentionsList ? '@' : textareaValue.slice(0, selectionEnd);
|
|
38191
|
-
var startOfTokenPosition = textToModify.lastIndexOf(currentTrigger);
|
|
38159
|
+
var startOfTokenPosition = textToModify.lastIndexOf(currentTrigger);
|
|
38192
38160
|
|
|
38161
|
+
// we add space after emoji is selected if a caret position is next
|
|
38193
38162
|
var newTokenString = newToken.caretPosition === 'next' ? "".concat(newToken.text, " ") : newToken.text;
|
|
38194
38163
|
var newCaretPosition = computeCaretPosition(newToken.caretPosition, newTokenString, startOfTokenPosition);
|
|
38195
38164
|
var modifiedText = textToModify.substring(0, startOfTokenPosition) + newTokenString;
|
|
38196
|
-
var valueToReplace = textareaValue.replace(textToModify, modifiedText);
|
|
38165
|
+
var valueToReplace = textareaValue.replace(textToModify, modifiedText);
|
|
38197
38166
|
|
|
38167
|
+
// set the new textarea value and after that set the caret back to its position
|
|
38198
38168
|
_this.setState({
|
|
38199
38169
|
dataLoading: false,
|
|
38200
38170
|
value: valueToReplace
|
|
@@ -38203,25 +38173,17 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38203
38173
|
var e = new CustomEvent('change', {
|
|
38204
38174
|
bubbles: true
|
|
38205
38175
|
});
|
|
38206
|
-
|
|
38207
38176
|
_this.textareaRef.dispatchEvent(e);
|
|
38208
|
-
|
|
38209
38177
|
if (onChange) onChange(e);
|
|
38210
|
-
|
|
38211
38178
|
_this.setCaretPosition(newCaretPosition);
|
|
38212
38179
|
});
|
|
38213
|
-
|
|
38214
38180
|
_this._closeAutocomplete();
|
|
38215
|
-
|
|
38216
38181
|
if (showCommandsList) closeCommandsList();
|
|
38217
38182
|
if (showMentionsList) closeMentionsList();
|
|
38218
38183
|
});
|
|
38219
|
-
|
|
38220
38184
|
definePropertyExports(assertThisInitializedExports(_this), "_getItemOnSelect", function (paramTrigger) {
|
|
38221
38185
|
var stateTrigger = _this.state.currentTrigger;
|
|
38222
|
-
|
|
38223
38186
|
var triggerSettings = _this._getCurrentTriggerSettings(paramTrigger);
|
|
38224
|
-
|
|
38225
38187
|
var currentTrigger = paramTrigger || stateTrigger;
|
|
38226
38188
|
if (!currentTrigger || !triggerSettings) return null;
|
|
38227
38189
|
var callback = triggerSettings.callback;
|
|
@@ -38230,22 +38192,17 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38230
38192
|
if (typeof callback !== 'function') {
|
|
38231
38193
|
throw new Error('Output functor is not defined! You have to define "output" function. https://github.com/webscopeio/react-textarea-autocomplete#trigger-type');
|
|
38232
38194
|
}
|
|
38233
|
-
|
|
38234
38195
|
if (callback) {
|
|
38235
38196
|
return callback(item, currentTrigger);
|
|
38236
38197
|
}
|
|
38237
|
-
|
|
38238
38198
|
return null;
|
|
38239
38199
|
};
|
|
38240
38200
|
});
|
|
38241
|
-
|
|
38242
38201
|
definePropertyExports(assertThisInitializedExports(_this), "_getTextToReplace", function (paramTrigger) {
|
|
38243
38202
|
var _this$state2 = _this.state,
|
|
38244
|
-
|
|
38245
|
-
|
|
38246
|
-
|
|
38203
|
+
actualToken = _this$state2.actualToken,
|
|
38204
|
+
stateTrigger = _this$state2.currentTrigger;
|
|
38247
38205
|
var triggerSettings = _this._getCurrentTriggerSettings(paramTrigger);
|
|
38248
|
-
|
|
38249
38206
|
var currentTrigger = paramTrigger || stateTrigger;
|
|
38250
38207
|
if (!currentTrigger || !triggerSettings) return null;
|
|
38251
38208
|
var output = triggerSettings.output;
|
|
@@ -38253,91 +38210,74 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38253
38210
|
if (_typeof$2(item) === 'object' && (!output || typeof output !== 'function')) {
|
|
38254
38211
|
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');
|
|
38255
38212
|
}
|
|
38256
|
-
|
|
38257
38213
|
if (output) {
|
|
38258
38214
|
var textToReplace = output(item, currentTrigger);
|
|
38259
|
-
|
|
38260
38215
|
if (!textToReplace || typeof textToReplace === 'number') {
|
|
38261
38216
|
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"));
|
|
38262
38217
|
}
|
|
38263
|
-
|
|
38264
38218
|
if (typeof textToReplace === 'string') {
|
|
38265
38219
|
return {
|
|
38266
38220
|
caretPosition: DEFAULT_CARET_POSITION,
|
|
38267
38221
|
text: textToReplace
|
|
38268
38222
|
};
|
|
38269
38223
|
}
|
|
38270
|
-
|
|
38271
38224
|
if (!textToReplace.text && currentTrigger !== ':') {
|
|
38272
38225
|
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"));
|
|
38273
38226
|
}
|
|
38274
|
-
|
|
38275
38227
|
if (!textToReplace.caretPosition) {
|
|
38276
38228
|
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"));
|
|
38277
38229
|
}
|
|
38278
|
-
|
|
38279
38230
|
return textToReplace;
|
|
38280
38231
|
}
|
|
38281
|
-
|
|
38282
38232
|
if (typeof item !== 'string') {
|
|
38283
38233
|
throw new Error('Output item should be string\n');
|
|
38284
38234
|
}
|
|
38285
|
-
|
|
38286
38235
|
return {
|
|
38287
38236
|
caretPosition: DEFAULT_CARET_POSITION,
|
|
38288
38237
|
text: "".concat(currentTrigger).concat(item).concat(currentTrigger)
|
|
38289
38238
|
};
|
|
38290
38239
|
};
|
|
38291
38240
|
});
|
|
38292
|
-
|
|
38293
38241
|
definePropertyExports(assertThisInitializedExports(_this), "_getCurrentTriggerSettings", function (paramTrigger) {
|
|
38294
38242
|
var stateTrigger = _this.state.currentTrigger;
|
|
38295
38243
|
var currentTrigger = paramTrigger || stateTrigger;
|
|
38296
38244
|
if (!currentTrigger) return null;
|
|
38297
38245
|
return _this.props.trigger[currentTrigger];
|
|
38298
38246
|
});
|
|
38299
|
-
|
|
38300
38247
|
definePropertyExports(assertThisInitializedExports(_this), "_getValuesFromProvider", function () {
|
|
38301
38248
|
var _this$state3 = _this.state,
|
|
38302
|
-
|
|
38303
|
-
|
|
38304
|
-
|
|
38249
|
+
actualToken = _this$state3.actualToken,
|
|
38250
|
+
currentTrigger = _this$state3.currentTrigger;
|
|
38305
38251
|
var triggerSettings = _this._getCurrentTriggerSettings();
|
|
38306
|
-
|
|
38307
38252
|
if (!currentTrigger || !triggerSettings) return;
|
|
38308
38253
|
var component = triggerSettings.component,
|
|
38309
|
-
|
|
38310
|
-
|
|
38254
|
+
dataProvider = triggerSettings.dataProvider;
|
|
38311
38255
|
if (typeof dataProvider !== 'function') {
|
|
38312
38256
|
throw new Error('Trigger provider has to be a function!');
|
|
38313
38257
|
}
|
|
38314
|
-
|
|
38315
38258
|
_this.setState({
|
|
38316
38259
|
dataLoading: true
|
|
38317
|
-
});
|
|
38318
|
-
|
|
38260
|
+
});
|
|
38319
38261
|
|
|
38262
|
+
// Modified: send the full text to support / style commands
|
|
38320
38263
|
dataProvider(actualToken, _this.state.value, function (data, token) {
|
|
38321
38264
|
// Make sure that the result is still relevant for current query
|
|
38322
38265
|
if (token !== _this.state.actualToken) return;
|
|
38323
|
-
|
|
38324
38266
|
if (!Array.isArray(data)) {
|
|
38325
38267
|
throw new Error('Trigger provider has to provide an array!');
|
|
38326
38268
|
}
|
|
38327
|
-
|
|
38328
38269
|
if (!reactIs$1.exports.isValidElementType(component)) {
|
|
38329
38270
|
throw new Error('Component should be defined!');
|
|
38330
|
-
}
|
|
38331
|
-
|
|
38271
|
+
}
|
|
38332
38272
|
|
|
38333
|
-
|
|
38273
|
+
// throw away if we resolved old trigger
|
|
38274
|
+
if (currentTrigger !== _this.state.currentTrigger) return;
|
|
38334
38275
|
|
|
38276
|
+
// if we haven't resolved any data let's close the autocomplete
|
|
38335
38277
|
if (!data.length) {
|
|
38336
38278
|
_this._closeAutocomplete();
|
|
38337
|
-
|
|
38338
38279
|
return;
|
|
38339
38280
|
}
|
|
38340
|
-
|
|
38341
38281
|
_this.setState({
|
|
38342
38282
|
component: component,
|
|
38343
38283
|
data: data,
|
|
@@ -38345,16 +38285,14 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38345
38285
|
});
|
|
38346
38286
|
});
|
|
38347
38287
|
});
|
|
38348
|
-
|
|
38349
38288
|
definePropertyExports(assertThisInitializedExports(_this), "_getSuggestions", function (paramTrigger) {
|
|
38350
38289
|
var _this$state4 = _this.state,
|
|
38351
|
-
|
|
38352
|
-
|
|
38290
|
+
stateTrigger = _this$state4.currentTrigger,
|
|
38291
|
+
data = _this$state4.data;
|
|
38353
38292
|
var currentTrigger = paramTrigger || stateTrigger;
|
|
38354
38293
|
if (!currentTrigger || !data || data && !data.length) return null;
|
|
38355
38294
|
return data;
|
|
38356
38295
|
});
|
|
38357
|
-
|
|
38358
38296
|
definePropertyExports(assertThisInitializedExports(_this), "_closeAutocomplete", function () {
|
|
38359
38297
|
_this.setState({
|
|
38360
38298
|
currentTrigger: null,
|
|
@@ -38364,54 +38302,45 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38364
38302
|
top: null
|
|
38365
38303
|
});
|
|
38366
38304
|
});
|
|
38367
|
-
|
|
38368
38305
|
definePropertyExports(assertThisInitializedExports(_this), "_cleanUpProps", function () {
|
|
38369
38306
|
var props = _objectSpread$2({}, _this.props);
|
|
38307
|
+
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'];
|
|
38370
38308
|
|
|
38371
|
-
|
|
38372
|
-
|
|
38309
|
+
// eslint-disable-next-line
|
|
38373
38310
|
for (var prop in props) {
|
|
38374
38311
|
if (notSafe.includes(prop)) delete props[prop];
|
|
38375
38312
|
}
|
|
38376
|
-
|
|
38377
38313
|
return props;
|
|
38378
38314
|
});
|
|
38379
|
-
|
|
38380
38315
|
definePropertyExports(assertThisInitializedExports(_this), "_isCommand", function (text) {
|
|
38381
38316
|
if (text[0] !== '/') return false;
|
|
38382
38317
|
var tokens = text.split(' ');
|
|
38383
38318
|
return tokens.length <= 1;
|
|
38384
38319
|
});
|
|
38385
|
-
|
|
38386
38320
|
definePropertyExports(assertThisInitializedExports(_this), "_changeHandler", function (e) {
|
|
38387
38321
|
var _this$props2 = _this.props,
|
|
38388
|
-
|
|
38389
|
-
|
|
38390
|
-
|
|
38391
|
-
|
|
38392
|
-
|
|
38322
|
+
minChar = _this$props2.minChar,
|
|
38323
|
+
movePopupAsYouType = _this$props2.movePopupAsYouType,
|
|
38324
|
+
onCaretPositionChange = _this$props2.onCaretPositionChange,
|
|
38325
|
+
onChange = _this$props2.onChange,
|
|
38326
|
+
trigger = _this$props2.trigger;
|
|
38393
38327
|
var _this$state5 = _this.state,
|
|
38394
|
-
|
|
38395
|
-
|
|
38328
|
+
left = _this$state5.left,
|
|
38329
|
+
top = _this$state5.top;
|
|
38396
38330
|
var textarea = e.target;
|
|
38397
38331
|
var selectionEnd = textarea.selectionEnd,
|
|
38398
|
-
|
|
38399
|
-
|
|
38400
|
-
|
|
38332
|
+
selectionStart = textarea.selectionStart,
|
|
38333
|
+
value = textarea.value;
|
|
38401
38334
|
if (onChange) {
|
|
38402
38335
|
e.persist();
|
|
38403
38336
|
onChange(e);
|
|
38404
38337
|
}
|
|
38405
|
-
|
|
38406
38338
|
if (onCaretPositionChange) onCaretPositionChange(_this.getCaretPosition());
|
|
38407
|
-
|
|
38408
38339
|
_this.setState({
|
|
38409
38340
|
value: value
|
|
38410
38341
|
});
|
|
38411
|
-
|
|
38412
38342
|
var currentTrigger;
|
|
38413
38343
|
var lastToken;
|
|
38414
|
-
|
|
38415
38344
|
if (_this._isCommand(value)) {
|
|
38416
38345
|
currentTrigger = '/';
|
|
38417
38346
|
lastToken = value;
|
|
@@ -38425,35 +38354,31 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38425
38354
|
return a === lastToken[0];
|
|
38426
38355
|
}) || null;
|
|
38427
38356
|
}
|
|
38357
|
+
|
|
38428
38358
|
/*
|
|
38429
38359
|
if we lost the trigger token or there is no following character we want to close
|
|
38430
38360
|
the autocomplete
|
|
38431
38361
|
*/
|
|
38432
|
-
|
|
38433
|
-
|
|
38434
38362
|
if (!lastToken || lastToken.length <= minChar) {
|
|
38435
38363
|
_this._closeAutocomplete();
|
|
38436
|
-
|
|
38437
38364
|
return;
|
|
38438
38365
|
}
|
|
38366
|
+
var actualToken = lastToken.slice(1);
|
|
38439
38367
|
|
|
38440
|
-
|
|
38441
|
-
|
|
38368
|
+
// if trigger is not configured step out from the function, otherwise proceed
|
|
38442
38369
|
if (!currentTrigger) return;
|
|
38443
|
-
|
|
38444
|
-
|
|
38370
|
+
if (movePopupAsYouType || top === null && left === null ||
|
|
38371
|
+
// if we have single char - trigger it means we want to re-position the autocomplete
|
|
38445
38372
|
lastToken.length === 1) {
|
|
38446
38373
|
var _getCaretCoordinates = getCaretCoordinates(textarea, selectionEnd),
|
|
38447
|
-
|
|
38448
|
-
|
|
38449
|
-
|
|
38374
|
+
newLeft = _getCaretCoordinates.left,
|
|
38375
|
+
newTop = _getCaretCoordinates.top;
|
|
38450
38376
|
_this.setState({
|
|
38451
38377
|
// make position relative to textarea
|
|
38452
38378
|
left: newLeft,
|
|
38453
38379
|
top: newTop - _this.textareaRef.scrollTop || 0
|
|
38454
38380
|
});
|
|
38455
38381
|
}
|
|
38456
|
-
|
|
38457
38382
|
_this.setState({
|
|
38458
38383
|
actualToken: actualToken,
|
|
38459
38384
|
currentTrigger: currentTrigger,
|
|
@@ -38467,77 +38392,62 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38467
38392
|
}
|
|
38468
38393
|
});
|
|
38469
38394
|
});
|
|
38470
|
-
|
|
38471
38395
|
definePropertyExports(assertThisInitializedExports(_this), "_selectHandler", function (e) {
|
|
38472
38396
|
var _this$props3 = _this.props,
|
|
38473
|
-
|
|
38474
|
-
|
|
38397
|
+
onCaretPositionChange = _this$props3.onCaretPositionChange,
|
|
38398
|
+
onSelect = _this$props3.onSelect;
|
|
38475
38399
|
if (onCaretPositionChange) onCaretPositionChange(_this.getCaretPosition());
|
|
38476
|
-
|
|
38477
38400
|
if (onSelect) {
|
|
38478
38401
|
e.persist();
|
|
38479
38402
|
onSelect(e);
|
|
38480
38403
|
}
|
|
38481
38404
|
});
|
|
38482
|
-
|
|
38483
38405
|
definePropertyExports(assertThisInitializedExports(_this), "_onClickAndBlurHandler", function (e) {
|
|
38484
38406
|
var _this$props4 = _this.props,
|
|
38485
|
-
|
|
38486
|
-
|
|
38407
|
+
closeOnClickOutside = _this$props4.closeOnClickOutside,
|
|
38408
|
+
onBlur = _this$props4.onBlur;
|
|
38409
|
+
|
|
38410
|
+
// If this is a click: e.target is the textarea, and e.relatedTarget is the thing
|
|
38487
38411
|
// that was actually clicked. If we clicked inside the auto-select dropdown, then
|
|
38488
38412
|
// that's not a blur, from the auto-select point of view, so then do nothing.
|
|
38489
|
-
|
|
38490
38413
|
var el = e.relatedTarget;
|
|
38491
|
-
|
|
38492
38414
|
if (_this.dropdownRef && el instanceof Node && _this.dropdownRef.contains(el)) {
|
|
38493
38415
|
return;
|
|
38494
38416
|
}
|
|
38495
|
-
|
|
38496
38417
|
if (closeOnClickOutside) _this._closeAutocomplete();
|
|
38497
|
-
|
|
38498
38418
|
if (onBlur) {
|
|
38499
38419
|
e.persist();
|
|
38500
38420
|
onBlur(e);
|
|
38501
38421
|
}
|
|
38502
38422
|
});
|
|
38503
|
-
|
|
38504
38423
|
definePropertyExports(assertThisInitializedExports(_this), "_onScrollHandler", function () {
|
|
38505
38424
|
return _this._closeAutocomplete();
|
|
38506
38425
|
});
|
|
38507
|
-
|
|
38508
38426
|
definePropertyExports(assertThisInitializedExports(_this), "_dropdownScroll", function (item) {
|
|
38509
38427
|
var scrollToItem = _this.props.scrollToItem;
|
|
38510
38428
|
if (!scrollToItem) return;
|
|
38511
|
-
|
|
38512
38429
|
if (scrollToItem === true) {
|
|
38513
38430
|
defaultScrollToItem(_this.dropdownRef, item);
|
|
38514
38431
|
return;
|
|
38515
38432
|
}
|
|
38516
|
-
|
|
38517
38433
|
if (typeof scrollToItem !== 'function' || scrollToItem.length !== 2) {
|
|
38518
38434
|
throw new Error('`scrollToItem` has to be boolean (true for default implementation) or function with two parameters: container, item.');
|
|
38519
38435
|
}
|
|
38520
|
-
|
|
38521
38436
|
scrollToItem(_this.dropdownRef, item);
|
|
38522
38437
|
});
|
|
38523
|
-
|
|
38524
38438
|
definePropertyExports(assertThisInitializedExports(_this), "getTriggerProps", function () {
|
|
38525
38439
|
var _this$props5 = _this.props,
|
|
38526
|
-
|
|
38527
|
-
|
|
38528
|
-
|
|
38440
|
+
showCommandsList = _this$props5.showCommandsList,
|
|
38441
|
+
showMentionsList = _this$props5.showMentionsList,
|
|
38442
|
+
trigger = _this$props5.trigger;
|
|
38529
38443
|
var _this$state6 = _this.state,
|
|
38530
|
-
|
|
38531
|
-
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38444
|
+
component = _this$state6.component,
|
|
38445
|
+
currentTrigger = _this$state6.currentTrigger,
|
|
38446
|
+
selectionEnd = _this$state6.selectionEnd,
|
|
38447
|
+
value = _this$state6.value;
|
|
38535
38448
|
var selectedItem = _this._getItemOnSelect();
|
|
38536
|
-
|
|
38537
38449
|
var suggestionData = _this._getSuggestions();
|
|
38538
|
-
|
|
38539
38450
|
var textToReplace = _this._getTextToReplace();
|
|
38540
|
-
|
|
38541
38451
|
var triggerProps = {
|
|
38542
38452
|
component: component,
|
|
38543
38453
|
currentTrigger: currentTrigger,
|
|
@@ -38547,7 +38457,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38547
38457
|
value: value,
|
|
38548
38458
|
values: suggestionData
|
|
38549
38459
|
};
|
|
38550
|
-
|
|
38551
38460
|
if (showCommandsList && trigger['/'] || showMentionsList && trigger['@']) {
|
|
38552
38461
|
var currentCommands;
|
|
38553
38462
|
var getCommands = trigger[showCommandsList ? '/' : '@'].dataProvider;
|
|
@@ -38562,28 +38471,25 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38562
38471
|
triggerProps.value = showCommandsList ? '/' : '@';
|
|
38563
38472
|
triggerProps.values = currentCommands;
|
|
38564
38473
|
}
|
|
38565
|
-
|
|
38566
38474
|
return triggerProps;
|
|
38567
38475
|
});
|
|
38568
|
-
|
|
38569
38476
|
definePropertyExports(assertThisInitializedExports(_this), "setDropdownRef", function (element) {
|
|
38570
38477
|
_this.dropdownRef = element;
|
|
38571
38478
|
});
|
|
38572
|
-
|
|
38573
38479
|
var _this$props6 = _this.props,
|
|
38574
|
-
|
|
38575
|
-
|
|
38576
|
-
|
|
38480
|
+
loadingComponent = _this$props6.loadingComponent,
|
|
38481
|
+
_trigger = _this$props6.trigger,
|
|
38482
|
+
_value = _this$props6.value;
|
|
38483
|
+
|
|
38484
|
+
// TODO: it would be better to have the parent control state...
|
|
38577
38485
|
// if (value) this.state.value = value;
|
|
38578
38486
|
|
|
38579
38487
|
if (!loadingComponent) {
|
|
38580
38488
|
throw new Error('RTA: loadingComponent is not defined');
|
|
38581
38489
|
}
|
|
38582
|
-
|
|
38583
38490
|
if (!_trigger) {
|
|
38584
38491
|
throw new Error('RTA: trigger is not defined');
|
|
38585
38492
|
}
|
|
38586
|
-
|
|
38587
38493
|
_this.state = {
|
|
38588
38494
|
actualToken: '',
|
|
38589
38495
|
component: null,
|
|
@@ -38598,22 +38504,20 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38598
38504
|
};
|
|
38599
38505
|
return _this;
|
|
38600
38506
|
}
|
|
38601
|
-
|
|
38602
38507
|
createClassExports(ReactTextareaAutocomplete, [{
|
|
38603
38508
|
key: "renderSuggestionListContainer",
|
|
38604
38509
|
value: function renderSuggestionListContainer() {
|
|
38605
38510
|
var _this$props7 = this.props,
|
|
38606
|
-
|
|
38607
|
-
|
|
38608
|
-
|
|
38609
|
-
|
|
38610
|
-
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
|
|
38511
|
+
disableMentions = _this$props7.disableMentions,
|
|
38512
|
+
dropdownClassName = _this$props7.dropdownClassName,
|
|
38513
|
+
dropdownStyle = _this$props7.dropdownStyle,
|
|
38514
|
+
itemClassName = _this$props7.itemClassName,
|
|
38515
|
+
itemStyle = _this$props7.itemStyle,
|
|
38516
|
+
listClassName = _this$props7.listClassName,
|
|
38517
|
+
SuggestionItem = _this$props7.SuggestionItem,
|
|
38518
|
+
_this$props7$Suggesti = _this$props7.SuggestionList,
|
|
38519
|
+
SuggestionList = _this$props7$Suggesti === void 0 ? List$1 : _this$props7$Suggesti;
|
|
38615
38520
|
var triggerProps = this.getTriggerProps();
|
|
38616
|
-
|
|
38617
38521
|
if (triggerProps.values && triggerProps.currentTrigger && !(disableMentions && triggerProps.currentTrigger === '@')) {
|
|
38618
38522
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
38619
38523
|
className: clsx('rta__autocomplete', 'str-chat__suggestion-list-container', dropdownClassName),
|
|
@@ -38628,24 +38532,24 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38628
38532
|
SuggestionItem: SuggestionItem
|
|
38629
38533
|
}, triggerProps)));
|
|
38630
38534
|
}
|
|
38631
|
-
|
|
38632
38535
|
return null;
|
|
38633
38536
|
}
|
|
38634
38537
|
}, {
|
|
38635
38538
|
key: "render",
|
|
38636
38539
|
value: function render() {
|
|
38637
38540
|
var _this2 = this;
|
|
38638
|
-
|
|
38639
38541
|
var _this$props8 = this.props,
|
|
38640
|
-
|
|
38641
|
-
|
|
38642
|
-
|
|
38643
|
-
|
|
38542
|
+
className = _this$props8.className,
|
|
38543
|
+
containerClassName = _this$props8.containerClassName,
|
|
38544
|
+
containerStyle = _this$props8.containerStyle,
|
|
38545
|
+
style = _this$props8.style;
|
|
38644
38546
|
var maxRows = this.props.maxRows;
|
|
38645
38547
|
var _this$state7 = this.state,
|
|
38646
|
-
|
|
38647
|
-
|
|
38648
|
-
if (!this.props.grow) maxRows = 1;
|
|
38548
|
+
dataLoading = _this$state7.dataLoading,
|
|
38549
|
+
value = _this$state7.value;
|
|
38550
|
+
if (!this.props.grow) maxRows = 1;
|
|
38551
|
+
|
|
38552
|
+
// By setting defaultValue to undefined, avoid error:
|
|
38649
38553
|
// ForwardRef(TextareaAutosize) contains a textarea with both value and defaultValue props.
|
|
38650
38554
|
// Textarea elements must be either controlled or uncontrolled
|
|
38651
38555
|
|
|
@@ -38668,7 +38572,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38668
38572
|
onSelect: this._selectHandler,
|
|
38669
38573
|
ref: function ref(_ref) {
|
|
38670
38574
|
var _this2$props;
|
|
38671
|
-
|
|
38672
38575
|
(_this2$props = _this2.props) === null || _this2$props === void 0 ? void 0 : _this2$props.innerRef(_ref);
|
|
38673
38576
|
_this2.textareaRef = _ref;
|
|
38674
38577
|
},
|
|
@@ -38697,12 +38600,9 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38697
38600
|
/**
|
|
38698
38601
|
* Close autocomplete, also clean up trigger (to avoid slow promises)
|
|
38699
38602
|
*/
|
|
38700
|
-
|
|
38701
38603
|
}]);
|
|
38702
|
-
|
|
38703
38604
|
return ReactTextareaAutocomplete;
|
|
38704
38605
|
}(React__default["default"].Component);
|
|
38705
|
-
|
|
38706
38606
|
definePropertyExports(ReactTextareaAutocomplete, "defaultProps", {
|
|
38707
38607
|
closeOnClickOutside: true,
|
|
38708
38608
|
maxRows: 10,
|
|
@@ -38711,7 +38611,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
38711
38611
|
scrollToItem: true,
|
|
38712
38612
|
value: ''
|
|
38713
38613
|
});
|
|
38714
|
-
|
|
38715
38614
|
ReactTextareaAutocomplete.propTypes = {
|
|
38716
38615
|
className: propTypesExports.string,
|
|
38717
38616
|
closeOnClickOutside: propTypesExports.bool,
|
|
@@ -48456,7 +48355,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
48456
48355
|
|
|
48457
48356
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
48458
48357
|
|
|
48459
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.
|
|
48358
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.7.1';
|
|
48460
48359
|
|
|
48461
48360
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
|
|
48462
48361
|
var _b, _c;
|
|
@@ -49572,7 +49471,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
49572
49471
|
var lastReceivedId = React$2.useMemo(function () { return getLastReceived(enrichedMessages); }, [enrichedMessages]);
|
|
49573
49472
|
var elements = React$2.useMemo(function () {
|
|
49574
49473
|
return enrichedMessages.map(function (message) {
|
|
49575
|
-
var _a;
|
|
49576
49474
|
if (message.customType === CUSTOM_MESSAGE_TYPE.date &&
|
|
49577
49475
|
message.date &&
|
|
49578
49476
|
isDate(message.date)) {
|
|
@@ -49584,9 +49482,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
49584
49482
|
React__default["default"].createElement(HeaderComponent, null)));
|
|
49585
49483
|
}
|
|
49586
49484
|
if (message.type === 'system') {
|
|
49587
|
-
return (React__default["default"].createElement("li", { key:
|
|
49588
|
-
message.created_at ||
|
|
49589
|
-
'' },
|
|
49485
|
+
return (React__default["default"].createElement("li", { key: message.id || message.created_at },
|
|
49590
49486
|
React__default["default"].createElement(MessageSystem, { message: message })));
|
|
49591
49487
|
}
|
|
49592
49488
|
var groupStyles = messageGroupStyles[message.id] || '';
|
|
@@ -56452,6 +56348,46 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
56452
56348
|
|
|
56453
56349
|
var parseXml$1 = src;
|
|
56454
56350
|
|
|
56351
|
+
var dist$1 = {};
|
|
56352
|
+
|
|
56353
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};Object.defineProperty(dist$1, "__esModule", { value: true });
|
|
56354
|
+
var sanitizeUrl_1 = dist$1.sanitizeUrl = void 0;
|
|
56355
|
+
var invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
|
|
56356
|
+
var htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
|
|
56357
|
+
var ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
|
|
56358
|
+
var urlSchemeRegex = /^([^:]+):/gm;
|
|
56359
|
+
var relativeFirstCharacters = [".", "/"];
|
|
56360
|
+
function isRelativeUrlWithoutProtocol(url) {
|
|
56361
|
+
return relativeFirstCharacters.indexOf(url[0]) > -1;
|
|
56362
|
+
}
|
|
56363
|
+
// adapted from https://stackoverflow.com/a/29824550/2601552
|
|
56364
|
+
function decodeHtmlCharacters(str) {
|
|
56365
|
+
return str.replace(htmlEntitiesRegex, function (match, dec) {
|
|
56366
|
+
return String.fromCharCode(dec);
|
|
56367
|
+
});
|
|
56368
|
+
}
|
|
56369
|
+
function sanitizeUrl(url) {
|
|
56370
|
+
var sanitizedUrl = decodeHtmlCharacters(url || "")
|
|
56371
|
+
.replace(ctrlCharactersRegex, "")
|
|
56372
|
+
.trim();
|
|
56373
|
+
if (!sanitizedUrl) {
|
|
56374
|
+
return "about:blank";
|
|
56375
|
+
}
|
|
56376
|
+
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
56377
|
+
return sanitizedUrl;
|
|
56378
|
+
}
|
|
56379
|
+
var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
|
|
56380
|
+
if (!urlSchemeParseResults) {
|
|
56381
|
+
return sanitizedUrl;
|
|
56382
|
+
}
|
|
56383
|
+
var urlScheme = urlSchemeParseResults[0];
|
|
56384
|
+
if (invalidProtocolRegex.test(urlScheme)) {
|
|
56385
|
+
return "about:blank";
|
|
56386
|
+
}
|
|
56387
|
+
return sanitizedUrl;
|
|
56388
|
+
}
|
|
56389
|
+
sanitizeUrl_1 = dist$1.sanitizeUrl = sanitizeUrl;
|
|
56390
|
+
|
|
56455
56391
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
56456
56392
|
var immutable = extend$1;
|
|
56457
56393
|
|
|
@@ -78529,6 +78465,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
78529
78465
|
exports.MessageTimestamp = MessageTimestamp;
|
|
78530
78466
|
exports.Modal = Modal;
|
|
78531
78467
|
exports.ModalGallery = ModalGallery;
|
|
78468
|
+
exports.NullComponent = NullComponent;
|
|
78532
78469
|
exports.PinIcon = PinIcon;
|
|
78533
78470
|
exports.PinIndicator = PinIndicator;
|
|
78534
78471
|
exports.PlayButton = PlayButton;
|
|
@@ -78564,6 +78501,8 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
78564
78501
|
exports.TypingIndicator = TypingIndicator;
|
|
78565
78502
|
exports.TypingProvider = TypingProvider;
|
|
78566
78503
|
exports.UnMemoizedLoadMorePaginator = UnMemoizedLoadMorePaginator;
|
|
78504
|
+
exports.UnsupportedAttachment = UnsupportedAttachment;
|
|
78505
|
+
exports.UnsupportedAttachmentContainer = UnsupportedAttachmentContainer;
|
|
78567
78506
|
exports.UploadIcon = UploadIcon;
|
|
78568
78507
|
exports.UploadsPreview = UploadsPreview;
|
|
78569
78508
|
exports.UserItem = UserItem;
|