UNPKG

communication-react-19

Version:

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

64 lines 2.93 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { _useContainerHeight, _useContainerWidth } from "../../../../react-components/src"; import { useMemo, useRef } from 'react'; import { MODAL_PIP_DEFAULT_PX } from './styles/ModalLocalAndRemotePIP.styles'; /** * @private */ export const isBoolean = (value) => { return value !== null && typeof value === 'boolean'; }; /** * @private */ // Use document.getElementById until Fluent's Stack supports componentRef property: https://github.com/microsoft/fluentui/issues/20410 export const useMinMaxDragPosition = (modalLayerHostId, rtl) => { const modalHostRef = useRef(document.getElementById(modalLayerHostId)); const modalHostWidth = _useContainerWidth(modalHostRef); const modalHostHeight = _useContainerHeight(modalHostRef); const minDragPosition = useMemo(() => modalHostWidth === undefined || modalHostHeight === undefined ? undefined : { x: rtl ? -1 * MODAL_PIP_DEFAULT_PX.rightPositionPx : MODAL_PIP_DEFAULT_PX.rightPositionPx - modalHostWidth + MODAL_PIP_DEFAULT_PX.widthPx, y: -1 * modalHostHeight + MODAL_PIP_DEFAULT_PX.heightPx + MODAL_PIP_DEFAULT_PX.bottomPositionPx }, [modalHostHeight, modalHostWidth, rtl]); const maxDragPosition = useMemo(() => modalHostWidth === undefined ? undefined : { x: rtl ? modalHostWidth - MODAL_PIP_DEFAULT_PX.rightPositionPx - MODAL_PIP_DEFAULT_PX.widthPx : MODAL_PIP_DEFAULT_PX.rightPositionPx, y: MODAL_PIP_DEFAULT_PX.bottomPositionPx }, [modalHostWidth, rtl]); return { minDragPosition: minDragPosition, maxDragPosition: maxDragPosition }; }; /** * @private */ export const defaultSpokenLanguage = 'en-us'; /** * @private */ export const busyWait = (checkCondition, retryLimit) => __awaiter(void 0, void 0, void 0, function* () { const delayMs = 500; let retryCount = 0; while (!checkCondition()) { yield new Promise((resolve) => setTimeout(resolve, delayMs)); if (!retryLimit || (retryLimit && retryCount++ >= retryLimit)) { break; } } }); //# sourceMappingURL=utils.js.map