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

63 lines
2.8 KiB
JavaScript

define(["require", "exports", "@fluentui/react-window-provider"], function (require, exports, react_window_provider_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWindowEx = exports.getDocumentEx = exports.useWindowEx = exports.useDocumentEx = void 0;
/**
* 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
*/
var useDocumentEx = function () {
var _a;
// eslint-disable-next-line no-restricted-globals
return (_a = (0, react_window_provider_1.useDocument)()) !== null && _a !== void 0 ? _a : (typeof document !== 'undefined' ? document : undefined);
};
exports.useDocumentEx = useDocumentEx;
/**
* Get a reference to the `window` object.
* Use this in place of the global `window` in React function components.
* @returns Window | undefined
*/
var useWindowEx = function () {
var _a;
// eslint-disable-next-line no-restricted-globals
return (_a = (0, react_window_provider_1.useWindow)()) !== null && _a !== void 0 ? _a : (typeof window !== 'undefined' ? window : undefined);
};
exports.useWindowEx = useWindowEx;
/**
* 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
*/
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);
};
exports.getDocumentEx = getDocumentEx;
/**
* 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
*/
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);
};
exports.getWindowEx = getWindowEx;
});
//# sourceMappingURL=dom.js.map