@sendbird/uikit-react
Version:
Sendbird UIKit for React: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.
67 lines (63 loc) • 4.15 kB
JavaScript
import React__default, { useRef, useState, useContext } from 'react';
import { u as useLocalization, L as LocalizationContext } from '../../chunks/bundle-Del33VzI.js';
import { C as ContextMenu, b as MenuItems, c as MenuItem } from '../../chunks/bundle-Bch_Ry4S.js';
import IconButton from '../../ui/IconButton.js';
import Icon, { IconTypes, IconColors } from '../../ui/Icon.js';
import { M as Modal } from '../../chunks/bundle-CtQtfJlT.js';
import { u as useSendbird } from '../../chunks/bundle-i_3w58Zd.js';
import '../../chunks/bundle-yl5d1NoZ.js';
import '../../chunks/bundle-C1dqPUnT.js';
import '../../chunks/bundle-BZGITC2g.js';
import 'react-dom';
import '../../chunks/bundle-MlG9piGf.js';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-DGh2T5IL.js';
import '../../chunks/bundle-viBng0Kh.js';
import '../../chunks/bundle-vmZ9LoYK.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-DgosLQK9.js';
import '../../chunks/bundle-DEuCwnTn.js';
import '../../chunks/bundle-fdEQfX2s.js';
import '../../chunks/bundle-CqLLOVG5.js';
import '../../chunks/bundle-BUYU9H94.js';
import '../../chunks/bundle-DBhJIxHw.js';
import '../../ui/Button.js';
var LeaveGroupChannel = function (_a) {
var channel = _a.channel, onSubmit = _a.onSubmit, onCancel = _a.onCancel;
var _b = useSendbird().state.config, logger = _b.logger, isOnline = _b.isOnline;
var stringSet = useLocalization().stringSet;
if (channel) {
return (React__default.createElement(Modal, { disabled: !isOnline, onCancel: onCancel, onSubmit: function () {
logger.info('LeaveGroupChannel: Leaving channel', channel);
channel.leave().then(function () {
logger.info('LeaveGroupChannel: Leaving channel successful!', channel);
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
});
}, submitText: stringSet.MODAL__LEAVE_CHANNEL__FOOTER, titleText: stringSet.MODAL__LEAVE_CHANNEL__TITLE }));
}
};
function GroupChannelPreviewAction(_a) {
var channel = _a.channel, _b = _a.disabled, disabled = _b === void 0 ? false : _b, onLeaveChannel = _a.onLeaveChannel;
var parentRef = useRef(null);
var parentContainerRef = useRef(null);
var _c = useState(false), showModal = _c[0], setShowModal = _c[1];
var stringSet = useContext(LocalizationContext).stringSet;
return (React__default.createElement("div", { ref: parentContainerRef, tabIndex: 0, role: "button", style: { display: 'inline-block' }, onKeyDown: function (e) { return e.stopPropagation(); }, onClick: function (e) { return e.stopPropagation(); } },
React__default.createElement(ContextMenu, { menuTrigger: function (toggleDropdown) { return (React__default.createElement(IconButton, { ref: parentRef, onClick: toggleDropdown, height: "32px", width: "32px" },
React__default.createElement(Icon, { type: IconTypes.MORE, fillColor: IconColors.PRIMARY, width: "24px", height: "24px" }))); }, menuItems: function (closeDropdown) { return (React__default.createElement(MenuItems, { parentRef: parentRef, parentContainRef: parentContainerRef, closeDropdown: closeDropdown },
React__default.createElement(MenuItem, { onClick: function () {
if (disabled)
return;
setShowModal(true);
closeDropdown();
}, testID: "channel_list_item_context_menu_leave_channel" }, stringSet.CHANNEL_SETTING__LEAVE_CHANNEL__TITLE))); } }),
showModal && (React__default.createElement(LeaveGroupChannel, { channel: channel, onSubmit: function () {
setShowModal(false);
onLeaveChannel === null || onLeaveChannel === void 0 ? void 0 : onLeaveChannel();
}, onCancel: function () { return setShowModal(false); } }))));
}
export { GroupChannelPreviewAction, GroupChannelPreviewAction as default };
//# sourceMappingURL=GroupChannelPreviewAction.js.map