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[];
};
}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IVirtualElement.js.map
+1
View File
@@ -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"]}
+8
View File
@@ -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;
+35
View File
@@ -0,0 +1,35 @@
import { getParent } from './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
*/
export 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 = getParent(child);
if (nextParent === parent) {
isContained = true;
break;
}
child = nextParent;
}
}
}
else if (parent.contains) {
isContained = parent.contains(child);
}
}
return isContained;
}
//# sourceMappingURL=elementContains.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"elementContains.js","sourceRoot":"../src/","sources":["elementContains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;;;;GAMG;AACH,MAAM,UAAU,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,SAAS,CAAC,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","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;
+12
View File
@@ -0,0 +1,12 @@
import { findElementRecursive } from './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
*/
export function elementContainsAttribute(element, attribute, doc) {
var elementMatch = findElementRecursive(element, function (testElement) { return testElement.hasAttribute(attribute); }, doc);
return elementMatch && elementMatch.getAttribute(attribute);
}
//# sourceMappingURL=elementContainsAttribute.js.map
@@ -0,0 +1 @@
{"version":3,"file":"elementContainsAttribute.js","sourceRoot":"../src/","sources":["elementContainsAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAoB,EAAE,SAAiB,EAAE,GAAc;IAC9F,IAAM,YAAY,GAAG,oBAAoB,CACvC,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","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"]}
+7
View File
@@ -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;
+16
View File
@@ -0,0 +1,16 @@
import { getParent } from './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
*/
export 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(getParent(element), matchFunction);
}
//# sourceMappingURL=findElementRecursive.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"findElementRecursive.js","sourceRoot":"../src/","sources":["findElementRecursive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;;;GAKG;AACH,MAAM,UAAU,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,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;AACpG,CAAC","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"]}
+1
View File
@@ -0,0 +1 @@
export declare const getActiveElement: (doc: Document) => Element | null;
+8
View File
@@ -0,0 +1,8 @@
export var getActiveElement = function (doc) {
var ae = doc.activeElement;
while (ae === null || ae === void 0 ? void 0 : ae.shadowRoot) {
ae = ae.shadowRoot.activeElement;
}
return ae;
};
//# sourceMappingURL=getActiveElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getActiveElement.js","sourceRoot":"../src/","sources":["getActiveElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,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","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[];
+22
View File
@@ -0,0 +1,22 @@
import { isVirtualElement } from './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.
*/
export 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 && isVirtualElement(parent)) {
children.push.apply(children, parent._virtual.children);
}
}
return children;
}
//# sourceMappingURL=getChildren.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getChildren.js","sourceRoot":"../src/","sources":["getChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD;;;;;;GAMG;AACH,MAAM,UAAU,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,gBAAgB,CAAC,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","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"]}
+1
View File
@@ -0,0 +1 @@
export declare const getEventTarget: (event: Event) => HTMLElement | null;
+8
View File
@@ -0,0 +1,8 @@
export var getEventTarget = function (event) {
var target = event.target;
if (target && target.shadowRoot) {
target = event.composedPath()[0];
}
return target;
};
//# sourceMappingURL=getEventTarget.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getEventTarget.js","sourceRoot":"../src/","sources":["getEventTarget.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,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","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;
+33
View File
@@ -0,0 +1,33 @@
import { getVirtualParent } from './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
*/
export function getParent(child, allowVirtualParents) {
var _a, _b;
if (allowVirtualParents === void 0) { allowVirtualParents = true; }
if (!child) {
return null;
}
var parent = allowVirtualParents && 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;
}
}
//# sourceMappingURL=getParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getParent.js","sourceRoot":"../src/","sources":["getParent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD;;;;;;GAMG;AACH,MAAM,UAAU,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,gBAAgB,CAAC,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","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"]}
+6
View File
@@ -0,0 +1,6 @@
/**
* Gets the virtual parent given the child element, if it exists.
*
* @public
*/
export declare function getVirtualParent(child: HTMLElement): HTMLElement | undefined;
+14
View File
@@ -0,0 +1,14 @@
import { isVirtualElement } from './isVirtualElement';
/**
* Gets the virtual parent given the child element, if it exists.
*
* @public
*/
export function getVirtualParent(child) {
var parent;
if (child && isVirtualElement(child)) {
parent = child._virtual.parent;
}
return parent;
}
//# sourceMappingURL=getVirtualParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getVirtualParent.js","sourceRoot":"../src/","sources":["getVirtualParent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAkB;IACjD,IAAI,MAA+B,CAAC;IACpC,IAAI,KAAK,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","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';
+14
View File
@@ -0,0 +1,14 @@
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';
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,WAAW,CAAC","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"]}
+7
View File
@@ -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;
+9
View File
@@ -0,0 +1,9 @@
/**
* Determines whether or not an element has the virtual hierarchy extension.
*
* @public
*/
export function isVirtualElement(element) {
return element && !!element._virtual;
}
//# sourceMappingURL=isVirtualElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"isVirtualElement.js","sourceRoot":"../src/","sources":["isVirtualElement.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAsC;IACrE,OAAO,OAAO,IAAI,CAAC,CAAmB,OAAQ,CAAC,QAAQ,CAAC;AAC1D,CAAC","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"]}
+9
View File
@@ -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;
+16
View File
@@ -0,0 +1,16 @@
import { findElementRecursive } from './findElementRecursive';
import { DATA_PORTAL_ATTRIBUTE } from './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.)
*/
export function portalContainsElement(target, parent, doc) {
var _a;
var elementMatch = findElementRecursive(target, function (testElement) { var _a; return parent === testElement || !!((_a = testElement.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(testElement, DATA_PORTAL_ATTRIBUTE)); }, doc);
return elementMatch !== null && !!((_a = elementMatch.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(elementMatch, DATA_PORTAL_ATTRIBUTE));
}
//# sourceMappingURL=portalContainsElement.js.map
@@ -0,0 +1 @@
{"version":3,"file":"portalContainsElement.js","sourceRoot":"../src/","sources":["portalContainsElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAmB,EAAE,MAAoB,EAAE,GAAc;;IAC7F,IAAM,YAAY,GAAG,oBAAoB,CACvC,MAAM,EACN,UAAC,WAAwB,YAAK,OAAA,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,CAAA,MAAA,WAAW,CAAC,YAAY,4DAAG,qBAAqB,CAAC,CAAA,CAAA,EAAA,EAC3G,GAAG,CACJ,CAAC;IACF,OAAO,YAAY,KAAK,IAAI,IAAI,CAAC,CAAC,CAAA,MAAA,YAAY,CAAC,YAAY,6DAAG,qBAAqB,CAAC,CAAA,CAAC;AACvF,CAAC","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"]}
+6
View File
@@ -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;
+9
View File
@@ -0,0 +1,9 @@
export var DATA_PORTAL_ATTRIBUTE = 'data-portal-element';
/**
* Identify element as a portal by setting an attribute.
* @param element - Element to mark as a portal.
*/
export function setPortalAttribute(element) {
element.setAttribute(DATA_PORTAL_ATTRIBUTE, 'true');
}
//# sourceMappingURL=setPortalAttribute.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setPortalAttribute.js","sourceRoot":"../src/","sources":["setPortalAttribute.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,OAAO,CAAC,YAAY,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","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"]}
+7
View File
@@ -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;
+33
View File
@@ -0,0 +1,33 @@
/**
* Sets the virtual parent of an element.
* Pass `undefined` as the `parent` to clear the virtual parent.
*
* @public
*/
export 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);
}
}
//# sourceMappingURL=setVirtualParent.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setVirtualParent.js","sourceRoot":"../src/","sources":["setVirtualParent.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,MAAM,UAAU,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","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 {};
+5
View File
@@ -0,0 +1,5 @@
// 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.
import { setVersion } from '@fluentui/set-version';
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,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,UAAU,CAAC,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');"]}