gdpr audit implemented, email log, vollmachten, pdf delete cancel data privacy and vollmachten, removed message no id card in engergy car, and other contracts that are not telecom contracts, added insert counter for engery
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
||||
export declare type AlignedPlacement = `${Side}-${Alignment}`;
|
||||
|
||||
export declare type Alignment = 'start' | 'end';
|
||||
|
||||
export declare const alignments: Alignment[];
|
||||
|
||||
export declare type Axis = 'x' | 'y';
|
||||
|
||||
export declare function clamp(start: number, value: number, end: number): number;
|
||||
|
||||
export declare type ClientRectObject = Prettify<Rect & SideObject>;
|
||||
|
||||
export declare type Coords = {
|
||||
[key in Axis]: number;
|
||||
};
|
||||
|
||||
export declare const createCoords: (v: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
export declare type Dimensions = {
|
||||
[key in Length]: number;
|
||||
};
|
||||
|
||||
export declare interface ElementRects {
|
||||
reference: Rect;
|
||||
floating: Rect;
|
||||
}
|
||||
|
||||
export declare function evaluate<T, P>(value: T | ((param: P) => T), param: P): T;
|
||||
|
||||
export declare function expandPaddingObject(padding: Partial<SideObject>): SideObject;
|
||||
|
||||
export declare const floor: (x: number) => number;
|
||||
|
||||
export declare function getAlignment(placement: Placement): Alignment | undefined;
|
||||
|
||||
export declare function getAlignmentAxis(placement: Placement): Axis;
|
||||
|
||||
export declare function getAlignmentSides(placement: Placement, rects: ElementRects, rtl?: boolean): [Side, Side];
|
||||
|
||||
export declare function getAxisLength(axis: Axis): Length;
|
||||
|
||||
export declare function getExpandedPlacements(placement: Placement): Array<Placement>;
|
||||
|
||||
export declare function getOppositeAlignmentPlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getOppositeAxis(axis: Axis): Axis;
|
||||
|
||||
export declare function getOppositeAxisPlacements(placement: Placement, flipAlignment: boolean, direction: 'none' | Alignment, rtl?: boolean): Placement[];
|
||||
|
||||
export declare function getOppositePlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getPaddingObject(padding: Padding): SideObject;
|
||||
|
||||
export declare function getSide(placement: Placement): Side;
|
||||
|
||||
export declare function getSideAxis(placement: Placement): Axis;
|
||||
|
||||
export declare type Length = 'width' | 'height';
|
||||
|
||||
export declare const max: (...values: number[]) => number;
|
||||
|
||||
export declare const min: (...values: number[]) => number;
|
||||
|
||||
export declare type Padding = number | Prettify<Partial<SideObject>>;
|
||||
|
||||
export declare type Placement = Prettify<Side | AlignedPlacement>;
|
||||
|
||||
export declare const placements: Placement[];
|
||||
|
||||
declare type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
export declare type Rect = Prettify<Coords & Dimensions>;
|
||||
|
||||
export declare function rectToClientRect(rect: Rect): ClientRectObject;
|
||||
|
||||
export declare const round: (x: number) => number;
|
||||
|
||||
export declare type Side = 'top' | 'right' | 'bottom' | 'left';
|
||||
|
||||
export declare type SideObject = {
|
||||
[key in Side]: number;
|
||||
};
|
||||
|
||||
export declare const sides: Side[];
|
||||
|
||||
export declare type Strategy = 'absolute' | 'fixed';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
export declare interface VirtualElement {
|
||||
getBoundingClientRect(): ClientRectObject;
|
||||
getClientRects?(): Array<ClientRectObject>;
|
||||
contextElement?: any;
|
||||
}
|
||||
|
||||
export { }
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
export declare type AlignedPlacement = `${Side}-${Alignment}`;
|
||||
|
||||
export declare type Alignment = 'start' | 'end';
|
||||
|
||||
export declare const alignments: Alignment[];
|
||||
|
||||
export declare type Axis = 'x' | 'y';
|
||||
|
||||
export declare function clamp(start: number, value: number, end: number): number;
|
||||
|
||||
export declare type ClientRectObject = Prettify<Rect & SideObject>;
|
||||
|
||||
export declare type Coords = {
|
||||
[key in Axis]: number;
|
||||
};
|
||||
|
||||
export declare const createCoords: (v: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
export declare type Dimensions = {
|
||||
[key in Length]: number;
|
||||
};
|
||||
|
||||
export declare interface ElementRects {
|
||||
reference: Rect;
|
||||
floating: Rect;
|
||||
}
|
||||
|
||||
export declare function evaluate<T, P>(value: T | ((param: P) => T), param: P): T;
|
||||
|
||||
export declare function expandPaddingObject(padding: Partial<SideObject>): SideObject;
|
||||
|
||||
export declare const floor: (x: number) => number;
|
||||
|
||||
export declare function getAlignment(placement: Placement): Alignment | undefined;
|
||||
|
||||
export declare function getAlignmentAxis(placement: Placement): Axis;
|
||||
|
||||
export declare function getAlignmentSides(placement: Placement, rects: ElementRects, rtl?: boolean): [Side, Side];
|
||||
|
||||
export declare function getAxisLength(axis: Axis): Length;
|
||||
|
||||
export declare function getExpandedPlacements(placement: Placement): Array<Placement>;
|
||||
|
||||
export declare function getOppositeAlignmentPlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getOppositeAxis(axis: Axis): Axis;
|
||||
|
||||
export declare function getOppositeAxisPlacements(placement: Placement, flipAlignment: boolean, direction: 'none' | Alignment, rtl?: boolean): Placement[];
|
||||
|
||||
export declare function getOppositePlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getPaddingObject(padding: Padding): SideObject;
|
||||
|
||||
export declare function getSide(placement: Placement): Side;
|
||||
|
||||
export declare function getSideAxis(placement: Placement): Axis;
|
||||
|
||||
export declare type Length = 'width' | 'height';
|
||||
|
||||
export declare const max: (...values: number[]) => number;
|
||||
|
||||
export declare const min: (...values: number[]) => number;
|
||||
|
||||
export declare type Padding = number | Prettify<Partial<SideObject>>;
|
||||
|
||||
export declare type Placement = Prettify<Side | AlignedPlacement>;
|
||||
|
||||
export declare const placements: Placement[];
|
||||
|
||||
declare type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
export declare type Rect = Prettify<Coords & Dimensions>;
|
||||
|
||||
export declare function rectToClientRect(rect: Rect): ClientRectObject;
|
||||
|
||||
export declare const round: (x: number) => number;
|
||||
|
||||
export declare type Side = 'top' | 'right' | 'bottom' | 'left';
|
||||
|
||||
export declare type SideObject = {
|
||||
[key in Side]: number;
|
||||
};
|
||||
|
||||
export declare const sides: Side[];
|
||||
|
||||
export declare type Strategy = 'absolute' | 'fixed';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
export declare interface VirtualElement {
|
||||
getBoundingClientRect(): ClientRectObject;
|
||||
getClientRects?(): Array<ClientRectObject>;
|
||||
contextElement?: any;
|
||||
}
|
||||
|
||||
export { }
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
declare function getComputedStyle_2(element: Element): CSSStyleDeclaration;
|
||||
export { getComputedStyle_2 as getComputedStyle }
|
||||
|
||||
export declare function getContainingBlock(element: Element): HTMLElement | null;
|
||||
|
||||
export declare function getDocumentElement(node: Node | Window): HTMLElement;
|
||||
|
||||
export declare function getFrameElement(win: Window): Element | null;
|
||||
|
||||
export declare function getNearestOverflowAncestor(node: Node): HTMLElement;
|
||||
|
||||
export declare function getNodeName(node: Node | Window): string;
|
||||
|
||||
export declare function getNodeScroll(element: Element | Window): {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
|
||||
export declare function getOverflowAncestors(node: Node, list?: OverflowAncestors, traverseIframes?: boolean): OverflowAncestors;
|
||||
|
||||
export declare function getParentNode(node: Node): Node;
|
||||
|
||||
export declare function getWindow(node: any): typeof window;
|
||||
|
||||
export declare function isContainingBlock(elementOrCss: Element | CSSStyleDeclaration): boolean;
|
||||
|
||||
export declare function isElement(value: unknown): value is Element;
|
||||
|
||||
export declare function isHTMLElement(value: unknown): value is HTMLElement;
|
||||
|
||||
export declare function isLastTraversableNode(node: Node): boolean;
|
||||
|
||||
export declare function isNode(value: unknown): value is Node;
|
||||
|
||||
export declare function isOverflowElement(element: Element): boolean;
|
||||
|
||||
export declare function isShadowRoot(value: unknown): value is ShadowRoot;
|
||||
|
||||
export declare function isTableElement(element: Element): boolean;
|
||||
|
||||
export declare function isTopLayer(element: Element): boolean;
|
||||
|
||||
export declare function isWebKit(): boolean;
|
||||
|
||||
declare type OverflowAncestors = Array<Element | Window | VisualViewport>;
|
||||
|
||||
export { }
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
declare function getComputedStyle_2(element: Element): CSSStyleDeclaration;
|
||||
export { getComputedStyle_2 as getComputedStyle }
|
||||
|
||||
export declare function getContainingBlock(element: Element): HTMLElement | null;
|
||||
|
||||
export declare function getDocumentElement(node: Node | Window): HTMLElement;
|
||||
|
||||
export declare function getFrameElement(win: Window): Element | null;
|
||||
|
||||
export declare function getNearestOverflowAncestor(node: Node): HTMLElement;
|
||||
|
||||
export declare function getNodeName(node: Node | Window): string;
|
||||
|
||||
export declare function getNodeScroll(element: Element | Window): {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
|
||||
export declare function getOverflowAncestors(node: Node, list?: OverflowAncestors, traverseIframes?: boolean): OverflowAncestors;
|
||||
|
||||
export declare function getParentNode(node: Node): Node;
|
||||
|
||||
export declare function getWindow(node: any): typeof window;
|
||||
|
||||
export declare function isContainingBlock(elementOrCss: Element | CSSStyleDeclaration): boolean;
|
||||
|
||||
export declare function isElement(value: unknown): value is Element;
|
||||
|
||||
export declare function isHTMLElement(value: unknown): value is HTMLElement;
|
||||
|
||||
export declare function isLastTraversableNode(node: Node): boolean;
|
||||
|
||||
export declare function isNode(value: unknown): value is Node;
|
||||
|
||||
export declare function isOverflowElement(element: Element): boolean;
|
||||
|
||||
export declare function isShadowRoot(value: unknown): value is ShadowRoot;
|
||||
|
||||
export declare function isTableElement(element: Element): boolean;
|
||||
|
||||
export declare function isTopLayer(element: Element): boolean;
|
||||
|
||||
export declare function isWebKit(): boolean;
|
||||
|
||||
declare type OverflowAncestors = Array<Element | Window | VisualViewport>;
|
||||
|
||||
export { }
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
export { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
export { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIUtilsDOM = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
exports.getComputedStyle = getComputedStyle;
|
||||
exports.getContainingBlock = getContainingBlock;
|
||||
exports.getDocumentElement = getDocumentElement;
|
||||
exports.getFrameElement = getFrameElement;
|
||||
exports.getNearestOverflowAncestor = getNearestOverflowAncestor;
|
||||
exports.getNodeName = getNodeName;
|
||||
exports.getNodeScroll = getNodeScroll;
|
||||
exports.getOverflowAncestors = getOverflowAncestors;
|
||||
exports.getParentNode = getParentNode;
|
||||
exports.getWindow = getWindow;
|
||||
exports.isContainingBlock = isContainingBlock;
|
||||
exports.isElement = isElement;
|
||||
exports.isHTMLElement = isHTMLElement;
|
||||
exports.isLastTraversableNode = isLastTraversableNode;
|
||||
exports.isNode = isNode;
|
||||
exports.isOverflowElement = isOverflowElement;
|
||||
exports.isShadowRoot = isShadowRoot;
|
||||
exports.isTableElement = isTableElement;
|
||||
exports.isTopLayer = isTopLayer;
|
||||
exports.isWebKit = isWebKit;
|
||||
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIUtilsDOM={})}(this,(function(e){"use strict";function n(){return"undefined"!=typeof window}function t(e){return i(e)?(e.nodeName||"").toLowerCase():"#document"}function o(e){var n;return(null==e||null==(n=e.ownerDocument)?void 0:n.defaultView)||window}function r(e){var n;return null==(n=(i(e)?e.ownerDocument:e.document)||window.document)?void 0:n.documentElement}function i(e){return!!n()&&(e instanceof Node||e instanceof o(e).Node)}function c(e){return!!n()&&(e instanceof Element||e instanceof o(e).Element)}function l(e){return!!n()&&(e instanceof HTMLElement||e instanceof o(e).HTMLElement)}function s(e){return!(!n()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof o(e).ShadowRoot)}const u=new Set(["inline","contents"]);function a(e){const{overflow:n,overflowX:t,overflowY:o,display:r}=b(e);return/auto|scroll|overlay|hidden|clip/.test(n+o+t)&&!u.has(r)}const f=new Set(["table","td","th"]);const d=[":popover-open",":modal"];function m(e){return d.some((n=>{try{return e.matches(n)}catch(e){return!1}}))}const p=["transform","translate","scale","rotate","perspective"],w=["transform","translate","scale","rotate","perspective","filter"],y=["paint","layout","strict","content"];function v(e){const n=g(),t=c(e)?b(e):e;return p.some((e=>!!t[e]&&"none"!==t[e]))||!!t.containerType&&"normal"!==t.containerType||!n&&!!t.backdropFilter&&"none"!==t.backdropFilter||!n&&!!t.filter&&"none"!==t.filter||w.some((e=>(t.willChange||"").includes(e)))||y.some((e=>(t.contain||"").includes(e)))}function g(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const h=new Set(["html","body","#document"]);function S(e){return h.has(t(e))}function b(e){return o(e).getComputedStyle(e)}function T(e){if("html"===t(e))return e;const n=e.assignedSlot||e.parentNode||s(e)&&e.host||r(e);return s(n)?n.host:n}function E(e){const n=T(e);return S(n)?e.ownerDocument?e.ownerDocument.body:e.body:l(n)&&a(n)?n:E(n)}function N(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}e.getComputedStyle=b,e.getContainingBlock=function(e){let n=T(e);for(;l(n)&&!S(n);){if(v(n))return n;if(m(n))return null;n=T(n)}return null},e.getDocumentElement=r,e.getFrameElement=N,e.getNearestOverflowAncestor=E,e.getNodeName=t,e.getNodeScroll=function(e){return c(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}},e.getOverflowAncestors=function e(n,t,r){var i;void 0===t&&(t=[]),void 0===r&&(r=!0);const c=E(n),l=c===(null==(i=n.ownerDocument)?void 0:i.body),s=o(c);if(l){const n=N(s);return t.concat(s,s.visualViewport||[],a(c)?c:[],n&&r?e(n):[])}return t.concat(c,e(c,[],r))},e.getParentNode=T,e.getWindow=o,e.isContainingBlock=v,e.isElement=c,e.isHTMLElement=l,e.isLastTraversableNode=S,e.isNode=i,e.isOverflowElement=a,e.isShadowRoot=s,e.isTableElement=function(e){return f.has(t(e))},e.isTopLayer=m,e.isWebKit=g}));
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const sides = ['top', 'right', 'bottom', 'left'];
|
||||
const alignments = ['start', 'end'];
|
||||
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
const oppositeSideMap = {
|
||||
left: 'right',
|
||||
right: 'left',
|
||||
bottom: 'top',
|
||||
top: 'bottom'
|
||||
};
|
||||
const oppositeAlignmentMap = {
|
||||
start: 'end',
|
||||
end: 'start'
|
||||
};
|
||||
function clamp(start, value, end) {
|
||||
return max(start, min(value, end));
|
||||
}
|
||||
function evaluate(value, param) {
|
||||
return typeof value === 'function' ? value(param) : value;
|
||||
}
|
||||
function getSide(placement) {
|
||||
return placement.split('-')[0];
|
||||
}
|
||||
function getAlignment(placement) {
|
||||
return placement.split('-')[1];
|
||||
}
|
||||
function getOppositeAxis(axis) {
|
||||
return axis === 'x' ? 'y' : 'x';
|
||||
}
|
||||
function getAxisLength(axis) {
|
||||
return axis === 'y' ? 'height' : 'width';
|
||||
}
|
||||
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
||||
function getSideAxis(placement) {
|
||||
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
||||
}
|
||||
function getAlignmentAxis(placement) {
|
||||
return getOppositeAxis(getSideAxis(placement));
|
||||
}
|
||||
function getAlignmentSides(placement, rects, rtl) {
|
||||
if (rtl === void 0) {
|
||||
rtl = false;
|
||||
}
|
||||
const alignment = getAlignment(placement);
|
||||
const alignmentAxis = getAlignmentAxis(placement);
|
||||
const length = getAxisLength(alignmentAxis);
|
||||
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
||||
if (rects.reference[length] > rects.floating[length]) {
|
||||
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
||||
}
|
||||
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
||||
}
|
||||
function getExpandedPlacements(placement) {
|
||||
const oppositePlacement = getOppositePlacement(placement);
|
||||
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
||||
}
|
||||
function getOppositeAlignmentPlacement(placement) {
|
||||
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
||||
}
|
||||
const lrPlacement = ['left', 'right'];
|
||||
const rlPlacement = ['right', 'left'];
|
||||
const tbPlacement = ['top', 'bottom'];
|
||||
const btPlacement = ['bottom', 'top'];
|
||||
function getSideList(side, isStart, rtl) {
|
||||
switch (side) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
||||
return isStart ? lrPlacement : rlPlacement;
|
||||
case 'left':
|
||||
case 'right':
|
||||
return isStart ? tbPlacement : btPlacement;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
||||
const alignment = getAlignment(placement);
|
||||
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
||||
if (alignment) {
|
||||
list = list.map(side => side + "-" + alignment);
|
||||
if (flipAlignment) {
|
||||
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function getOppositePlacement(placement) {
|
||||
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
||||
}
|
||||
function expandPaddingObject(padding) {
|
||||
return {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...padding
|
||||
};
|
||||
}
|
||||
function getPaddingObject(padding) {
|
||||
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
||||
top: padding,
|
||||
right: padding,
|
||||
bottom: padding,
|
||||
left: padding
|
||||
};
|
||||
}
|
||||
function rectToClientRect(rect) {
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = rect;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
top: y,
|
||||
left: x,
|
||||
right: x + width,
|
||||
bottom: y + height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
export { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const sides = ['top', 'right', 'bottom', 'left'];
|
||||
const alignments = ['start', 'end'];
|
||||
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
const oppositeSideMap = {
|
||||
left: 'right',
|
||||
right: 'left',
|
||||
bottom: 'top',
|
||||
top: 'bottom'
|
||||
};
|
||||
const oppositeAlignmentMap = {
|
||||
start: 'end',
|
||||
end: 'start'
|
||||
};
|
||||
function clamp(start, value, end) {
|
||||
return max(start, min(value, end));
|
||||
}
|
||||
function evaluate(value, param) {
|
||||
return typeof value === 'function' ? value(param) : value;
|
||||
}
|
||||
function getSide(placement) {
|
||||
return placement.split('-')[0];
|
||||
}
|
||||
function getAlignment(placement) {
|
||||
return placement.split('-')[1];
|
||||
}
|
||||
function getOppositeAxis(axis) {
|
||||
return axis === 'x' ? 'y' : 'x';
|
||||
}
|
||||
function getAxisLength(axis) {
|
||||
return axis === 'y' ? 'height' : 'width';
|
||||
}
|
||||
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
||||
function getSideAxis(placement) {
|
||||
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
||||
}
|
||||
function getAlignmentAxis(placement) {
|
||||
return getOppositeAxis(getSideAxis(placement));
|
||||
}
|
||||
function getAlignmentSides(placement, rects, rtl) {
|
||||
if (rtl === void 0) {
|
||||
rtl = false;
|
||||
}
|
||||
const alignment = getAlignment(placement);
|
||||
const alignmentAxis = getAlignmentAxis(placement);
|
||||
const length = getAxisLength(alignmentAxis);
|
||||
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
||||
if (rects.reference[length] > rects.floating[length]) {
|
||||
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
||||
}
|
||||
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
||||
}
|
||||
function getExpandedPlacements(placement) {
|
||||
const oppositePlacement = getOppositePlacement(placement);
|
||||
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
||||
}
|
||||
function getOppositeAlignmentPlacement(placement) {
|
||||
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
||||
}
|
||||
const lrPlacement = ['left', 'right'];
|
||||
const rlPlacement = ['right', 'left'];
|
||||
const tbPlacement = ['top', 'bottom'];
|
||||
const btPlacement = ['bottom', 'top'];
|
||||
function getSideList(side, isStart, rtl) {
|
||||
switch (side) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
||||
return isStart ? lrPlacement : rlPlacement;
|
||||
case 'left':
|
||||
case 'right':
|
||||
return isStart ? tbPlacement : btPlacement;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
||||
const alignment = getAlignment(placement);
|
||||
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
||||
if (alignment) {
|
||||
list = list.map(side => side + "-" + alignment);
|
||||
if (flipAlignment) {
|
||||
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function getOppositePlacement(placement) {
|
||||
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
||||
}
|
||||
function expandPaddingObject(padding) {
|
||||
return {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...padding
|
||||
};
|
||||
}
|
||||
function getPaddingObject(padding) {
|
||||
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
||||
top: padding,
|
||||
right: padding,
|
||||
bottom: padding,
|
||||
left: padding
|
||||
};
|
||||
}
|
||||
function rectToClientRect(rect) {
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = rect;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
top: y,
|
||||
left: x,
|
||||
right: x + width,
|
||||
bottom: y + height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
export { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIUtils = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const sides = ['top', 'right', 'bottom', 'left'];
|
||||
const alignments = ['start', 'end'];
|
||||
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
const oppositeSideMap = {
|
||||
left: 'right',
|
||||
right: 'left',
|
||||
bottom: 'top',
|
||||
top: 'bottom'
|
||||
};
|
||||
const oppositeAlignmentMap = {
|
||||
start: 'end',
|
||||
end: 'start'
|
||||
};
|
||||
function clamp(start, value, end) {
|
||||
return max(start, min(value, end));
|
||||
}
|
||||
function evaluate(value, param) {
|
||||
return typeof value === 'function' ? value(param) : value;
|
||||
}
|
||||
function getSide(placement) {
|
||||
return placement.split('-')[0];
|
||||
}
|
||||
function getAlignment(placement) {
|
||||
return placement.split('-')[1];
|
||||
}
|
||||
function getOppositeAxis(axis) {
|
||||
return axis === 'x' ? 'y' : 'x';
|
||||
}
|
||||
function getAxisLength(axis) {
|
||||
return axis === 'y' ? 'height' : 'width';
|
||||
}
|
||||
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
||||
function getSideAxis(placement) {
|
||||
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
||||
}
|
||||
function getAlignmentAxis(placement) {
|
||||
return getOppositeAxis(getSideAxis(placement));
|
||||
}
|
||||
function getAlignmentSides(placement, rects, rtl) {
|
||||
if (rtl === void 0) {
|
||||
rtl = false;
|
||||
}
|
||||
const alignment = getAlignment(placement);
|
||||
const alignmentAxis = getAlignmentAxis(placement);
|
||||
const length = getAxisLength(alignmentAxis);
|
||||
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
||||
if (rects.reference[length] > rects.floating[length]) {
|
||||
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
||||
}
|
||||
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
||||
}
|
||||
function getExpandedPlacements(placement) {
|
||||
const oppositePlacement = getOppositePlacement(placement);
|
||||
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
||||
}
|
||||
function getOppositeAlignmentPlacement(placement) {
|
||||
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
||||
}
|
||||
const lrPlacement = ['left', 'right'];
|
||||
const rlPlacement = ['right', 'left'];
|
||||
const tbPlacement = ['top', 'bottom'];
|
||||
const btPlacement = ['bottom', 'top'];
|
||||
function getSideList(side, isStart, rtl) {
|
||||
switch (side) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
||||
return isStart ? lrPlacement : rlPlacement;
|
||||
case 'left':
|
||||
case 'right':
|
||||
return isStart ? tbPlacement : btPlacement;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
||||
const alignment = getAlignment(placement);
|
||||
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
||||
if (alignment) {
|
||||
list = list.map(side => side + "-" + alignment);
|
||||
if (flipAlignment) {
|
||||
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function getOppositePlacement(placement) {
|
||||
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
||||
}
|
||||
function expandPaddingObject(padding) {
|
||||
return {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...padding
|
||||
};
|
||||
}
|
||||
function getPaddingObject(padding) {
|
||||
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
||||
top: padding,
|
||||
right: padding,
|
||||
bottom: padding,
|
||||
left: padding
|
||||
};
|
||||
}
|
||||
function rectToClientRect(rect) {
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = rect;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
top: y,
|
||||
left: x,
|
||||
right: x + width,
|
||||
bottom: y + height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
exports.alignments = alignments;
|
||||
exports.clamp = clamp;
|
||||
exports.createCoords = createCoords;
|
||||
exports.evaluate = evaluate;
|
||||
exports.expandPaddingObject = expandPaddingObject;
|
||||
exports.floor = floor;
|
||||
exports.getAlignment = getAlignment;
|
||||
exports.getAlignmentAxis = getAlignmentAxis;
|
||||
exports.getAlignmentSides = getAlignmentSides;
|
||||
exports.getAxisLength = getAxisLength;
|
||||
exports.getExpandedPlacements = getExpandedPlacements;
|
||||
exports.getOppositeAlignmentPlacement = getOppositeAlignmentPlacement;
|
||||
exports.getOppositeAxis = getOppositeAxis;
|
||||
exports.getOppositeAxisPlacements = getOppositeAxisPlacements;
|
||||
exports.getOppositePlacement = getOppositePlacement;
|
||||
exports.getPaddingObject = getPaddingObject;
|
||||
exports.getSide = getSide;
|
||||
exports.getSideAxis = getSideAxis;
|
||||
exports.max = max;
|
||||
exports.min = min;
|
||||
exports.placements = placements;
|
||||
exports.rectToClientRect = rectToClientRect;
|
||||
exports.round = round;
|
||||
exports.sides = sides;
|
||||
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIUtils={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],o=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),i=Math.min,r=Math.max,c=Math.round,u=Math.floor,f={left:"right",right:"left",bottom:"top",top:"bottom"},s={start:"end",end:"start"};function a(t){return t.split("-")[0]}function l(t){return t.split("-")[1]}function g(t){return"x"===t?"y":"x"}function p(t){return"y"===t?"height":"width"}const d=new Set(["top","bottom"]);function m(t){return d.has(a(t))?"y":"x"}function h(t){return g(m(t))}function x(t){return t.replace(/start|end/g,(t=>s[t]))}const b=["left","right"],y=["right","left"],A=["top","bottom"],O=["bottom","top"];function P(t){return t.replace(/left|right|bottom|top/g,(t=>f[t]))}function w(t){return{top:0,right:0,bottom:0,left:0,...t}}t.alignments=n,t.clamp=function(t,e,n){return r(t,i(e,n))},t.createCoords=t=>({x:t,y:t}),t.evaluate=function(t,e){return"function"==typeof t?t(e):t},t.expandPaddingObject=w,t.floor=u,t.getAlignment=l,t.getAlignmentAxis=h,t.getAlignmentSides=function(t,e,n){void 0===n&&(n=!1);const o=l(t),i=h(t),r=p(i);let c="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(c=P(c)),[c,P(c)]},t.getAxisLength=p,t.getExpandedPlacements=function(t){const e=P(t);return[x(t),e,x(e)]},t.getOppositeAlignmentPlacement=x,t.getOppositeAxis=g,t.getOppositeAxisPlacements=function(t,e,n,o){const i=l(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?y:b:e?b:y;case"left":case"right":return e?A:O;default:return[]}}(a(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(x)))),r},t.getOppositePlacement=P,t.getPaddingObject=function(t){return"number"!=typeof t?w(t):{top:t,right:t,bottom:t,left:t}},t.getSide=a,t.getSideAxis=m,t.max=r,t.min=i,t.placements=o,t.rectToClientRect=function(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}},t.round=c,t.sides=e}));
|
||||
Reference in New Issue
Block a user