@azure/communication-react
Version:
React library for building modern communication user experiences utilizing Azure Communication Services
27 lines • 1.58 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ScreenShareButton } from "../../../../../../react-components/src";
import React, { useMemo } from 'react';
import { usePropsFor } from '../../hooks/usePropsFor';
import { concatButtonBaseStyles } from '../../styles/Buttons.styles';
import { getIsRoomsCall, getRole } from '../../selectors/baseSelectors';
import { useSelector } from '../../hooks/useSelector';
/** @private */
export const ScreenShare = (props) => {
const screenShareButtonProps = usePropsFor(ScreenShareButton);
const styles = useMemo(() => { var _a; return concatButtonBaseStyles((_a = props.styles) !== null && _a !== void 0 ? _a : {}); }, [props.styles]);
const isRoomsCall = useSelector(getIsRoomsCall);
const role = useSelector(getRole);
const screenShareButtonDisabled = () => {
var _a;
return (_a = screenShareButtonProps === null || screenShareButtonProps === void 0 ? void 0 : screenShareButtonProps.disabled) !== null && _a !== void 0 ? _a : isDisabled(props.option);
};
return React.createElement(ScreenShareButton, Object.assign({ "data-ui-id": "call-composite-screenshare-button" }, screenShareButtonProps, { showLabel: props.displayType !== 'compact', disabled: screenShareButtonDisabled() || props.disabled || !!(isRoomsCall && role === 'Unknown'), styles: styles }));
};
const isDisabled = (option) => {
if (option === undefined || option === true || option === false) {
return false;
}
return option.disabled;
};
//# sourceMappingURL=ScreenShare.js.map