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
@@ -0,0 +1 @@
export type { IVirtualElement } from '@fluentui/dom-utilities';
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IVirtualElement.js.map
@@ -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;
+15
View File
@@ -0,0 +1,15 @@
"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":";;AAGA,8BASC;AAZD;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO;IACL,iDAAiD;IACjD,OAAO,MAAM,KAAK,WAAW;QAC7B,CAAC,CAAC;QACA,mFAAmF;QACnF,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CACnD,CACF,CAAC;AACJ,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 {};
+98
View File
@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var portalContainsElement_1 = require("./portalContainsElement");
var setPortalAttribute_1 = require("./setPortalAttribute");
var elementContains_1 = require("./elementContains");
var getParent_1 = require("./getParent");
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
@@ -0,0 +1 @@
export { elementContains } from '@fluentui/dom-utilities';
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContains = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
Object.defineProperty(exports, "elementContains", { enumerable: true, get: function () { return dom_utilities_1.elementContains; } });
//# sourceMappingURL=elementContains.js.map
@@ -0,0 +1 @@
{"version":3,"file":"elementContains.js","sourceRoot":"../src/","sources":["dom/elementContains.ts"],"names":[],"mappings":";;;AAAA,yDAA0D;AAAjD,gHAAA,eAAe,OAAA","sourcesContent":["export { elementContains } from '@fluentui/dom-utilities';\n"]}
@@ -0,0 +1 @@
export { elementContainsAttribute } from '@fluentui/dom-utilities';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContainsAttribute = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
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":";;;AAAA,yDAAmE;AAA1D,yHAAA,wBAAwB,OAAA","sourcesContent":["export { elementContainsAttribute } from '@fluentui/dom-utilities';\n"]}
@@ -0,0 +1 @@
export { findElementRecursive } from '@fluentui/dom-utilities';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findElementRecursive = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
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":";;;AAAA,yDAA+D;AAAtD,qHAAA,oBAAoB,OAAA","sourcesContent":["export { findElementRecursive } from '@fluentui/dom-utilities';\n"]}
@@ -0,0 +1 @@
export { getActiveElement } from '@fluentui/dom-utilities';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveElement = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
Object.defineProperty(exports, "getActiveElement", { enumerable: true, get: function () { return dom_utilities_1.getActiveElement; } });
//# sourceMappingURL=getActiveElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getActiveElement.js","sourceRoot":"../src/","sources":["dom/getActiveElement.ts"],"names":[],"mappings":";;;AAAA,yDAA2D;AAAlD,iHAAA,gBAAgB,OAAA","sourcesContent":["export { getActiveElement } from '@fluentui/dom-utilities';\n"]}
+1
View File
@@ -0,0 +1 @@
export { getChildren } from '@fluentui/dom-utilities';
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildren = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
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":";;;AAAA,yDAAsD;AAA7C,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;
+23
View File
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDocument = getDocument;
var canUseDOM_1 = require("./canUseDOM");
/**
* 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":";;AASA,kCAUC;AAnBD,yCAAwC;AAExC;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,WAAgC;IAC1D,iDAAiD;IACjD,IAAI,CAAC,IAAA,qBAAS,GAAE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,IAAM,EAAE,GAAG,WAAsB,CAAC;QAElC,iDAAiD;QACjD,OAAO,EAAE,IAAI,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9D,CAAC;AACH,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"]}
@@ -0,0 +1 @@
export { getEventTarget } from '@fluentui/dom-utilities';
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEventTarget = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
Object.defineProperty(exports, "getEventTarget", { enumerable: true, get: function () { return dom_utilities_1.getEventTarget; } });
//# sourceMappingURL=getEventTarget.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getEventTarget.js","sourceRoot":"../src/","sources":["dom/getEventTarget.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AAAhD,+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 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFirstVisibleElementFromSelector = getFirstVisibleElementFromSelector;
var focus_1 = require("../focus");
var getDocument_1 = require("./getDocument");
/**
* 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":";;AAUA,gFAQC;AAlBD,kCAAwD;AACxD,6CAA4C;AAE5C;;;;;;GAMG;AACH,SAAgB,kCAAkC,CAAC,QAAgB;IACjE,IAAM,GAAG,GAAG,IAAA,yBAAW,GAAG,CAAC;IAC3B,IAAM,QAAQ,GAAG,GAAG,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAEhD,sGAAsG;IACtG,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;AACJ,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';
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParent = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
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":";;;AAAA,yDAAoD;AAA3C,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;
+32
View File
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRect = getRect;
var getWindow_1 = require("./getWindow");
/**
* 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":";;AAQA,0BAqBC;AA5BD,yCAAwC;AAExC;;;;GAIG;AACH,SAAgB,OAAO,CAAC,OAAoC,EAAE,GAAY;IACxE,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;QAC1E,CAAC,CAAC,IAAA,qBAAS,GAAE;QACb,CAAC,CAAC,IAAA,qBAAS,EAAC,OAAsB,CAAE,CAAC;IACzC,IAAI,IAA4B,CAAC;IACjC,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;YACvB,IAAI,GAAG;gBACL,IAAI,EAAE,CAAC;gBACP,GAAG,EAAE,CAAC;gBACN,KAAK,EAAE,MAAM,CAAC,UAAU;gBACxB,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,KAAK,EAAE,MAAM,CAAC,UAAU;gBACxB,MAAM,EAAE,MAAM,CAAC,WAAW;aAC3B,CAAC;QACJ,CAAC;aAAM,IAAK,OAA+C,CAAC,qBAAqB,EAAE,CAAC;YAClF,IAAI,GAAI,OAAuB,CAAC,qBAAqB,EAAE,CAAC;QAC1D,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,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"]}
@@ -0,0 +1 @@
export { getVirtualParent } from '@fluentui/dom-utilities';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVirtualParent = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
Object.defineProperty(exports, "getVirtualParent", { enumerable: true, get: function () { return dom_utilities_1.getVirtualParent; } });
//# sourceMappingURL=getVirtualParent.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getVirtualParent.js","sourceRoot":"../src/","sources":["dom/getVirtualParent.ts"],"names":[],"mappings":";;;AAAA,yDAA2D;AAAlD,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;
+33
View File
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWindow = getWindow;
var canUseDOM_1 = require("./canUseDOM");
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":";;AAsBA,8BAQC;AA9BD,yCAAwC;AAExC,IAAI,OAAO,GAAuB,SAAS,CAAC;AAE5C,sFAAsF;AACtF,iFAAiF;AACjF,0EAA0E;AAC1E,IAAI,CAAC;IACH,iDAAiD;IACjD,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,WAAW;AACb,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAC,WAA4B;IACpD,IAAI,CAAC,IAAA,qBAAS,GAAE,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,IAAM,EAAE,GAAG,WAAsB,CAAC;QAElC,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;IACzG,CAAC;AACH,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"]}
@@ -0,0 +1 @@
export { isVirtualElement } from '@fluentui/dom-utilities';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isVirtualElement = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
Object.defineProperty(exports, "isVirtualElement", { enumerable: true, get: function () { return dom_utilities_1.isVirtualElement; } });
//# sourceMappingURL=isVirtualElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isVirtualElement.js","sourceRoot":"../src/","sources":["dom/isVirtualElement.ts"],"names":[],"mappings":";;;AAAA,yDAA2D;AAAlD,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;
+8
View File
@@ -0,0 +1,8 @@
"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":";;AAAA,gBASC;AATD,SAAgB,EAAE,CAChB,OAAoC,EACpC,SAAiB,EACjB,QAA6B,EAC7B,OAAiB;IAEjB,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEvD,OAAO,cAAM,OAAA,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAzD,CAAyD,CAAC;AACzE,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,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.portalContainsElement = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
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":";;;AAAA,yDAAgE;AAAvD,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;
+29
View File
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.raiseClick = raiseClick;
var getDocument_1 = require("./getDocument");
/** 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":";;AAKA,gCAMC;AAXD,6CAA4C;AAE5C;;GAEG;AACH,SAAgB,UAAU,CAAC,MAAe,EAAE,GAAc;IACxD,IAAM,MAAM,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAA,yBAAW,GAAG,CAAC;IACrC,IAAM,KAAK,GAAG,cAAc,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACpD,4DAA4D;IAC5D,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,cAAc,CAAC,SAAiB,EAAE,GAAa;IACtD,IAAI,KAAK,CAAC;IACV,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,yBAAyB;QACzB,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,KAAK;QACL,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACjC,4DAA4D;QAC5D,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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"]}
@@ -0,0 +1 @@
export { DATA_PORTAL_ATTRIBUTE, setPortalAttribute } from '@fluentui/dom-utilities';
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setPortalAttribute = exports.DATA_PORTAL_ATTRIBUTE = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
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":";;;AAAA,yDAAoF;AAA3E,sHAAA,qBAAqB,OAAA;AAAE,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;
+18
View File
@@ -0,0 +1,18 @@
"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":";;;AAUA,wBAKC;AAfD;;GAEG;AACQ,QAAA,MAAM,GAAG,KAAK,CAAC;AAE1B;;;;GAIG;AACH,SAAgB,MAAM,CAAC,SAAkB;IACvC,MAAM,IAAI,KAAK,CACb,sEAAsE;QACpE,kDAAkD,CACrD,CAAC;AACJ,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"]}
@@ -0,0 +1 @@
export { setVirtualParent } from '@fluentui/dom-utilities';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setVirtualParent = void 0;
var dom_utilities_1 = require("@fluentui/dom-utilities");
Object.defineProperty(exports, "setVirtualParent", { enumerable: true, get: function () { return dom_utilities_1.setVirtualParent; } });
//# sourceMappingURL=setVirtualParent.js.map
@@ -0,0 +1 @@
{"version":3,"file":"setVirtualParent.js","sourceRoot":"../src/","sources":["dom/setVirtualParent.ts"],"names":[],"mappings":";;;AAAA,yDAA2D;AAAlD,iHAAA,gBAAgB,OAAA","sourcesContent":["export { setVirtualParent } from '@fluentui/dom-utilities';\n"]}