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
+10
View File
@@ -0,0 +1,10 @@
/**
* Attached interface for elements which support virtual references.
* Used internally by the virtual hierarchy methods.
*/
export interface IVirtualElement extends HTMLElement {
_virtual: {
parent?: IVirtualElement;
children: IVirtualElement[];
};
}
+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":["IVirtualElement.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Attached interface for elements which support virtual references.\n * Used internally by the virtual hierarchy methods.\n */\nexport interface IVirtualElement extends HTMLElement {\n _virtual: {\n parent?: IVirtualElement;\n children: IVirtualElement[];\n };\n}\n"]}
@@ -0,0 +1,8 @@
/**
* Determines whether or not a parent element contains a given child element.
* If `allowVirtualParents` is true, this method may return `true` if the child
* has the parent in its virtual element hierarchy.
*
* @public
*/
export declare function elementContains(parent: HTMLElement | null, child: HTMLElement | null, allowVirtualParents?: boolean): boolean;
+39
View File
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContains = void 0;
var getParent_1 = require("./getParent");
/**
* Determines whether or not a parent element contains a given child element.
* If `allowVirtualParents` is true, this method may return `true` if the child
* has the parent in its virtual element hierarchy.
*
* @public
*/
function elementContains(parent, child, allowVirtualParents) {
if (allowVirtualParents === void 0) { allowVirtualParents = true; }
var isContained = false;
if (parent && child) {
if (allowVirtualParents) {
if (parent === child) {
isContained = true;
}
else {
isContained = false;
while (child) {
var nextParent = (0, getParent_1.getParent)(child);
if (nextParent === parent) {
isContained = true;
break;
}
child = nextParent;
}
}
}
else if (parent.contains) {
isContained = parent.contains(child);
}
}
return isContained;
}
exports.elementContains = elementContains;
//# sourceMappingURL=elementContains.js.map
@@ -0,0 +1 @@
{"version":3,"file":"elementContains.js","sourceRoot":"../src/","sources":["elementContains.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,MAA0B,EAC1B,KAAyB,EACzB,mBAAmC;IAAnC,oCAAA,EAAA,0BAAmC;IAEnC,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QACpB,IAAI,mBAAmB,EAAE,CAAC;YACxB,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;gBACrB,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,WAAW,GAAG,KAAK,CAAC;gBAEpB,OAAO,KAAK,EAAE,CAAC;oBACb,IAAM,UAAU,GAAuB,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;oBAExD,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;wBAC1B,WAAW,GAAG,IAAI,CAAC;wBACnB,MAAM;oBACR,CAAC;oBAED,KAAK,GAAG,UAAU,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3B,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AA/BD,0CA+BC","sourcesContent":["import { getParent } from './getParent';\n/**\n * Determines whether or not a parent element contains a given child element.\n * If `allowVirtualParents` is true, this method may return `true` if the child\n * has the parent in its virtual element hierarchy.\n *\n * @public\n */\nexport function elementContains(\n parent: HTMLElement | null,\n child: HTMLElement | null,\n allowVirtualParents: boolean = true,\n): boolean {\n let isContained = false;\n\n if (parent && child) {\n if (allowVirtualParents) {\n if (parent === child) {\n isContained = true;\n } else {\n isContained = false;\n\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n isContained = true;\n break;\n }\n\n child = nextParent;\n }\n }\n } else if (parent.contains) {\n isContained = parent.contains(child);\n }\n }\n\n return isContained;\n}\n"]}
@@ -0,0 +1,7 @@
/**
* Determines if an element, or any of its ancestors, contain the given attribute
* @param element - element to start searching at
* @param attribute - the attribute to search for
* @returns the value of the first instance found
*/
export declare function elementContainsAttribute(element: HTMLElement, attribute: string, doc?: Document): string | null;
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContainsAttribute = void 0;
var findElementRecursive_1 = require("./findElementRecursive");
/**
* Determines if an element, or any of its ancestors, contain the given attribute
* @param element - element to start searching at
* @param attribute - the attribute to search for
* @returns the value of the first instance found
*/
function elementContainsAttribute(element, attribute, doc) {
var elementMatch = (0, findElementRecursive_1.findElementRecursive)(element, function (testElement) { return testElement.hasAttribute(attribute); }, doc);
return elementMatch && elementMatch.getAttribute(attribute);
}
exports.elementContainsAttribute = elementContainsAttribute;
//# sourceMappingURL=elementContainsAttribute.js.map
@@ -0,0 +1 @@
{"version":3,"file":"elementContainsAttribute.js","sourceRoot":"../src/","sources":["elementContainsAttribute.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAE9D;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,OAAoB,EAAE,SAAiB,EAAE,GAAc;IAC9F,IAAM,YAAY,GAAG,IAAA,2CAAoB,EACvC,OAAO,EACP,UAAC,WAAwB,IAAK,OAAA,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,EAAnC,CAAmC,EACjE,GAAG,CACJ,CAAC;IAEF,OAAO,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AAC9D,CAAC;AARD,4DAQC","sourcesContent":["import { findElementRecursive } from './findElementRecursive';\n\n/**\n * Determines if an element, or any of its ancestors, contain the given attribute\n * @param element - element to start searching at\n * @param attribute - the attribute to search for\n * @returns the value of the first instance found\n */\nexport function elementContainsAttribute(element: HTMLElement, attribute: string, doc?: Document): string | null {\n const elementMatch = findElementRecursive(\n element,\n (testElement: HTMLElement) => testElement.hasAttribute(attribute),\n doc,\n );\n\n return elementMatch && elementMatch.getAttribute(attribute);\n}\n"]}
@@ -0,0 +1,7 @@
/**
* Finds the first parent element where the matchFunction returns true
* @param element - element to start searching at
* @param matchFunction - the function that determines if the element is a match
* @returns the matched element or null no match was found
*/
export declare function findElementRecursive(element: HTMLElement | null, matchFunction: (element: HTMLElement) => boolean, doc?: Document): HTMLElement | null;
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findElementRecursive = void 0;
var getParent_1 = require("./getParent");
/**
* Finds the first parent element where the matchFunction returns true
* @param element - element to start searching at
* @param matchFunction - the function that determines if the element is a match
* @returns the matched element or null no match was found
*/
function findElementRecursive(element, matchFunction, doc) {
// eslint-disable-next-line no-restricted-globals
doc !== null && doc !== void 0 ? doc : (doc = document);
if (!element || element === doc.body || element instanceof Document) {
return null;
}
return matchFunction(element) ? element : findElementRecursive((0, getParent_1.getParent)(element), matchFunction);
}
exports.findElementRecursive = findElementRecursive;
//# sourceMappingURL=findElementRecursive.js.map
@@ -0,0 +1 @@
{"version":3,"file":"findElementRecursive.js","sourceRoot":"../src/","sources":["findElementRecursive.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,OAA2B,EAC3B,aAAgD,EAChD,GAAc;IAEd,iDAAiD;IACjD,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,QAAQ,EAAC;IACjB,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,GAAG,CAAC,IAAI,IAAI,OAAO,YAAY,QAAQ,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAA,qBAAS,EAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;AACpG,CAAC;AAXD,oDAWC","sourcesContent":["import { getParent } from './getParent';\n/**\n * Finds the first parent element where the matchFunction returns true\n * @param element - element to start searching at\n * @param matchFunction - the function that determines if the element is a match\n * @returns the matched element or null no match was found\n */\nexport function findElementRecursive(\n element: HTMLElement | null,\n matchFunction: (element: HTMLElement) => boolean,\n doc?: Document,\n): HTMLElement | null {\n // eslint-disable-next-line no-restricted-globals\n doc ??= document;\n if (!element || element === doc.body || element instanceof Document) {\n return null;\n }\n return matchFunction(element) ? element : findElementRecursive(getParent(element), matchFunction);\n}\n"]}
@@ -0,0 +1 @@
export declare const getActiveElement: (doc: Document) => Element | null;
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveElement = void 0;
var getActiveElement = function (doc) {
var ae = doc.activeElement;
while (ae === null || ae === void 0 ? void 0 : ae.shadowRoot) {
ae = ae.shadowRoot.activeElement;
}
return ae;
};
exports.getActiveElement = getActiveElement;
//# sourceMappingURL=getActiveElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getActiveElement.js","sourceRoot":"../src/","sources":["getActiveElement.ts"],"names":[],"mappings":";;;AAAO,IAAM,gBAAgB,GAAG,UAAC,GAAa;IAC5C,IAAI,EAAE,GAAG,GAAG,CAAC,aAAa,CAAC;IAE3B,OAAO,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,UAAU,EAAE,CAAC;QACtB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;IACnC,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AARW,QAAA,gBAAgB,oBAQ3B","sourcesContent":["export const getActiveElement = (doc: Document): Element | null => {\n let ae = doc.activeElement;\n\n while (ae?.shadowRoot) {\n ae = ae.shadowRoot.activeElement;\n }\n\n return ae;\n};\n"]}
+8
View File
@@ -0,0 +1,8 @@
/**
* Gets the elements which are child elements of the given element.
* If `allowVirtualChildren` is `true`, this method enumerates virtual child elements
* after the original children.
* @param parent - The element to get the children of.
* @param allowVirtualChildren - true if the method should enumerate virtual child elements.
*/
export declare function getChildren(parent: HTMLElement, allowVirtualChildren?: boolean): HTMLElement[];
+26
View File
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildren = void 0;
var isVirtualElement_1 = require("./isVirtualElement");
/**
* Gets the elements which are child elements of the given element.
* If `allowVirtualChildren` is `true`, this method enumerates virtual child elements
* after the original children.
* @param parent - The element to get the children of.
* @param allowVirtualChildren - true if the method should enumerate virtual child elements.
*/
function getChildren(parent, allowVirtualChildren) {
if (allowVirtualChildren === void 0) { allowVirtualChildren = true; }
var children = [];
if (parent) {
for (var i = 0; i < parent.children.length; i++) {
children.push(parent.children.item(i));
}
if (allowVirtualChildren && (0, isVirtualElement_1.isVirtualElement)(parent)) {
children.push.apply(children, parent._virtual.children);
}
}
return children;
}
exports.getChildren = getChildren;
//# sourceMappingURL=getChildren.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getChildren.js","sourceRoot":"../src/","sources":["getChildren.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AACtD;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,MAAmB,EAAE,oBAAoC;IAApC,qCAAA,EAAA,2BAAoC;IACnF,IAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAgB,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,oBAAoB,IAAI,IAAA,mCAAgB,EAAC,MAAM,CAAC,EAAE,CAAC;YACrD,QAAQ,CAAC,IAAI,OAAb,QAAQ,EAAS,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAXD,kCAWC","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the elements which are child elements of the given element.\n * If `allowVirtualChildren` is `true`, this method enumerates virtual child elements\n * after the original children.\n * @param parent - The element to get the children of.\n * @param allowVirtualChildren - true if the method should enumerate virtual child elements.\n */\nexport function getChildren(parent: HTMLElement, allowVirtualChildren: boolean = true): HTMLElement[] {\n const children: HTMLElement[] = [];\n if (parent) {\n for (let i = 0; i < parent.children.length; i++) {\n children.push(parent.children.item(i) as HTMLElement);\n }\n if (allowVirtualChildren && isVirtualElement(parent)) {\n children.push(...parent._virtual.children);\n }\n }\n return children;\n}\n"]}
@@ -0,0 +1 @@
export declare const getEventTarget: (event: Event) => HTMLElement | null;
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEventTarget = void 0;
var getEventTarget = function (event) {
var target = event.target;
if (target && target.shadowRoot) {
target = event.composedPath()[0];
}
return target;
};
exports.getEventTarget = getEventTarget;
//# sourceMappingURL=getEventTarget.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getEventTarget.js","sourceRoot":"../src/","sources":["getEventTarget.ts"],"names":[],"mappings":";;;AAAO,IAAM,cAAc,GAAG,UAAC,KAAY;IACzC,IAAI,MAAM,GAAG,KAAK,CAAC,MAAqB,CAAC;IACzC,IAAI,MAAM,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAChC,MAAM,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAgB,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB","sourcesContent":["export const getEventTarget = (event: Event): HTMLElement | null => {\n let target = event.target as HTMLElement;\n if (target && target.shadowRoot) {\n target = event.composedPath()[0] as HTMLElement;\n }\n\n return target;\n};\n"]}
+8
View File
@@ -0,0 +1,8 @@
/**
* Gets the element which is the parent of a given element.
* If `allowVirtuaParents` is `true`, this method prefers the virtual parent over
* real DOM parent when present.
*
* @public
*/
export declare function getParent(child: HTMLElement, allowVirtualParents?: boolean): HTMLElement | null;
+37
View File
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParent = void 0;
var getVirtualParent_1 = require("./getVirtualParent");
/**
* Gets the element which is the parent of a given element.
* If `allowVirtuaParents` is `true`, this method prefers the virtual parent over
* real DOM parent when present.
*
* @public
*/
function getParent(child, allowVirtualParents) {
var _a, _b;
if (allowVirtualParents === void 0) { allowVirtualParents = true; }
if (!child) {
return null;
}
var parent = allowVirtualParents && (0, getVirtualParent_1.getVirtualParent)(child);
if (parent) {
return parent;
}
// Support looking for parents in shadow DOM
if (typeof child.assignedElements !== 'function' && ((_a = child.assignedSlot) === null || _a === void 0 ? void 0 : _a.parentNode)) {
// Element is slotted
return child.assignedSlot;
}
else if (((_b = child.parentNode) === null || _b === void 0 ? void 0 : _b.nodeType) === 11) {
// nodeType 11 is DOCUMENT_FRAGMENT
// Element is in shadow root
return child.parentNode.host;
}
else {
return child.parentNode;
}
}
exports.getParent = getParent;
//# sourceMappingURL=getParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getParent.js","sourceRoot":"../src/","sources":["getParent.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AACtD;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAkB,EAAE,mBAAmC;;IAAnC,oCAAA,EAAA,0BAAmC;IAC/E,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAM,MAAM,GAAG,mBAAmB,IAAI,IAAA,mCAAgB,EAAC,KAAK,CAAC,CAAC;IAE9D,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,4CAA4C;IAC5C,IAAI,OAAQ,KAAyB,CAAC,gBAAgB,KAAK,UAAU,KAAI,MAAA,KAAK,CAAC,YAAY,0CAAE,UAAU,CAAA,EAAE,CAAC;QACxG,qBAAqB;QACrB,OAAO,KAAK,CAAC,YAA2B,CAAC;IAC3C,CAAC;SAAM,IAAI,CAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,QAAQ,MAAK,EAAE,EAAE,CAAC;QAC7C,mCAAmC;QACnC,4BAA4B;QAC5B,OAAQ,KAAK,CAAC,UAAyB,CAAC,IAAmB,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,UAAyB,CAAC;IACzC,CAAC;AACH,CAAC;AAtBD,8BAsBC","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n/**\n * Gets the element which is the parent of a given element.\n * If `allowVirtuaParents` is `true`, this method prefers the virtual parent over\n * real DOM parent when present.\n *\n * @public\n */\nexport function getParent(child: HTMLElement, allowVirtualParents: boolean = true): HTMLElement | null {\n if (!child) {\n return null;\n }\n\n const parent = allowVirtualParents && getVirtualParent(child);\n\n if (parent) {\n return parent;\n }\n\n // Support looking for parents in shadow DOM\n if (typeof (child as HTMLSlotElement).assignedElements !== 'function' && child.assignedSlot?.parentNode) {\n // Element is slotted\n return child.assignedSlot as HTMLElement;\n } else if (child.parentNode?.nodeType === 11) {\n // nodeType 11 is DOCUMENT_FRAGMENT\n // Element is in shadow root\n return (child.parentNode as ShadowRoot).host as HTMLElement;\n } else {\n return child.parentNode as HTMLElement;\n }\n}\n"]}
@@ -0,0 +1,6 @@
/**
* Gets the virtual parent given the child element, if it exists.
*
* @public
*/
export declare function getVirtualParent(child: HTMLElement): HTMLElement | undefined;
+18
View File
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVirtualParent = void 0;
var isVirtualElement_1 = require("./isVirtualElement");
/**
* Gets the virtual parent given the child element, if it exists.
*
* @public
*/
function getVirtualParent(child) {
var parent;
if (child && (0, isVirtualElement_1.isVirtualElement)(child)) {
parent = child._virtual.parent;
}
return parent;
}
exports.getVirtualParent = getVirtualParent;
//# sourceMappingURL=getVirtualParent.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getVirtualParent.js","sourceRoot":"../src/","sources":["getVirtualParent.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AACtD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,KAAkB;IACjD,IAAI,MAA+B,CAAC;IACpC,IAAI,KAAK,IAAI,IAAA,mCAAgB,EAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,4CAMC","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n *\n * @public\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (child && isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"]}
+14
View File
@@ -0,0 +1,14 @@
export type { IVirtualElement } from './IVirtualElement';
export { elementContains } from './elementContains';
export { elementContainsAttribute } from './elementContainsAttribute';
export { findElementRecursive } from './findElementRecursive';
export { getActiveElement } from './getActiveElement';
export { getChildren } from './getChildren';
export { getEventTarget } from './getEventTarget';
export { getParent } from './getParent';
export { getVirtualParent } from './getVirtualParent';
export { isVirtualElement } from './isVirtualElement';
export { portalContainsElement } from './portalContainsElement';
export { DATA_PORTAL_ATTRIBUTE, setPortalAttribute } from './setPortalAttribute';
export { setVirtualParent } from './setVirtualParent';
import './version';
+30
View File
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setVirtualParent = exports.setPortalAttribute = exports.DATA_PORTAL_ATTRIBUTE = exports.portalContainsElement = exports.isVirtualElement = exports.getVirtualParent = exports.getParent = exports.getEventTarget = exports.getChildren = exports.getActiveElement = exports.findElementRecursive = exports.elementContainsAttribute = exports.elementContains = void 0;
var elementContains_1 = require("./elementContains");
Object.defineProperty(exports, "elementContains", { enumerable: true, get: function () { return elementContains_1.elementContains; } });
var elementContainsAttribute_1 = require("./elementContainsAttribute");
Object.defineProperty(exports, "elementContainsAttribute", { enumerable: true, get: function () { return elementContainsAttribute_1.elementContainsAttribute; } });
var findElementRecursive_1 = require("./findElementRecursive");
Object.defineProperty(exports, "findElementRecursive", { enumerable: true, get: function () { return findElementRecursive_1.findElementRecursive; } });
var getActiveElement_1 = require("./getActiveElement");
Object.defineProperty(exports, "getActiveElement", { enumerable: true, get: function () { return getActiveElement_1.getActiveElement; } });
var getChildren_1 = require("./getChildren");
Object.defineProperty(exports, "getChildren", { enumerable: true, get: function () { return getChildren_1.getChildren; } });
var getEventTarget_1 = require("./getEventTarget");
Object.defineProperty(exports, "getEventTarget", { enumerable: true, get: function () { return getEventTarget_1.getEventTarget; } });
var getParent_1 = require("./getParent");
Object.defineProperty(exports, "getParent", { enumerable: true, get: function () { return getParent_1.getParent; } });
var getVirtualParent_1 = require("./getVirtualParent");
Object.defineProperty(exports, "getVirtualParent", { enumerable: true, get: function () { return getVirtualParent_1.getVirtualParent; } });
var isVirtualElement_1 = require("./isVirtualElement");
Object.defineProperty(exports, "isVirtualElement", { enumerable: true, get: function () { return isVirtualElement_1.isVirtualElement; } });
var portalContainsElement_1 = require("./portalContainsElement");
Object.defineProperty(exports, "portalContainsElement", { enumerable: true, get: function () { return portalContainsElement_1.portalContainsElement; } });
var setPortalAttribute_1 = require("./setPortalAttribute");
Object.defineProperty(exports, "DATA_PORTAL_ATTRIBUTE", { enumerable: true, get: function () { return setPortalAttribute_1.DATA_PORTAL_ATTRIBUTE; } });
Object.defineProperty(exports, "setPortalAttribute", { enumerable: true, get: function () { return setPortalAttribute_1.setPortalAttribute; } });
var setVirtualParent_1 = require("./setVirtualParent");
Object.defineProperty(exports, "setVirtualParent", { enumerable: true, get: function () { return setVirtualParent_1.setVirtualParent; } });
require("./version");
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;AACA,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2DAAiF;AAAxE,2HAAA,qBAAqB,OAAA;AAAE,wHAAA,kBAAkB,OAAA;AAClD,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AAEzB,qBAAmB","sourcesContent":["export type { IVirtualElement } from './IVirtualElement';\nexport { elementContains } from './elementContains';\nexport { elementContainsAttribute } from './elementContainsAttribute';\nexport { findElementRecursive } from './findElementRecursive';\nexport { getActiveElement } from './getActiveElement';\nexport { getChildren } from './getChildren';\nexport { getEventTarget } from './getEventTarget';\nexport { getParent } from './getParent';\nexport { getVirtualParent } from './getVirtualParent';\nexport { isVirtualElement } from './isVirtualElement';\nexport { portalContainsElement } from './portalContainsElement';\nexport { DATA_PORTAL_ATTRIBUTE, setPortalAttribute } from './setPortalAttribute';\nexport { setVirtualParent } from './setVirtualParent';\n\nimport './version';\n"]}
@@ -0,0 +1,7 @@
import { IVirtualElement } from './IVirtualElement';
/**
* Determines whether or not an element has the virtual hierarchy extension.
*
* @public
*/
export declare function isVirtualElement(element: HTMLElement | IVirtualElement): element is IVirtualElement;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isVirtualElement = void 0;
/**
* Determines whether or not an element has the virtual hierarchy extension.
*
* @public
*/
function isVirtualElement(element) {
return element && !!element._virtual;
}
exports.isVirtualElement = isVirtualElement;
//# sourceMappingURL=isVirtualElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isVirtualElement.js","sourceRoot":"../src/","sources":["isVirtualElement.ts"],"names":[],"mappings":";;;AACA;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,OAAsC;IACrE,OAAO,OAAO,IAAI,CAAC,CAAmB,OAAQ,CAAC,QAAQ,CAAC;AAC1D,CAAC;AAFD,4CAEC","sourcesContent":["import { IVirtualElement } from './IVirtualElement';\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n *\n * @public\n */\nexport function isVirtualElement(element: HTMLElement | IVirtualElement): element is IVirtualElement {\n return element && !!(<IVirtualElement>element)._virtual;\n}\n"]}
@@ -0,0 +1,9 @@
/**
* Determine whether a target is within a portal from perspective of root or optional parent.
* This function only works against portal components that use the setPortalAttribute function.
* If both parent and child are within the same portal this function will return false.
* @param target - Element to query portal containment status of.
* @param parent - Optional parent perspective. Search for containing portal stops at parent
* (or root if parent is undefined or invalid.)
*/
export declare function portalContainsElement(target: HTMLElement, parent?: HTMLElement, doc?: Document): boolean;
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.portalContainsElement = void 0;
var findElementRecursive_1 = require("./findElementRecursive");
var setPortalAttribute_1 = require("./setPortalAttribute");
/**
* Determine whether a target is within a portal from perspective of root or optional parent.
* This function only works against portal components that use the setPortalAttribute function.
* If both parent and child are within the same portal this function will return false.
* @param target - Element to query portal containment status of.
* @param parent - Optional parent perspective. Search for containing portal stops at parent
* (or root if parent is undefined or invalid.)
*/
function portalContainsElement(target, parent, doc) {
var _a;
var elementMatch = (0, findElementRecursive_1.findElementRecursive)(target, function (testElement) { var _a; return parent === testElement || !!((_a = testElement.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(testElement, setPortalAttribute_1.DATA_PORTAL_ATTRIBUTE)); }, doc);
return elementMatch !== null && !!((_a = elementMatch.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(elementMatch, setPortalAttribute_1.DATA_PORTAL_ATTRIBUTE));
}
exports.portalContainsElement = portalContainsElement;
//# sourceMappingURL=portalContainsElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"portalContainsElement.js","sourceRoot":"../src/","sources":["portalContainsElement.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAC9D,2DAA6D;AAE7D;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAC,MAAmB,EAAE,MAAoB,EAAE,GAAc;;IAC7F,IAAM,YAAY,GAAG,IAAA,2CAAoB,EACvC,MAAM,EACN,UAAC,WAAwB,YAAK,OAAA,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,CAAA,MAAA,WAAW,CAAC,YAAY,4DAAG,0CAAqB,CAAC,CAAA,CAAA,EAAA,EAC3G,GAAG,CACJ,CAAC;IACF,OAAO,YAAY,KAAK,IAAI,IAAI,CAAC,CAAC,CAAA,MAAA,YAAY,CAAC,YAAY,6DAAG,0CAAqB,CAAC,CAAA,CAAC;AACvF,CAAC;AAPD,sDAOC","sourcesContent":["import { findElementRecursive } from './findElementRecursive';\nimport { DATA_PORTAL_ATTRIBUTE } from './setPortalAttribute';\n\n/**\n * Determine whether a target is within a portal from perspective of root or optional parent.\n * This function only works against portal components that use the setPortalAttribute function.\n * If both parent and child are within the same portal this function will return false.\n * @param target - Element to query portal containment status of.\n * @param parent - Optional parent perspective. Search for containing portal stops at parent\n * (or root if parent is undefined or invalid.)\n */\nexport function portalContainsElement(target: HTMLElement, parent?: HTMLElement, doc?: Document): boolean {\n const elementMatch = findElementRecursive(\n target,\n (testElement: HTMLElement) => parent === testElement || !!testElement.hasAttribute?.(DATA_PORTAL_ATTRIBUTE),\n doc,\n );\n return elementMatch !== null && !!elementMatch.hasAttribute?.(DATA_PORTAL_ATTRIBUTE);\n}\n"]}
@@ -0,0 +1,6 @@
export declare const DATA_PORTAL_ATTRIBUTE = "data-portal-element";
/**
* Identify element as a portal by setting an attribute.
* @param element - Element to mark as a portal.
*/
export declare function setPortalAttribute(element: HTMLElement): void;
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setPortalAttribute = exports.DATA_PORTAL_ATTRIBUTE = void 0;
exports.DATA_PORTAL_ATTRIBUTE = 'data-portal-element';
/**
* Identify element as a portal by setting an attribute.
* @param element - Element to mark as a portal.
*/
function setPortalAttribute(element) {
element.setAttribute(exports.DATA_PORTAL_ATTRIBUTE, 'true');
}
exports.setPortalAttribute = setPortalAttribute;
//# sourceMappingURL=setPortalAttribute.js.map
@@ -0,0 +1 @@
{"version":3,"file":"setPortalAttribute.js","sourceRoot":"../src/","sources":["setPortalAttribute.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,OAAoB;IACrD,OAAO,CAAC,YAAY,CAAC,6BAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAFD,gDAEC","sourcesContent":["export const DATA_PORTAL_ATTRIBUTE = 'data-portal-element';\n\n/**\n * Identify element as a portal by setting an attribute.\n * @param element - Element to mark as a portal.\n */\nexport function setPortalAttribute(element: HTMLElement): void {\n element.setAttribute(DATA_PORTAL_ATTRIBUTE, 'true');\n}\n"]}
@@ -0,0 +1,7 @@
/**
* Sets the virtual parent of an element.
* Pass `undefined` as the `parent` to clear the virtual parent.
*
* @public
*/
export declare function setVirtualParent(child: HTMLElement, parent: HTMLElement | null): void;
+37
View File
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setVirtualParent = void 0;
/**
* Sets the virtual parent of an element.
* Pass `undefined` as the `parent` to clear the virtual parent.
*
* @public
*/
function setVirtualParent(child, parent) {
var virtualChild = child;
var virtualParent = parent;
if (!virtualChild._virtual) {
virtualChild._virtual = {
children: [],
};
}
var oldParent = virtualChild._virtual.parent;
if (oldParent && oldParent !== parent) {
// Remove the child from its old parent.
var index = oldParent._virtual.children.indexOf(virtualChild);
if (index > -1) {
oldParent._virtual.children.splice(index, 1);
}
}
virtualChild._virtual.parent = virtualParent || undefined;
if (virtualParent) {
if (!virtualParent._virtual) {
virtualParent._virtual = {
children: [],
};
}
virtualParent._virtual.children.push(virtualChild);
}
}
exports.setVirtualParent = setVirtualParent;
//# sourceMappingURL=setVirtualParent.js.map
@@ -0,0 +1 @@
{"version":3,"file":"setVirtualParent.js","sourceRoot":"../src/","sources":["setVirtualParent.ts"],"names":[],"mappings":";;;AACA;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAkB,EAAE,MAA0B;IAC7E,IAAM,YAAY,GAAoB,KAAK,CAAC;IAC5C,IAAM,aAAa,GAA2B,MAAM,CAAC;IAErD,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC3B,YAAY,CAAC,QAAQ,GAAG;YACtB,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,IAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;IAE/C,IAAI,SAAS,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACtC,wCAAwC;QACxC,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACf,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,aAAa,IAAI,SAAS,CAAC;IAE1D,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC5B,aAAa,CAAC,QAAQ,GAAG;gBACvB,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAhCD,4CAgCC","sourcesContent":["import { IVirtualElement } from './IVirtualElement';\n/**\n * Sets the virtual parent of an element.\n * Pass `undefined` as the `parent` to clear the virtual parent.\n *\n * @public\n */\nexport function setVirtualParent(child: HTMLElement, parent: HTMLElement | null): void {\n const virtualChild = <IVirtualElement>child;\n const virtualParent = <IVirtualElement | null>parent;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {\n children: [],\n };\n }\n\n const oldParent = virtualChild._virtual.parent;\n\n if (oldParent && oldParent !== parent) {\n // Remove the child from its old parent.\n const index = oldParent._virtual.children.indexOf(virtualChild);\n\n if (index > -1) {\n oldParent._virtual.children.splice(index, 1);\n }\n }\n\n virtualChild._virtual.parent = virtualParent || undefined;\n\n if (virtualParent) {\n if (!virtualParent._virtual) {\n virtualParent._virtual = {\n children: [],\n };\n }\n\n virtualParent._virtual.children.push(virtualChild);\n }\n}\n"]}
+1
View File
@@ -0,0 +1 @@
export {};
+7
View File
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Do not modify this file; it is generated as part of publish.
// The checked in version is a placeholder only and will not be updated.
var set_version_1 = require("@fluentui/set-version");
(0, set_version_1.setVersion)('@fluentui/dom-utilities', '2.3.10');
//# sourceMappingURL=version.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"../src/","sources":["version.ts"],"names":[],"mappings":";;AAAA,+DAA+D;AAC/D,wEAAwE;AACxE,qDAAmD;AACnD,IAAA,wBAAU,EAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Do not modify this file; it is generated as part of publish.\n// The checked in version is a placeholder only and will not be updated.\nimport { setVersion } from '@fluentui/set-version';\nsetVersion('@fluentui/dom-utilities', '2.3.10');"]}