UNPKG

communication-react-19

Version:

React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)

57 lines 3.37 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React, { useMemo } from 'react'; import { useCallWithChatCompositeStrings } from '../../CallWithChatComposite/hooks/useCallWithChatCompositeStrings'; import { MoreDrawer } from './MoreDrawer'; import { moreDrawerSelector } from '../../CallWithChatComposite/selectors/moreDrawerSelector'; import { useSelector } from '../../CallComposite/hooks/useSelector'; import { useHandlers } from '../../CallComposite/hooks/useHandlers'; import { useLocale } from '../../localization'; /** @private */ export const PreparedMoreDrawer = (props) => { var _a; const strings = useCallWithChatCompositeStrings(); const moreDrawerStrings = useMemo(() => ({ peopleButtonLabel: strings.peopleButtonLabel, audioDeviceMenuTitle: strings.moreDrawerAudioDeviceMenuTitle, microphoneMenuTitle: strings.moreDrawerMicrophoneMenuTitle, speakerMenuTitle: strings.moreDrawerSpeakerMenuTitle, captionsMenuTitle: strings.moreDrawerCaptionsMenuTitle, spokenLanguageMenuTitle: strings.moreDrawerSpokenLanguageMenuTitle, captionLanguageMenuTitle: strings.moreDrawerCaptionLanguageMenuTitle, galleryOptionsMenuTitle: strings.moreDrawerGalleryOptionsMenuTitle }), [strings]); const _b = useSelector(moreDrawerSelector), { microphones, selectedMicrophone } = _b, deviceProps = __rest(_b, ["microphones", "selectedMicrophone"]); const callHandlers = useHandlers(MoreDrawer); const defaultMicrophoneLabelFallback = (_a = useLocale().component.strings.devicesButton.defaultMicrophoneLabelFallback) !== null && _a !== void 0 ? _a : 'Default'; const adjustedMicrophones = useMemo(() => { return microphones === null || microphones === void 0 ? void 0 : microphones.map((microphone, i) => ({ id: microphone.id, name: i === 0 && !microphone.name ? defaultMicrophoneLabelFallback : microphone.name })); }, [defaultMicrophoneLabelFallback, microphones]); const adjustedSelectedMicrophone = useMemo(() => { var _a; if (!selectedMicrophone) { return undefined; } const selectedMicIsDefault = selectedMicrophone.id === ((_a = microphones === null || microphones === void 0 ? void 0 : microphones[0]) === null || _a === void 0 ? void 0 : _a.id); return { id: selectedMicrophone.id, name: selectedMicIsDefault && !selectedMicrophone.name ? defaultMicrophoneLabelFallback : selectedMicrophone.name }; }, [defaultMicrophoneLabelFallback, selectedMicrophone]); return (React.createElement(MoreDrawer, Object.assign({}, props, deviceProps, callHandlers, { strings: moreDrawerStrings, microphones: adjustedMicrophones, selectedMicrophone: adjustedSelectedMicrophone }))); }; //# sourceMappingURL=PreparedMoreDrawer.js.map