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[];
};
}
+5
View File
@@ -0,0 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});
//# sourceMappingURL=IVirtualElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IVirtualElement.js","sourceRoot":"../src/","sources":["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;
+40
View File
@@ -0,0 +1,40 @@
define(["require", "exports", "./getParent"], function (require, exports, getParent_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContains = void 0;
/**
* 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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"elementContains.js","sourceRoot":"../src/","sources":["elementContains.ts"],"names":[],"mappings":";;;;IACA;;;;;;OAMG;IACH,SAAgB,eAAe,CAC7B,MAA0B,EAC1B,KAAyB,EACzB,mBAAmC;QAAnC,oCAAA,EAAA,0BAAmC;QAEnC,IAAI,WAAW,GAAG,KAAK,CAAC;QAExB,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;YACpB,IAAI,mBAAmB,EAAE,CAAC;gBACxB,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;oBACrB,WAAW,GAAG,IAAI,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACN,WAAW,GAAG,KAAK,CAAC;oBAEpB,OAAO,KAAK,EAAE,CAAC;wBACb,IAAM,UAAU,GAAuB,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;wBAExD,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;4BAC1B,WAAW,GAAG,IAAI,CAAC;4BACnB,MAAM;wBACR,CAAC;wBAED,KAAK,GAAG,UAAU,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC3B,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IA/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,17 @@
define(["require", "exports", "./findElementRecursive"], function (require, exports, findElementRecursive_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementContainsAttribute = void 0;
/**
* 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":";;;;IAEA;;;;;OAKG;IACH,SAAgB,wBAAwB,CAAC,OAAoB,EAAE,SAAiB,EAAE,GAAc;QAC9F,IAAM,YAAY,GAAG,IAAA,2CAAoB,EACvC,OAAO,EACP,UAAC,WAAwB,IAAK,OAAA,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,EAAnC,CAAmC,EACjE,GAAG,CACJ,CAAC;QAEF,OAAO,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;IARD,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;
+21
View File
@@ -0,0 +1,21 @@
define(["require", "exports", "./getParent"], function (require, exports, getParent_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findElementRecursive = void 0;
/**
* 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":";;;;IACA;;;;;OAKG;IACH,SAAgB,oBAAoB,CAClC,OAA2B,EAC3B,aAAgD,EAChD,GAAc;QAEd,iDAAiD;QACjD,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,QAAQ,EAAC;QACjB,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,GAAG,CAAC,IAAI,IAAI,OAAO,YAAY,QAAQ,EAAE,CAAC;YACpE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAA,qBAAS,EAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;IACpG,CAAC;IAXD,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"]}
+1
View File
@@ -0,0 +1 @@
export declare const getActiveElement: (doc: Document) => Element | null;
+14
View File
@@ -0,0 +1,14 @@
define(["require", "exports"], function (require, exports) {
"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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getActiveElement.js","sourceRoot":"../src/","sources":["getActiveElement.ts"],"names":[],"mappings":";;;;IAAO,IAAM,gBAAgB,GAAG,UAAC,GAAa;QAC5C,IAAI,EAAE,GAAG,GAAG,CAAC,aAAa,CAAC;QAE3B,OAAO,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,UAAU,EAAE,CAAC;YACtB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;QACnC,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IARW,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[];
+27
View File
@@ -0,0 +1,27 @@
define(["require", "exports", "./isVirtualElement"], function (require, exports, isVirtualElement_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildren = void 0;
/**
* 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":";;;;IACA;;;;;;OAMG;IACH,SAAgB,WAAW,CAAC,MAAmB,EAAE,oBAAoC;QAApC,qCAAA,EAAA,2BAAoC;QACnF,IAAM,QAAQ,GAAkB,EAAE,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAgB,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,oBAAoB,IAAI,IAAA,mCAAgB,EAAC,MAAM,CAAC,EAAE,CAAC;gBACrD,QAAQ,CAAC,IAAI,OAAb,QAAQ,EAAS,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAC7C,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAXD,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"]}
+1
View File
@@ -0,0 +1 @@
export declare const getEventTarget: (event: Event) => HTMLElement | null;
+14
View File
@@ -0,0 +1,14 @@
define(["require", "exports"], function (require, exports) {
"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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getEventTarget.js","sourceRoot":"../src/","sources":["getEventTarget.ts"],"names":[],"mappings":";;;;IAAO,IAAM,cAAc,GAAG,UAAC,KAAY;QACzC,IAAI,MAAM,GAAG,KAAK,CAAC,MAAqB,CAAC;QACzC,IAAI,MAAM,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YAChC,MAAM,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAgB,CAAC;QAClD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAPW,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;
+38
View File
@@ -0,0 +1,38 @@
define(["require", "exports", "./getVirtualParent"], function (require, exports, getVirtualParent_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParent = void 0;
/**
* 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":";;;;IACA;;;;;;OAMG;IACH,SAAgB,SAAS,CAAC,KAAkB,EAAE,mBAAmC;;QAAnC,oCAAA,EAAA,0BAAmC;QAC/E,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAM,MAAM,GAAG,mBAAmB,IAAI,IAAA,mCAAgB,EAAC,KAAK,CAAC,CAAC;QAE9D,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,4CAA4C;QAC5C,IAAI,OAAQ,KAAyB,CAAC,gBAAgB,KAAK,UAAU,KAAI,MAAA,KAAK,CAAC,YAAY,0CAAE,UAAU,CAAA,EAAE,CAAC;YACxG,qBAAqB;YACrB,OAAO,KAAK,CAAC,YAA2B,CAAC;QAC3C,CAAC;aAAM,IAAI,CAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,QAAQ,MAAK,EAAE,EAAE,CAAC;YAC7C,mCAAmC;YACnC,4BAA4B;YAC5B,OAAQ,KAAK,CAAC,UAAyB,CAAC,IAAmB,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC,UAAyB,CAAC;QACzC,CAAC;IACH,CAAC;IAtBD,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"]}
+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;
+19
View File
@@ -0,0 +1,19 @@
define(["require", "exports", "./isVirtualElement"], function (require, exports, isVirtualElement_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVirtualParent = void 0;
/**
* 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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getVirtualParent.js","sourceRoot":"../src/","sources":["getVirtualParent.ts"],"names":[],"mappings":";;;;IACA;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,KAAkB;QACjD,IAAI,MAA+B,CAAC;QACpC,IAAI,KAAK,IAAI,IAAA,mCAAgB,EAAC,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACjC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAND,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';
+19
View File
@@ -0,0 +1,19 @@
define(["require", "exports", "./elementContains", "./elementContainsAttribute", "./findElementRecursive", "./getActiveElement", "./getChildren", "./getEventTarget", "./getParent", "./getVirtualParent", "./isVirtualElement", "./portalContainsElement", "./setPortalAttribute", "./setVirtualParent", "./version"], function (require, exports, elementContains_1, elementContainsAttribute_1, findElementRecursive_1, getActiveElement_1, getChildren_1, getEventTarget_1, getParent_1, getVirtualParent_1, isVirtualElement_1, portalContainsElement_1, setPortalAttribute_1, setVirtualParent_1) {
"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;
Object.defineProperty(exports, "elementContains", { enumerable: true, get: function () { return elementContains_1.elementContains; } });
Object.defineProperty(exports, "elementContainsAttribute", { enumerable: true, get: function () { return elementContainsAttribute_1.elementContainsAttribute; } });
Object.defineProperty(exports, "findElementRecursive", { enumerable: true, get: function () { return findElementRecursive_1.findElementRecursive; } });
Object.defineProperty(exports, "getActiveElement", { enumerable: true, get: function () { return getActiveElement_1.getActiveElement; } });
Object.defineProperty(exports, "getChildren", { enumerable: true, get: function () { return getChildren_1.getChildren; } });
Object.defineProperty(exports, "getEventTarget", { enumerable: true, get: function () { return getEventTarget_1.getEventTarget; } });
Object.defineProperty(exports, "getParent", { enumerable: true, get: function () { return getParent_1.getParent; } });
Object.defineProperty(exports, "getVirtualParent", { enumerable: true, get: function () { return getVirtualParent_1.getVirtualParent; } });
Object.defineProperty(exports, "isVirtualElement", { enumerable: true, get: function () { return isVirtualElement_1.isVirtualElement; } });
Object.defineProperty(exports, "portalContainsElement", { enumerable: true, get: function () { return portalContainsElement_1.portalContainsElement; } });
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; } });
Object.defineProperty(exports, "setVirtualParent", { enumerable: true, get: function () { return setVirtualParent_1.setVirtualParent; } });
});
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;;IACS,kHAAA,eAAe,OAAA;IACf,oIAAA,wBAAwB,OAAA;IACxB,4HAAA,oBAAoB,OAAA;IACpB,oHAAA,gBAAgB,OAAA;IAChB,0GAAA,WAAW,OAAA;IACX,gHAAA,cAAc,OAAA;IACd,sGAAA,SAAS,OAAA;IACT,oHAAA,gBAAgB,OAAA;IAChB,oHAAA,gBAAgB,OAAA;IAChB,8HAAA,qBAAqB,OAAA;IACrB,2HAAA,qBAAqB,OAAA;IAAE,wHAAA,kBAAkB,OAAA;IACzC,oHAAA,gBAAgB,OAAA","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;
+15
View File
@@ -0,0 +1,15 @@
define(["require", "exports"], function (require, exports) {
"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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"isVirtualElement.js","sourceRoot":"../src/","sources":["isVirtualElement.ts"],"names":[],"mappings":";;;;IACA;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,OAAsC;QACrE,OAAO,OAAO,IAAI,CAAC,CAAmB,OAAQ,CAAC,QAAQ,CAAC;IAC1D,CAAC;IAFD,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;
+20
View File
@@ -0,0 +1,20 @@
define(["require", "exports", "./findElementRecursive", "./setPortalAttribute"], function (require, exports, findElementRecursive_1, setPortalAttribute_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.portalContainsElement = void 0;
/**
* 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":";;;;IAGA;;;;;;;OAOG;IACH,SAAgB,qBAAqB,CAAC,MAAmB,EAAE,MAAoB,EAAE,GAAc;;QAC7F,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;QACF,OAAO,YAAY,KAAK,IAAI,IAAI,CAAC,CAAC,CAAA,MAAA,YAAY,CAAC,YAAY,6DAAG,0CAAqB,CAAC,CAAA,CAAC;IACvF,CAAC;IAPD,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"]}
+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;
+15
View File
@@ -0,0 +1,15 @@
define(["require", "exports"], function (require, exports) {
"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":";;;;IAAa,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;IAE3D;;;OAGG;IACH,SAAgB,kBAAkB,CAAC,OAAoB;QACrD,OAAO,CAAC,YAAY,CAAC,6BAAqB,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;IAFD,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"]}
+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;
+39
View File
@@ -0,0 +1,39 @@
define(["require", "exports"], function (require, exports) {
"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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setVirtualParent.js","sourceRoot":"../src/","sources":["setVirtualParent.ts"],"names":[],"mappings":";;;;IACA;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,KAAkB,EAAE,MAA0B;QAC7E,IAAM,YAAY,GAAoB,KAAK,CAAC;QAC5C,IAAM,aAAa,GAA2B,MAAM,CAAC;QAErD,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,QAAQ,GAAG;gBACtB,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QAED,IAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;QAE/C,IAAI,SAAS,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YACtC,wCAAwC;YACxC,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAEhE,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;gBACf,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QAED,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,aAAa,IAAI,SAAS,CAAC;QAE1D,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;gBAC5B,aAAa,CAAC,QAAQ,GAAG;oBACvB,QAAQ,EAAE,EAAE;iBACb,CAAC;YACJ,CAAC;YAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAhCD,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 {};
+6
View File
@@ -0,0 +1,6 @@
define(["require", "exports", "@fluentui/set-version"], function (require, exports, set_version_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
(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":";;;IAGA,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');"]}