改了url

This commit is contained in:
z
2025-05-16 12:11:51 +09:00
parent 68cb20c2d5
commit 4b91f4c4d2
312 changed files with 20217 additions and 366 deletions

View File

@ -0,0 +1,12 @@
import type { State, Padding } from "../types";
import type { Placement, ComputedPlacement, Boundary, RootBoundary } from "../enums";
declare type Options = {
placement: Placement;
padding: Padding;
boundary: Boundary;
rootBoundary: RootBoundary;
flipVariations: boolean;
allowedAutoPlacements?: Array<Placement>;
};
export default function computeAutoPlacement(state: Partial<State>, options?: Options): Array<ComputedPlacement>;
export {};

View File

@ -0,0 +1,43 @@
import getVariation from "./getVariation.js";
import { variationPlacements, basePlacements, placements as allPlacements } from "../enums.js";
import detectOverflow from "./detectOverflow.js";
import getBasePlacement from "./getBasePlacement.js";
export default function computeAutoPlacement(state, options) {
if (options === void 0) {
options = {};
}
var _options = options,
placement = _options.placement,
boundary = _options.boundary,
rootBoundary = _options.rootBoundary,
padding = _options.padding,
flipVariations = _options.flipVariations,
_options$allowedAutoP = _options.allowedAutoPlacements,
allowedAutoPlacements = _options$allowedAutoP === void 0 ? allPlacements : _options$allowedAutoP;
var variation = getVariation(placement);
var placements = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
return getVariation(placement) === variation;
}) : basePlacements;
var allowedPlacements = placements.filter(function (placement) {
return allowedAutoPlacements.indexOf(placement) >= 0;
});
if (allowedPlacements.length === 0) {
allowedPlacements = placements;
} // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
var overflows = allowedPlacements.reduce(function (acc, placement) {
acc[placement] = detectOverflow(state, {
placement: placement,
boundary: boundary,
rootBoundary: rootBoundary,
padding: padding
})[getBasePlacement(placement)];
return acc;
}, {});
return Object.keys(overflows).sort(function (a, b) {
return overflows[a] - overflows[b];
});
}

View File

@ -0,0 +1,73 @@
// @flow
import type { State, Padding } from '../types';
import type {
Placement,
ComputedPlacement,
Boundary,
RootBoundary,
} from '../enums';
import getVariation from './getVariation';
import {
variationPlacements,
basePlacements,
placements as allPlacements,
} from '../enums';
import detectOverflow from './detectOverflow';
import getBasePlacement from './getBasePlacement';
type Options = {
placement: Placement,
padding: Padding,
boundary: Boundary,
rootBoundary: RootBoundary,
flipVariations: boolean,
allowedAutoPlacements?: Array<Placement>,
};
type OverflowsMap = { [ComputedPlacement]: number };
export default function computeAutoPlacement(
state: $Shape<State>,
options: Options = {}
): Array<ComputedPlacement> {
const {
placement,
boundary,
rootBoundary,
padding,
flipVariations,
allowedAutoPlacements = allPlacements,
} = options;
const variation = getVariation(placement);
const placements = variation
? flipVariations
? variationPlacements
: variationPlacements.filter(
(placement) => getVariation(placement) === variation
)
: basePlacements;
let allowedPlacements = placements.filter(
(placement) => allowedAutoPlacements.indexOf(placement) >= 0
);
if (allowedPlacements.length === 0) {
allowedPlacements = placements;
}
// $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
const overflows: OverflowsMap = allowedPlacements.reduce((acc, placement) => {
acc[placement] = detectOverflow(state, {
placement,
boundary,
rootBoundary,
padding,
})[getBasePlacement(placement)];
return acc;
}, {});
return Object.keys(overflows).sort((a, b) => overflows[a] - overflows[b]);
}

View File

@ -0,0 +1,8 @@
import type { Rect, PositioningStrategy, Offsets, ClientRectObject } from "../types";
import { Placement } from "../enums";
export default function computeOffsets({ reference, element, placement }: {
reference: Rect | ClientRectObject;
element: Rect | ClientRectObject;
strategy: PositioningStrategy;
placement?: Placement;
}): Offsets;

View File

@ -0,0 +1,70 @@
import getBasePlacement from "./getBasePlacement.js";
import getVariation from "./getVariation.js";
import getMainAxisFromPlacement from "./getMainAxisFromPlacement.js";
import { top, right, bottom, left, start, end } from "../enums.js";
export default function computeOffsets(_ref) {
var reference = _ref.reference,
element = _ref.element,
placement = _ref.placement;
var basePlacement = placement ? getBasePlacement(placement) : null;
var variation = placement ? getVariation(placement) : null;
var commonX = reference.x + reference.width / 2 - element.width / 2;
var commonY = reference.y + reference.height / 2 - element.height / 2;
var offsets;
switch (basePlacement) {
case top:
offsets = {
x: commonX,
y: reference.y - element.height
};
break;
case bottom:
offsets = {
x: commonX,
y: reference.y + reference.height
};
break;
case right:
offsets = {
x: reference.x + reference.width,
y: commonY
};
break;
case left:
offsets = {
x: reference.x - element.width,
y: commonY
};
break;
default:
offsets = {
x: reference.x,
y: reference.y
};
}
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
if (mainAxis != null) {
var len = mainAxis === 'y' ? 'height' : 'width';
switch (variation) {
case start:
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
break;
case end:
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
break;
default:
}
}
return offsets;
}

View File

@ -0,0 +1,82 @@
// @flow
import getBasePlacement from './getBasePlacement';
import getVariation from './getVariation';
import getMainAxisFromPlacement from './getMainAxisFromPlacement';
import type {
Rect,
PositioningStrategy,
Offsets,
ClientRectObject,
} from '../types';
import { top, right, bottom, left, start, end, type Placement } from '../enums';
export default function computeOffsets({
reference,
element,
placement,
}: {
reference: Rect | ClientRectObject,
element: Rect | ClientRectObject,
strategy: PositioningStrategy,
placement?: Placement,
}): Offsets {
const basePlacement = placement ? getBasePlacement(placement) : null;
const variation = placement ? getVariation(placement) : null;
const commonX = reference.x + reference.width / 2 - element.width / 2;
const commonY = reference.y + reference.height / 2 - element.height / 2;
let offsets;
switch (basePlacement) {
case top:
offsets = {
x: commonX,
y: reference.y - element.height,
};
break;
case bottom:
offsets = {
x: commonX,
y: reference.y + reference.height,
};
break;
case right:
offsets = {
x: reference.x + reference.width,
y: commonY,
};
break;
case left:
offsets = {
x: reference.x - element.width,
y: commonY,
};
break;
default:
offsets = {
x: reference.x,
y: reference.y,
};
}
const mainAxis = basePlacement
? getMainAxisFromPlacement(basePlacement)
: null;
if (mainAxis != null) {
const len = mainAxis === 'y' ? 'height' : 'width';
switch (variation) {
case start:
offsets[mainAxis] =
offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
break;
case end:
offsets[mainAxis] =
offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
break;
default:
}
}
return offsets;
}

1
node_modules/@popperjs/core/lib/utils/debounce.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export default function debounce<T>(fn: (...args: Array<any>) => any): () => Promise<T>;

15
node_modules/@popperjs/core/lib/utils/debounce.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
export default function debounce(fn) {
var pending;
return function () {
if (!pending) {
pending = new Promise(function (resolve) {
Promise.resolve().then(function () {
pending = undefined;
resolve(fn());
});
});
}
return pending;
};
}

17
node_modules/@popperjs/core/lib/utils/debounce.js.flow generated vendored Normal file
View File

@ -0,0 +1,17 @@
// @flow
export default function debounce<T>(fn: Function): () => Promise<T> {
let pending;
return () => {
if (!pending) {
pending = new Promise<T>(resolve => {
Promise.resolve().then(() => {
pending = undefined;
resolve(fn());
});
});
}
return pending;
};
}

View File

@ -0,0 +1,12 @@
import type { State, SideObject, Padding, PositioningStrategy } from "../types";
import type { Placement, Boundary, RootBoundary, Context } from "../enums";
export declare type Options = {
placement: Placement;
strategy: PositioningStrategy;
boundary: Boundary;
rootBoundary: RootBoundary;
elementContext: Context;
altBoundary: boolean;
padding: Padding;
};
export default function detectOverflow(state: State, options?: Partial<Options>): SideObject;

View File

@ -0,0 +1,65 @@
import getClippingRect from "../dom-utils/getClippingRect.js";
import getDocumentElement from "../dom-utils/getDocumentElement.js";
import getBoundingClientRect from "../dom-utils/getBoundingClientRect.js";
import computeOffsets from "./computeOffsets.js";
import rectToClientRect from "./rectToClientRect.js";
import { clippingParents, reference, popper, bottom, top, right, basePlacements, viewport } from "../enums.js";
import { isElement } from "../dom-utils/instanceOf.js";
import mergePaddingObject from "./mergePaddingObject.js";
import expandToHashMap from "./expandToHashMap.js"; // eslint-disable-next-line import/no-unused-modules
export default function detectOverflow(state, options) {
if (options === void 0) {
options = {};
}
var _options = options,
_options$placement = _options.placement,
placement = _options$placement === void 0 ? state.placement : _options$placement,
_options$strategy = _options.strategy,
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
_options$boundary = _options.boundary,
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
_options$rootBoundary = _options.rootBoundary,
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
_options$elementConte = _options.elementContext,
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
_options$altBoundary = _options.altBoundary,
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
_options$padding = _options.padding,
padding = _options$padding === void 0 ? 0 : _options$padding;
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
var altContext = elementContext === popper ? reference : popper;
var popperRect = state.rects.popper;
var element = state.elements[altBoundary ? altContext : elementContext];
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
var referenceClientRect = getBoundingClientRect(state.elements.reference);
var popperOffsets = computeOffsets({
reference: referenceClientRect,
element: popperRect,
strategy: 'absolute',
placement: placement
});
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect
var overflowOffsets = {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
};
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
if (elementContext === popper && offsetData) {
var offset = offsetData[placement];
Object.keys(overflowOffsets).forEach(function (key) {
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
overflowOffsets[key] += offset[axis] * multiply;
});
}
return overflowOffsets;
}

View File

@ -0,0 +1,112 @@
// @flow
import type { State, SideObject, Padding, PositioningStrategy } from '../types';
import type { Placement, Boundary, RootBoundary, Context } from '../enums';
import getClippingRect from '../dom-utils/getClippingRect';
import getDocumentElement from '../dom-utils/getDocumentElement';
import getBoundingClientRect from '../dom-utils/getBoundingClientRect';
import computeOffsets from './computeOffsets';
import rectToClientRect from './rectToClientRect';
import {
clippingParents,
reference,
popper,
bottom,
top,
right,
basePlacements,
viewport,
} from '../enums';
import { isElement } from '../dom-utils/instanceOf';
import mergePaddingObject from './mergePaddingObject';
import expandToHashMap from './expandToHashMap';
// eslint-disable-next-line import/no-unused-modules
export type Options = {
placement: Placement,
strategy: PositioningStrategy,
boundary: Boundary,
rootBoundary: RootBoundary,
elementContext: Context,
altBoundary: boolean,
padding: Padding,
};
export default function detectOverflow(
state: State,
options: $Shape<Options> = {}
): SideObject {
const {
placement = state.placement,
strategy = state.strategy,
boundary = clippingParents,
rootBoundary = viewport,
elementContext = popper,
altBoundary = false,
padding = 0,
} = options;
const paddingObject = mergePaddingObject(
typeof padding !== 'number'
? padding
: expandToHashMap(padding, basePlacements)
);
const altContext = elementContext === popper ? reference : popper;
const popperRect = state.rects.popper;
const element = state.elements[altBoundary ? altContext : elementContext];
const clippingClientRect = getClippingRect(
isElement(element)
? element
: element.contextElement || getDocumentElement(state.elements.popper),
boundary,
rootBoundary,
strategy
);
const referenceClientRect = getBoundingClientRect(state.elements.reference);
const popperOffsets = computeOffsets({
reference: referenceClientRect,
element: popperRect,
strategy: 'absolute',
placement,
});
const popperClientRect = rectToClientRect({
...popperRect,
...popperOffsets,
});
const elementClientRect =
elementContext === popper ? popperClientRect : referenceClientRect;
// positive = overflowing the clipping rect
// 0 or negative = within the clipping rect
const overflowOffsets = {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom:
elementClientRect.bottom -
clippingClientRect.bottom +
paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right:
elementClientRect.right - clippingClientRect.right + paddingObject.right,
};
const offsetData = state.modifiersData.offset;
// Offsets can be applied only to the popper element
if (elementContext === popper && offsetData) {
const offset = offsetData[placement];
Object.keys(overflowOffsets).forEach((key) => {
const multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
const axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
overflowOffsets[key] += offset[axis] * multiply;
});
}
return overflowOffsets;
}

View File

@ -0,0 +1,3 @@
export default function expandToHashMap<T extends number | string | boolean, K extends string>(value: T, keys: Array<K>): {
[key: string]: T;
};

View File

@ -0,0 +1,6 @@
export default function expandToHashMap(value, keys) {
return keys.reduce(function (hashMap, key) {
hashMap[key] = value;
return hashMap;
}, {});
}

View File

@ -0,0 +1,11 @@
// @flow
export default function expandToHashMap<
T: number | string | boolean,
K: string
>(value: T, keys: Array<K>): { [key: string]: T } {
return keys.reduce((hashMap, key) => {
hashMap[key] = value;
return hashMap;
}, {});
}

View File

@ -0,0 +1 @@
export default function getAltAxis(axis: "x" | "y"): "x" | "y";

3
node_modules/@popperjs/core/lib/utils/getAltAxis.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
export default function getAltAxis(axis) {
return axis === 'x' ? 'y' : 'x';
}

View File

@ -0,0 +1,5 @@
// @flow
export default function getAltAxis(axis: 'x' | 'y'): 'x' | 'y' {
return axis === 'x' ? 'y' : 'x';
}

1
node_modules/@popperjs/core/lib/utils/getAltLen.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export default function getAltLen(len: "width" | "height"): "width" | "height";

3
node_modules/@popperjs/core/lib/utils/getAltLen.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
export default function getAltLen(len) {
return len === 'width' ? 'height' : 'width';
}

View File

@ -0,0 +1,5 @@
// @flow
export default function getAltLen(len: 'width' | 'height'): 'width' | 'height' {
return len === 'width' ? 'height' : 'width';
}

View File

@ -0,0 +1,2 @@
import { BasePlacement, Placement, auto } from "../enums";
export default function getBasePlacement(placement: Placement | typeof auto): BasePlacement;

View File

@ -0,0 +1,4 @@
import { auto } from "../enums.js";
export default function getBasePlacement(placement) {
return placement.split('-')[0];
}

View File

@ -0,0 +1,8 @@
// @flow
import { type BasePlacement, type Placement, auto } from '../enums';
export default function getBasePlacement(
placement: Placement | typeof auto
): BasePlacement {
return (placement.split('-')[0]: any);
}

View File

@ -0,0 +1,2 @@
import type { SideObject } from "../types";
export default function getFreshSideObject(): SideObject;

View File

@ -0,0 +1,8 @@
export default function getFreshSideObject() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}

View File

@ -0,0 +1,11 @@
// @flow
import type { SideObject } from '../types';
export default function getFreshSideObject(): SideObject {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
};
}

View File

@ -0,0 +1,2 @@
import type { Placement } from "../enums";
export default function getMainAxisFromPlacement(placement: Placement): "x" | "y";

View File

@ -0,0 +1,3 @@
export default function getMainAxisFromPlacement(placement) {
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
}

View File

@ -0,0 +1,8 @@
// @flow
import type { Placement } from '../enums';
export default function getMainAxisFromPlacement(
placement: Placement
): 'x' | 'y' {
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
}

View File

@ -0,0 +1,2 @@
import type { Placement } from "../enums";
export default function getOppositePlacement(placement: Placement): Placement;

View File

@ -0,0 +1,11 @@
var hash = {
left: 'right',
right: 'left',
bottom: 'top',
top: 'bottom'
};
export default function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, function (matched) {
return hash[matched];
});
}

View File

@ -0,0 +1,11 @@
// @flow
import type { Placement } from '../enums';
const hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
export default function getOppositePlacement(placement: Placement): Placement {
return (placement.replace(
/left|right|bottom|top/g,
matched => hash[matched]
): any);
}

View File

@ -0,0 +1,2 @@
import type { Placement } from "../enums";
export default function getOppositeVariationPlacement(placement: Placement): Placement;

View File

@ -0,0 +1,9 @@
var hash = {
start: 'end',
end: 'start'
};
export default function getOppositeVariationPlacement(placement) {
return placement.replace(/start|end/g, function (matched) {
return hash[matched];
});
}

View File

@ -0,0 +1,10 @@
// @flow
import type { Placement } from '../enums';
const hash = { start: 'end', end: 'start' };
export default function getOppositeVariationPlacement(
placement: Placement
): Placement {
return (placement.replace(/start|end/g, matched => hash[matched]): any);
}

View File

@ -0,0 +1,2 @@
import { Variation, Placement } from "../enums";
export default function getVariation(placement: Placement): Variation | null | undefined;

View File

@ -0,0 +1,3 @@
export default function getVariation(placement) {
return placement.split('-')[1];
}

View File

@ -0,0 +1,6 @@
// @flow
import { type Variation, type Placement } from '../enums';
export default function getVariation(placement: Placement): ?Variation {
return (placement.split('-')[1]: any);
}

3
node_modules/@popperjs/core/lib/utils/math.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
export declare const max: (...values: number[]) => number;
export declare const min: (...values: number[]) => number;
export declare const round: (x: number) => number;

3
node_modules/@popperjs/core/lib/utils/math.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
export var max = Math.max;
export var min = Math.min;
export var round = Math.round;

4
node_modules/@popperjs/core/lib/utils/math.js.flow generated vendored Normal file
View File

@ -0,0 +1,4 @@
// @flow
export const max = Math.max;
export const min = Math.min;
export const round = Math.round;

View File

@ -0,0 +1,2 @@
import type { Modifier } from "../types";
export default function mergeByName(modifiers: Array<Partial<Modifier<any, any>>>): Array<Partial<Modifier<any, any>>>;

14
node_modules/@popperjs/core/lib/utils/mergeByName.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
export default function mergeByName(modifiers) {
var merged = modifiers.reduce(function (merged, current) {
var existing = merged[current.name];
merged[current.name] = existing ? Object.assign({}, existing, current, {
options: Object.assign({}, existing.options, current.options),
data: Object.assign({}, existing.data, current.data)
}) : current;
return merged;
}, {}); // IE11 does not support Object.values
return Object.keys(merged).map(function (key) {
return merged[key];
});
}

View File

@ -0,0 +1,22 @@
// @flow
import type { Modifier } from '../types';
export default function mergeByName(
modifiers: Array<$Shape<Modifier<any, any>>>
): Array<$Shape<Modifier<any, any>>> {
const merged = modifiers.reduce((merged, current) => {
const existing = merged[current.name];
merged[current.name] = existing
? {
...existing,
...current,
options: { ...existing.options, ...current.options },
data: { ...existing.data, ...current.data },
}
: current;
return merged;
}, {});
// IE11 does not support Object.values
return Object.keys(merged).map(key => merged[key]);
}

View File

@ -0,0 +1,2 @@
import type { SideObject } from "../types";
export default function mergePaddingObject(paddingObject: Partial<SideObject>): SideObject;

View File

@ -0,0 +1,4 @@
import getFreshSideObject from "./getFreshSideObject.js";
export default function mergePaddingObject(paddingObject) {
return Object.assign({}, getFreshSideObject(), paddingObject);
}

View File

@ -0,0 +1,12 @@
// @flow
import type { SideObject } from '../types';
import getFreshSideObject from './getFreshSideObject';
export default function mergePaddingObject(
paddingObject: $Shape<SideObject>
): SideObject {
return {
...getFreshSideObject(),
...paddingObject,
};
}

View File

@ -0,0 +1,2 @@
import type { Modifier } from "../types";
export default function orderModifiers(modifiers: Array<Modifier<any, any>>): Array<Modifier<any, any>>;

View File

@ -0,0 +1,44 @@
import { modifierPhases } from "../enums.js"; // source: https://stackoverflow.com/questions/49875255
function order(modifiers) {
var map = new Map();
var visited = new Set();
var result = [];
modifiers.forEach(function (modifier) {
map.set(modifier.name, modifier);
}); // On visiting object, check for its dependencies and visit them recursively
function sort(modifier) {
visited.add(modifier.name);
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
requires.forEach(function (dep) {
if (!visited.has(dep)) {
var depModifier = map.get(dep);
if (depModifier) {
sort(depModifier);
}
}
});
result.push(modifier);
}
modifiers.forEach(function (modifier) {
if (!visited.has(modifier.name)) {
// check for visited object
sort(modifier);
}
});
return result;
}
export default function orderModifiers(modifiers) {
// order based on dependencies
var orderedModifiers = order(modifiers); // order based on phase
return modifierPhases.reduce(function (acc, phase) {
return acc.concat(orderedModifiers.filter(function (modifier) {
return modifier.phase === phase;
}));
}, []);
}

View File

@ -0,0 +1,59 @@
// @flow
import type { Modifier } from '../types';
import { modifierPhases } from '../enums';
// source: https://stackoverflow.com/questions/49875255
function order(modifiers) {
const map = new Map();
const visited = new Set();
const result = [];
modifiers.forEach(modifier => {
map.set(modifier.name, modifier);
});
// On visiting object, check for its dependencies and visit them recursively
function sort(modifier: Modifier<any, any>) {
visited.add(modifier.name);
const requires = [
...(modifier.requires || []),
...(modifier.requiresIfExists || []),
];
requires.forEach(dep => {
if (!visited.has(dep)) {
const depModifier = map.get(dep);
if (depModifier) {
sort(depModifier);
}
}
});
result.push(modifier);
}
modifiers.forEach(modifier => {
if (!visited.has(modifier.name)) {
// check for visited object
sort(modifier);
}
});
return result;
}
export default function orderModifiers(
modifiers: Array<Modifier<any, any>>
): Array<Modifier<any, any>> {
// order based on dependencies
const orderedModifiers = order(modifiers);
// order based on phase
return modifierPhases.reduce((acc, phase) => {
return acc.concat(
orderedModifiers.filter(modifier => modifier.phase === phase)
);
}, []);
}

View File

@ -0,0 +1,2 @@
import type { Rect, ClientRectObject } from "../types";
export default function rectToClientRect(rect: Rect): ClientRectObject;

View File

@ -0,0 +1,8 @@
export default function rectToClientRect(rect) {
return Object.assign({}, rect, {
left: rect.x,
top: rect.y,
right: rect.x + rect.width,
bottom: rect.y + rect.height
});
}

View File

@ -0,0 +1,12 @@
// @flow
import type { Rect, ClientRectObject } from '../types';
export default function rectToClientRect(rect: Rect): ClientRectObject {
return {
...rect,
left: rect.x,
top: rect.y,
right: rect.x + rect.width,
bottom: rect.y + rect.height,
};
}

1
node_modules/@popperjs/core/lib/utils/uniqueBy.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export default function uniqueBy<T>(arr: Array<T>, fn: (arg0: T) => any): Array<T>;

11
node_modules/@popperjs/core/lib/utils/uniqueBy.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
export default function uniqueBy(arr, fn) {
var identifiers = new Set();
return arr.filter(function (item) {
var identifier = fn(item);
if (!identifiers.has(identifier)) {
identifiers.add(identifier);
return true;
}
});
}

14
node_modules/@popperjs/core/lib/utils/uniqueBy.js.flow generated vendored Normal file
View File

@ -0,0 +1,14 @@
// @flow
export default function uniqueBy<T>(arr: Array<T>, fn: T => any): Array<T> {
const identifiers = new Set();
return arr.filter(item => {
const identifier = fn(item);
if (!identifiers.has(identifier)) {
identifiers.add(identifier);
return true;
}
});
}

1
node_modules/@popperjs/core/lib/utils/userAgent.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export default function getUAString(): string;

11
node_modules/@popperjs/core/lib/utils/userAgent.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
export default function getUAString() {
var uaData = navigator.userAgentData;
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
return uaData.brands.map(function (item) {
return item.brand + "/" + item.version;
}).join(' ');
}
return navigator.userAgent;
}

View File

@ -0,0 +1,20 @@
// @flow
type Navigator = Navigator & { userAgentData?: NavigatorUAData };
interface NavigatorUAData {
brands: Array<{ brand: string, version: string }>;
mobile: boolean;
platform: string;
}
export default function getUAString(): string {
const uaData = (navigator: Navigator).userAgentData;
if (uaData?.brands && Array.isArray(uaData.brands)) {
return uaData.brands
.map((item) => `${item.brand}/${item.version}`)
.join(' ');
}
return navigator.userAgent;
}

2
node_modules/@popperjs/core/lib/utils/within.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export declare function within(min: number, value: number, max: number): number;
export declare function withinMaxClamp(min: number, value: number, max: number): number;

8
node_modules/@popperjs/core/lib/utils/within.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
import { max as mathMax, min as mathMin } from "./math.js";
export function within(min, value, max) {
return mathMax(min, mathMin(value, max));
}
export function withinMaxClamp(min, value, max) {
var v = within(min, value, max);
return v > max ? max : v;
}

11
node_modules/@popperjs/core/lib/utils/within.js.flow generated vendored Normal file
View File

@ -0,0 +1,11 @@
// @flow
import { max as mathMax, min as mathMin } from './math';
export function within(min: number, value: number, max: number): number {
return mathMax(min, mathMin(value, max));
}
export function withinMaxClamp(min: number, value: number, max: number) {
const v = within(min, value, max);
return v > max ? max : v;
}