Outlook_Addin_LLM/node_modules/@fluentui/react/lib/utilities/dom.js

55 lines
2.2 KiB
JavaScript

import { useDocument, useWindow } from '@fluentui/react-window-provider';
/**
* NOTE: the check for `window`/`document` is a bit verbose and perhaps
* overkill but it ensures the prior assumbed behavior of directly
* calling `window`/`document` is preserved.
*
* It is possible to set `window` to undefined on `WindowProvider` so
* we'll fallback to directly accessing the global in that (hopefully unlikely)
* case.
*/
/**
* Get a reference to the `document` object.
* Use this in place of the global `document` in React function components.
* @returns Document | undefined
*/
export var useDocumentEx = function () {
var _a;
// eslint-disable-next-line no-restricted-globals
return (_a = useDocument()) !== null && _a !== void 0 ? _a : (typeof document !== 'undefined' ? document : undefined);
};
/**
* Get a reference to the `window` object.
* Use this in place of the global `window` in React function components.
* @returns Window | undefined
*/
export var useWindowEx = function () {
var _a;
// eslint-disable-next-line no-restricted-globals
return (_a = useWindow()) !== null && _a !== void 0 ? _a : (typeof window !== 'undefined' ? window : undefined);
};
/**
* Get a reference to the `document` object.
* Use this in place of the global `document` in React class components.
*
* @param ctx - Class component WindowContext
* @returns Document | undefined
*/
export var getDocumentEx = function (ctx) {
var _a, _b;
// eslint-disable-next-line no-restricted-globals
return (_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.window) === null || _a === void 0 ? void 0 : _a.document) !== null && _b !== void 0 ? _b : (typeof document !== 'undefined' ? document : undefined);
};
/**
* Get a reference to the `window` object.
* Use this in place of the global `window` in React class components.
*
* @param ctx - Class component WindowContext
* @returns Window | undefined
*/
export var getWindowEx = function (ctx) {
var _a;
// eslint-disable-next-line no-restricted-globals
return (_a = ctx === null || ctx === void 0 ? void 0 : ctx.window) !== null && _a !== void 0 ? _a : (typeof window !== 'undefined' ? window : undefined);
};
//# sourceMappingURL=dom.js.map