first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
export type { IVirtualElement } from '@fluentui/dom-utilities';
+5
View File
@@ -0,0 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});
//# sourceMappingURL=IVirtualElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IVirtualElement.js","sourceRoot":"../src/","sources":["dom/IVirtualElement.ts"],"names":[],"mappings":"","sourcesContent":["export type { IVirtualElement } from '@fluentui/dom-utilities';\n"]}
+4
View File
@@ -0,0 +1,4 @@
/**
* Verifies if an application can use DOM.
*/
export declare function canUseDOM(): boolean;
+17
View File
@@ -0,0 +1,17 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.canUseDOM = canUseDOM;
/**
* Verifies if an application can use DOM.
*/
function canUseDOM() {
return (
// eslint-disable-next-line no-restricted-globals
typeof window !== 'undefined' &&
!!(
// eslint-disable-next-line no-restricted-globals, @typescript-eslint/no-deprecated
(window.document && window.document.createElement)));
}
});
//# sourceMappingURL=canUseDOM.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"canUseDOM.js","sourceRoot":"../src/","sources":["dom/canUseDOM.ts"],"names":[],"mappings":";;;IAGA,8BASC;IAZD;;OAEG;IACH,SAAgB,SAAS;QACvB,OAAO;QACL,iDAAiD;QACjD,OAAO,MAAM,KAAK,WAAW;YAC7B,CAAC,CAAC;YACA,mFAAmF;YACnF,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CACnD,CACF,CAAC;IACJ,CAAC","sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n // eslint-disable-next-line no-restricted-globals\n typeof window !== 'undefined' &&\n !!(\n // eslint-disable-next-line no-restricted-globals, @typescript-eslint/no-deprecated\n (window.document && window.document.createElement)\n )\n );\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export {};
+96
View File
@@ -0,0 +1,96 @@
define(["require", "exports", "./portalContainsElement", "./setPortalAttribute", "./elementContains", "./getParent"], function (require, exports, portalContainsElement_1, setPortalAttribute_1, elementContains_1, getParent_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var unattachedSvg = document.createElement('svg');
var unattachedDiv = document.createElement('div');
var parentDiv = document.createElement('div');
var childDiv = document.createElement('div');
parentDiv.appendChild(childDiv);
describe('elementContains', function () {
it('can find a child', function () {
expect((0, elementContains_1.elementContains)(parentDiv, childDiv)).toEqual(true);
});
it('can return false on an unattached child', function () {
expect((0, elementContains_1.elementContains)(parentDiv, unattachedDiv)).toEqual(false);
});
it('can return false on a null child', function () {
expect((0, elementContains_1.elementContains)(parentDiv, null)).toEqual(false);
});
it('can return false on a null parent', function () {
expect((0, elementContains_1.elementContains)(null, null)).toEqual(false);
});
it('can return false when parent is an svg', function () {
expect((0, elementContains_1.elementContains)(unattachedSvg, unattachedDiv)).toEqual(false);
});
});
describe('getParent', function () {
it('returns correct parent for inner SVG elements', function () {
var childSvg = document.createElement('svg');
var svgRectangle = document.createElement('rect');
childSvg.appendChild(svgRectangle);
parentDiv.appendChild(childSvg);
expect((0, getParent_1.getParent)(svgRectangle)).toEqual(childSvg);
expect((0, getParent_1.getParent)(childSvg)).toEqual(parentDiv);
});
});
describe('setPortalAttribute', function () {
it('sets attribute', function () {
var testDiv = document.createElement('div');
expect(testDiv.getAttribute(setPortalAttribute_1.DATA_PORTAL_ATTRIBUTE)).toBeFalsy();
(0, setPortalAttribute_1.setPortalAttribute)(testDiv);
expect(testDiv.getAttribute(setPortalAttribute_1.DATA_PORTAL_ATTRIBUTE)).toBeTruthy();
});
});
describe('portalContainsElement', function () {
var root;
var leaf;
var parent;
var portal;
var unlinked;
beforeEach(function () {
root = document.createElement('div');
leaf = document.createElement('div');
parent = document.createElement('div');
portal = document.createElement('div');
unlinked = document.createElement('div');
(0, setPortalAttribute_1.setPortalAttribute)(portal);
});
it('works with and without parent specified', function () {
root.appendChild(parent);
parent.appendChild(portal);
portal.appendChild(leaf);
expect((0, portalContainsElement_1.portalContainsElement)(root)).toBeFalsy();
expect((0, portalContainsElement_1.portalContainsElement)(parent)).toBeFalsy();
expect((0, portalContainsElement_1.portalContainsElement)(portal)).toBeTruthy();
expect((0, portalContainsElement_1.portalContainsElement)(leaf)).toBeTruthy();
expect((0, portalContainsElement_1.portalContainsElement)(leaf, parent)).toBeTruthy();
});
it('works correctly when parent and child are in same portal', function () {
root.appendChild(portal);
portal.appendChild(parent);
parent.appendChild(leaf);
expect((0, portalContainsElement_1.portalContainsElement)(parent)).toBeTruthy();
expect((0, portalContainsElement_1.portalContainsElement)(leaf, parent)).toBeFalsy();
});
it('works with hierarchically invalid parents', function () {
root.appendChild(parent);
parent.appendChild(portal);
portal.appendChild(leaf);
// When parent is invalid, searches should go to root
expect((0, portalContainsElement_1.portalContainsElement)(root, leaf)).toBeFalsy();
expect((0, portalContainsElement_1.portalContainsElement)(parent, leaf)).toBeFalsy();
expect((0, portalContainsElement_1.portalContainsElement)(portal, leaf)).toBeTruthy();
expect((0, portalContainsElement_1.portalContainsElement)(leaf, unlinked)).toBeTruthy();
});
it('works when element is parent', function () {
root.appendChild(parent);
parent.appendChild(portal);
portal.appendChild(leaf);
expect((0, portalContainsElement_1.portalContainsElement)(root, root)).toBeFalsy();
expect((0, portalContainsElement_1.portalContainsElement)(parent, parent)).toBeFalsy();
expect((0, portalContainsElement_1.portalContainsElement)(portal, portal)).toBeTruthy();
expect((0, portalContainsElement_1.portalContainsElement)(leaf, leaf)).toBeFalsy();
});
});
});
//# sourceMappingURL=dom.test.js.map
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
export { elementContains } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContains = void 0;
Object.defineProperty(exports, "elementContains", { enumerable: true, get: function () { return dom_utilities_1.elementContains; } });
});
//# sourceMappingURL=elementContains.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"elementContains.js","sourceRoot":"../src/","sources":["dom/elementContains.ts"],"names":[],"mappings":";;;;IAAS,gHAAA,eAAe,OAAA","sourcesContent":["export { elementContains } from '@fluentui/dom-utilities';\n"]}
@@ -0,0 +1 @@
export { elementContainsAttribute } from '@fluentui/dom-utilities';
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContainsAttribute = void 0;
Object.defineProperty(exports, "elementContainsAttribute", { enumerable: true, get: function () { return dom_utilities_1.elementContainsAttribute; } });
});
//# sourceMappingURL=elementContainsAttribute.js.map
@@ -0,0 +1 @@
{"version":3,"file":"elementContainsAttribute.js","sourceRoot":"../src/","sources":["dom/elementContainsAttribute.ts"],"names":[],"mappings":";;;;IAAS,yHAAA,wBAAwB,OAAA","sourcesContent":["export { elementContainsAttribute } from '@fluentui/dom-utilities';\n"]}
@@ -0,0 +1 @@
export { findElementRecursive } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findElementRecursive = void 0;
Object.defineProperty(exports, "findElementRecursive", { enumerable: true, get: function () { return dom_utilities_1.findElementRecursive; } });
});
//# sourceMappingURL=findElementRecursive.js.map
@@ -0,0 +1 @@
{"version":3,"file":"findElementRecursive.js","sourceRoot":"../src/","sources":["dom/findElementRecursive.ts"],"names":[],"mappings":";;;;IAAS,qHAAA,oBAAoB,OAAA","sourcesContent":["export { findElementRecursive } from '@fluentui/dom-utilities';\n"]}
+1
View File
@@ -0,0 +1 @@
export { getActiveElement } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveElement = void 0;
Object.defineProperty(exports, "getActiveElement", { enumerable: true, get: function () { return dom_utilities_1.getActiveElement; } });
});
//# sourceMappingURL=getActiveElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getActiveElement.js","sourceRoot":"../src/","sources":["dom/getActiveElement.ts"],"names":[],"mappings":";;;;IAAS,iHAAA,gBAAgB,OAAA","sourcesContent":["export { getActiveElement } from '@fluentui/dom-utilities';\n"]}
+1
View File
@@ -0,0 +1 @@
export { getChildren } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildren = void 0;
Object.defineProperty(exports, "getChildren", { enumerable: true, get: function () { return dom_utilities_1.getChildren; } });
});
//# sourceMappingURL=getChildren.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getChildren.js","sourceRoot":"../src/","sources":["dom/getChildren.ts"],"names":[],"mappings":";;;;IAAS,4GAAA,WAAW,OAAA","sourcesContent":["export { getChildren } from '@fluentui/dom-utilities';\n"]}
+8
View File
@@ -0,0 +1,8 @@
/**
* Helper to get the document object. Note that in popup window cases, document
* might be the wrong document, which is why we look at ownerDocument for the
* truth.
*
* @public
*/
export declare function getDocument(rootElement?: HTMLElement | null): Document | undefined;
+24
View File
@@ -0,0 +1,24 @@
define(["require", "exports", "./canUseDOM"], function (require, exports, canUseDOM_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDocument = getDocument;
/**
* Helper to get the document object. Note that in popup window cases, document
* might be the wrong document, which is why we look at ownerDocument for the
* truth.
*
* @public
*/
function getDocument(rootElement) {
// eslint-disable-next-line no-restricted-globals
if (!(0, canUseDOM_1.canUseDOM)() || typeof document === 'undefined') {
return undefined;
}
else {
var el = rootElement;
// eslint-disable-next-line no-restricted-globals
return el && el.ownerDocument ? el.ownerDocument : document;
}
}
});
//# sourceMappingURL=getDocument.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getDocument.js","sourceRoot":"../src/","sources":["dom/getDocument.ts"],"names":[],"mappings":";;;IASA,kCAUC;IAjBD;;;;;;OAMG;IACH,SAAgB,WAAW,CAAC,WAAgC;QAC1D,iDAAiD;QACjD,IAAI,CAAC,IAAA,qBAAS,GAAE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpD,OAAO,SAAS,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAM,EAAE,GAAG,WAAsB,CAAC;YAElC,iDAAiD;YACjD,OAAO,EAAE,IAAI,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9D,CAAC;IACH,CAAC","sourcesContent":["import { canUseDOM } from './canUseDOM';\n\n/**\n * Helper to get the document object. Note that in popup window cases, document\n * might be the wrong document, which is why we look at ownerDocument for the\n * truth.\n *\n * @public\n */\nexport function getDocument(rootElement?: HTMLElement | null): Document | undefined {\n // eslint-disable-next-line no-restricted-globals\n if (!canUseDOM() || typeof document === 'undefined') {\n return undefined;\n } else {\n const el = rootElement as Element;\n\n // eslint-disable-next-line no-restricted-globals\n return el && el.ownerDocument ? el.ownerDocument : document;\n }\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export { getEventTarget } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEventTarget = void 0;
Object.defineProperty(exports, "getEventTarget", { enumerable: true, get: function () { return dom_utilities_1.getEventTarget; } });
});
//# sourceMappingURL=getEventTarget.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getEventTarget.js","sourceRoot":"../src/","sources":["dom/getEventTarget.ts"],"names":[],"mappings":";;;;IAAS,+GAAA,cAAc,OAAA","sourcesContent":["export { getEventTarget } from '@fluentui/dom-utilities';\n"]}
@@ -0,0 +1,8 @@
/**
* Gets the first visible element that matches the given selector
* @param selector - The selector to use to find potential visible elements
* @returns The first visible element that matches the selector, otherwise undefined
*
* @public
*/
export declare function getFirstVisibleElementFromSelector(selector: string): Element | undefined;
@@ -0,0 +1,19 @@
define(["require", "exports", "../focus", "./getDocument"], function (require, exports, focus_1, getDocument_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFirstVisibleElementFromSelector = getFirstVisibleElementFromSelector;
/**
* Gets the first visible element that matches the given selector
* @param selector - The selector to use to find potential visible elements
* @returns The first visible element that matches the selector, otherwise undefined
*
* @public
*/
function getFirstVisibleElementFromSelector(selector) {
var doc = (0, getDocument_1.getDocument)();
var elements = doc.querySelectorAll(selector);
// Iterate across the elements that match the selector and return the first visible/non-hidden element
return Array.from(elements).find(function (element) { var _a; return (0, focus_1.isElementVisibleAndNotHidden)(element, (_a = doc.defaultView) !== null && _a !== void 0 ? _a : undefined); });
}
});
//# sourceMappingURL=getFirstVisibleElementFromSelector.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getFirstVisibleElementFromSelector.js","sourceRoot":"../src/","sources":["dom/getFirstVisibleElementFromSelector.ts"],"names":[],"mappings":";;;IAUA,gFAQC;IAfD;;;;;;OAMG;IACH,SAAgB,kCAAkC,CAAC,QAAgB;QACjE,IAAM,GAAG,GAAG,IAAA,yBAAW,GAAG,CAAC;QAC3B,IAAM,QAAQ,GAAG,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAEhD,sGAAsG;QACtG,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAC,OAAoB,YACpD,OAAA,IAAA,oCAA4B,EAAC,OAAO,EAAE,MAAA,GAAG,CAAC,WAAW,mCAAI,SAAS,CAAC,CAAA,EAAA,CACpE,CAAC;IACJ,CAAC","sourcesContent":["import { isElementVisibleAndNotHidden } from '../focus';\nimport { getDocument } from './getDocument';\n\n/**\n * Gets the first visible element that matches the given selector\n * @param selector - The selector to use to find potential visible elements\n * @returns The first visible element that matches the selector, otherwise undefined\n *\n * @public\n */\nexport function getFirstVisibleElementFromSelector(selector: string): Element | undefined {\n const doc = getDocument()!;\n const elements = doc.querySelectorAll(selector);\n\n // Iterate across the elements that match the selector and return the first visible/non-hidden element\n return Array.from(elements).find((element: HTMLElement) =>\n isElementVisibleAndNotHidden(element, doc.defaultView ?? undefined),\n );\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export { getParent } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParent = void 0;
Object.defineProperty(exports, "getParent", { enumerable: true, get: function () { return dom_utilities_1.getParent; } });
});
//# sourceMappingURL=getParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getParent.js","sourceRoot":"../src/","sources":["dom/getParent.ts"],"names":[],"mappings":";;;;IAAS,0GAAA,SAAS,OAAA","sourcesContent":["export { getParent } from '@fluentui/dom-utilities';\n"]}
+7
View File
@@ -0,0 +1,7 @@
import type { IRectangle } from '../IRectangle';
/**
* Helper to get bounding client rect. Passing in window will get the window size.
*
* @public
*/
export declare function getRect(element: HTMLElement | Window | null, win?: Window): IRectangle | undefined;
+33
View File
@@ -0,0 +1,33 @@
define(["require", "exports", "./getWindow"], function (require, exports, getWindow_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRect = getRect;
/**
* Helper to get bounding client rect. Passing in window will get the window size.
*
* @public
*/
function getRect(element, win) {
var theWin = (win !== null && win !== void 0 ? win : (!element || (element && element.hasOwnProperty('devicePixelRatio'))))
? (0, getWindow_1.getWindow)()
: (0, getWindow_1.getWindow)(element);
var rect;
if (element) {
if (element === theWin) {
rect = {
left: 0,
top: 0,
width: theWin.innerWidth,
height: theWin.innerHeight,
right: theWin.innerWidth,
bottom: theWin.innerHeight,
};
}
else if (element.getBoundingClientRect) {
rect = element.getBoundingClientRect();
}
}
return rect;
}
});
//# sourceMappingURL=getRect.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getRect.js","sourceRoot":"../src/","sources":["dom/getRect.ts"],"names":[],"mappings":";;;IAQA,0BAqBC;IA1BD;;;;OAIG;IACH,SAAgB,OAAO,CAAC,OAAoC,EAAE,GAAY;QACxE,IAAM,MAAM,GACV,CAAA,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC,IAAA,qBAAS,GAAE;YACb,CAAC,CAAC,IAAA,qBAAS,EAAC,OAAsB,CAAE,CAAC;QACzC,IAAI,IAA4B,CAAC;QACjC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBACvB,IAAI,GAAG;oBACL,IAAI,EAAE,CAAC;oBACP,GAAG,EAAE,CAAC;oBACN,KAAK,EAAE,MAAM,CAAC,UAAU;oBACxB,MAAM,EAAE,MAAM,CAAC,WAAW;oBAC1B,KAAK,EAAE,MAAM,CAAC,UAAU;oBACxB,MAAM,EAAE,MAAM,CAAC,WAAW;iBAC3B,CAAC;YACJ,CAAC;iBAAM,IAAK,OAA+C,CAAC,qBAAqB,EAAE,CAAC;gBAClF,IAAI,GAAI,OAAuB,CAAC,qBAAqB,EAAE,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC","sourcesContent":["import type { IRectangle } from '../IRectangle';\nimport { getWindow } from './getWindow';\n\n/**\n * Helper to get bounding client rect. Passing in window will get the window size.\n *\n * @public\n */\nexport function getRect(element: HTMLElement | Window | null, win?: Window): IRectangle | undefined {\n const theWin =\n win ?? (!element || (element && element.hasOwnProperty('devicePixelRatio')))\n ? getWindow()\n : getWindow(element as HTMLElement)!;\n let rect: IRectangle | undefined;\n if (element) {\n if (element === theWin) {\n rect = {\n left: 0,\n top: 0,\n width: theWin.innerWidth,\n height: theWin.innerHeight,\n right: theWin.innerWidth,\n bottom: theWin.innerHeight,\n };\n } else if ((element as { getBoundingClientRect?: unknown }).getBoundingClientRect) {\n rect = (element as HTMLElement).getBoundingClientRect();\n }\n }\n return rect;\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export { getVirtualParent } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVirtualParent = void 0;
Object.defineProperty(exports, "getVirtualParent", { enumerable: true, get: function () { return dom_utilities_1.getVirtualParent; } });
});
//# sourceMappingURL=getVirtualParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getVirtualParent.js","sourceRoot":"../src/","sources":["dom/getVirtualParent.ts"],"names":[],"mappings":";;;;IAAS,iHAAA,gBAAgB,OAAA","sourcesContent":["export { getVirtualParent } from '@fluentui/dom-utilities';\n"]}
+9
View File
@@ -0,0 +1,9 @@
/**
* Helper to get the window object. The helper will make sure to use a cached variable
* of "window", to avoid overhead and memory leaks in IE11. Note that in popup scenarios the
* window object won't match the "global" window object, and for these scenarios, you should
* pass in an element hosted within the popup.
*
* @public
*/
export declare function getWindow(rootElement?: Element | null): Window | undefined;
+34
View File
@@ -0,0 +1,34 @@
define(["require", "exports", "./canUseDOM"], function (require, exports, canUseDOM_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWindow = getWindow;
var _window = undefined;
// Note: Accessing "window" in IE11 is somewhat expensive, and calling "typeof window"
// hits a memory leak, whereas aliasing it and calling "typeof _window" does not.
// Caching the window value at the file scope lets us minimize the impact.
try {
// eslint-disable-next-line no-restricted-globals
_window = window;
}
catch (e) {
/* no-op */
}
/**
* Helper to get the window object. The helper will make sure to use a cached variable
* of "window", to avoid overhead and memory leaks in IE11. Note that in popup scenarios the
* window object won't match the "global" window object, and for these scenarios, you should
* pass in an element hosted within the popup.
*
* @public
*/
function getWindow(rootElement) {
if (!(0, canUseDOM_1.canUseDOM)() || typeof _window === 'undefined') {
return undefined;
}
else {
var el = rootElement;
return el && el.ownerDocument && el.ownerDocument.defaultView ? el.ownerDocument.defaultView : _window;
}
}
});
//# sourceMappingURL=getWindow.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getWindow.js","sourceRoot":"../src/","sources":["dom/getWindow.ts"],"names":[],"mappings":";;;IAsBA,8BAQC;IA5BD,IAAI,OAAO,GAAuB,SAAS,CAAC;IAE5C,sFAAsF;IACtF,iFAAiF;IACjF,0EAA0E;IAC1E,IAAI,CAAC;QACH,iDAAiD;QACjD,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,WAAW;IACb,CAAC;IAED;;;;;;;OAOG;IACH,SAAgB,SAAS,CAAC,WAA4B;QACpD,IAAI,CAAC,IAAA,qBAAS,GAAE,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACnD,OAAO,SAAS,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAM,EAAE,GAAG,WAAsB,CAAC;YAElC,OAAO,EAAE,IAAI,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;QACzG,CAAC;IACH,CAAC","sourcesContent":["import { canUseDOM } from './canUseDOM';\n\nlet _window: Window | undefined = undefined;\n\n// Note: Accessing \"window\" in IE11 is somewhat expensive, and calling \"typeof window\"\n// hits a memory leak, whereas aliasing it and calling \"typeof _window\" does not.\n// Caching the window value at the file scope lets us minimize the impact.\ntry {\n // eslint-disable-next-line no-restricted-globals\n _window = window;\n} catch (e) {\n /* no-op */\n}\n\n/**\n * Helper to get the window object. The helper will make sure to use a cached variable\n * of \"window\", to avoid overhead and memory leaks in IE11. Note that in popup scenarios the\n * window object won't match the \"global\" window object, and for these scenarios, you should\n * pass in an element hosted within the popup.\n *\n * @public\n */\nexport function getWindow(rootElement?: Element | null): Window | undefined {\n if (!canUseDOM() || typeof _window === 'undefined') {\n return undefined;\n } else {\n const el = rootElement as Element;\n\n return el && el.ownerDocument && el.ownerDocument.defaultView ? el.ownerDocument.defaultView : _window;\n }\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export { isVirtualElement } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isVirtualElement = void 0;
Object.defineProperty(exports, "isVirtualElement", { enumerable: true, get: function () { return dom_utilities_1.isVirtualElement; } });
});
//# sourceMappingURL=isVirtualElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"isVirtualElement.js","sourceRoot":"../src/","sources":["dom/isVirtualElement.ts"],"names":[],"mappings":";;;;IAAS,iHAAA,gBAAgB,OAAA","sourcesContent":["export { isVirtualElement } from '@fluentui/dom-utilities';\n"]}
+1
View File
@@ -0,0 +1 @@
export declare function on(element: Element | Window | Document, eventName: string, callback: (ev: Event) => void, options?: boolean): () => void;
+10
View File
@@ -0,0 +1,10 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.on = on;
function on(element, eventName, callback, options) {
element.addEventListener(eventName, callback, options);
return function () { return element.removeEventListener(eventName, callback, options); };
}
});
//# sourceMappingURL=on.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"on.js","sourceRoot":"../src/","sources":["dom/on.ts"],"names":[],"mappings":";;;IAAA,gBASC;IATD,SAAgB,EAAE,CAChB,OAAoC,EACpC,SAAiB,EACjB,QAA6B,EAC7B,OAAiB;QAEjB,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEvD,OAAO,cAAM,OAAA,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAzD,CAAyD,CAAC;IACzE,CAAC","sourcesContent":["export function on(\n element: Element | Window | Document,\n eventName: string,\n callback: (ev: Event) => void,\n options?: boolean,\n): () => void {\n element.addEventListener(eventName, callback, options);\n\n return () => element.removeEventListener(eventName, callback, options);\n}\n"]}
@@ -0,0 +1 @@
export { portalContainsElement } from '@fluentui/dom-utilities';
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.portalContainsElement = void 0;
Object.defineProperty(exports, "portalContainsElement", { enumerable: true, get: function () { return dom_utilities_1.portalContainsElement; } });
});
//# sourceMappingURL=portalContainsElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"portalContainsElement.js","sourceRoot":"../src/","sources":["dom/portalContainsElement.ts"],"names":[],"mappings":";;;;IAAS,sHAAA,qBAAqB,OAAA","sourcesContent":["export { portalContainsElement } from '@fluentui/dom-utilities';\n"]}
+4
View File
@@ -0,0 +1,4 @@
/** Raises a click event.
* @deprecated Moved to `FocusZone` component since it was the only place internally using this function.
*/
export declare function raiseClick(target: Element, doc?: Document): void;
+30
View File
@@ -0,0 +1,30 @@
define(["require", "exports", "./getDocument"], function (require, exports, getDocument_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.raiseClick = raiseClick;
/** Raises a click event.
* @deprecated Moved to `FocusZone` component since it was the only place internally using this function.
*/
function raiseClick(target, doc) {
var theDoc = doc !== null && doc !== void 0 ? doc : (0, getDocument_1.getDocument)();
var event = createNewEvent('MouseEvents', theDoc);
// eslint-disable-next-line @typescript-eslint/no-deprecated
event.initEvent('click', true, true);
target.dispatchEvent(event);
}
function createNewEvent(eventName, doc) {
var event;
if (typeof Event === 'function') {
// Chrome, Opera, Firefox
event = new Event(eventName);
}
else {
// IE
event = doc.createEvent('Event');
// eslint-disable-next-line @typescript-eslint/no-deprecated
event.initEvent(eventName, true, true);
}
return event;
}
});
//# sourceMappingURL=raiseClick.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"raiseClick.js","sourceRoot":"../src/","sources":["dom/raiseClick.ts"],"names":[],"mappings":";;;IAKA,gCAMC;IATD;;OAEG;IACH,SAAgB,UAAU,CAAC,MAAe,EAAE,GAAc;QACxD,IAAM,MAAM,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAA,yBAAW,GAAG,CAAC;QACrC,IAAM,KAAK,GAAG,cAAc,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACpD,4DAA4D;QAC5D,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACrC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,cAAc,CAAC,SAAiB,EAAE,GAAa;QACtD,IAAI,KAAK,CAAC;QACV,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,yBAAyB;YACzB,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,KAAK;YACL,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACjC,4DAA4D;YAC5D,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC","sourcesContent":["import { getDocument } from './getDocument';\n\n/** Raises a click event.\n * @deprecated Moved to `FocusZone` component since it was the only place internally using this function.\n */\nexport function raiseClick(target: Element, doc?: Document): void {\n const theDoc = doc ?? getDocument()!;\n const event = createNewEvent('MouseEvents', theDoc);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n event.initEvent('click', true, true);\n target.dispatchEvent(event);\n}\n\nfunction createNewEvent(eventName: string, doc: Document): Event {\n let event;\n if (typeof Event === 'function') {\n // Chrome, Opera, Firefox\n event = new Event(eventName);\n } else {\n // IE\n event = doc.createEvent('Event');\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n event.initEvent(eventName, true, true);\n }\n return event;\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export { DATA_PORTAL_ATTRIBUTE, setPortalAttribute } from '@fluentui/dom-utilities';
+8
View File
@@ -0,0 +1,8 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setPortalAttribute = exports.DATA_PORTAL_ATTRIBUTE = void 0;
Object.defineProperty(exports, "DATA_PORTAL_ATTRIBUTE", { enumerable: true, get: function () { return dom_utilities_1.DATA_PORTAL_ATTRIBUTE; } });
Object.defineProperty(exports, "setPortalAttribute", { enumerable: true, get: function () { return dom_utilities_1.setPortalAttribute; } });
});
//# sourceMappingURL=setPortalAttribute.js.map
@@ -0,0 +1 @@
{"version":3,"file":"setPortalAttribute.js","sourceRoot":"../src/","sources":["dom/setPortalAttribute.ts"],"names":[],"mappings":";;;;IAAS,sHAAA,qBAAqB,OAAA;IAAE,mHAAA,kBAAkB,OAAA","sourcesContent":["export { DATA_PORTAL_ATTRIBUTE, setPortalAttribute } from '@fluentui/dom-utilities';\n"]}
+10
View File
@@ -0,0 +1,10 @@
/**
* @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.
*/
export declare let _isSSR: boolean;
/**
* Helper to set ssr mode to simulate no window object returned from getWindow helper.
*
* @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.
*/
export declare function setSSR(isEnabled: boolean): void;
+20
View File
@@ -0,0 +1,20 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._isSSR = void 0;
exports.setSSR = setSSR;
/**
* @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.
*/
exports._isSSR = false;
/**
* Helper to set ssr mode to simulate no window object returned from getWindow helper.
*
* @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.
*/
function setSSR(isEnabled) {
throw new Error('setSSR has been deprecated and is not used in any utilities anymore.' +
' Use canUseDOM from @fluentui/utilities instead.');
}
});
//# sourceMappingURL=setSSR.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setSSR.js","sourceRoot":"../src/","sources":["dom/setSSR.ts"],"names":[],"mappings":";;;;IAUA,wBAKC;IAfD;;OAEG;IACQ,QAAA,MAAM,GAAG,KAAK,CAAC;IAE1B;;;;OAIG;IACH,SAAgB,MAAM,CAAC,SAAkB;QACvC,MAAM,IAAI,KAAK,CACb,sEAAsE;YACpE,kDAAkD,CACrD,CAAC;IACJ,CAAC","sourcesContent":["/**\n * @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.\n */\nexport let _isSSR = false;\n\n/**\n * Helper to set ssr mode to simulate no window object returned from getWindow helper.\n *\n * @deprecated Use `canUseDOM` from `@fluentui/utilities` instead.\n */\nexport function setSSR(isEnabled: boolean): void {\n throw new Error(\n 'setSSR has been deprecated and is not used in any utilities anymore.' +\n ' Use canUseDOM from @fluentui/utilities instead.',\n );\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export { setVirtualParent } from '@fluentui/dom-utilities';
+7
View File
@@ -0,0 +1,7 @@
define(["require", "exports", "@fluentui/dom-utilities"], function (require, exports, dom_utilities_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setVirtualParent = void 0;
Object.defineProperty(exports, "setVirtualParent", { enumerable: true, get: function () { return dom_utilities_1.setVirtualParent; } });
});
//# sourceMappingURL=setVirtualParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setVirtualParent.js","sourceRoot":"../src/","sources":["dom/setVirtualParent.ts"],"names":[],"mappings":";;;;IAAS,iHAAA,gBAAgB,OAAA","sourcesContent":["export { setVirtualParent } from '@fluentui/dom-utilities';\n"]}